diff --git a/app/build.gradle b/app/build.gradle index e95b84b..d3c7f72 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,12 +23,13 @@ android { } dependencies { - implementation "com.plaid.link:sdk-core:2.2.0" - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation "com.plaid.link:sdk-core:3.0.0" + + implementation "androidx.appcompat:appcompat:1.2.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.1' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'com.google.android.material:material:1.2.0' + implementation "androidx.core:core-ktx:1.3.1" + implementation "androidx.constraintlayout:constraintlayout:1.1.3" + implementation "com.google.android.material:material:1.2.0" implementation "com.squareup.retrofit2:retrofit:2.9.0" implementation "com.squareup.retrofit2:converter-gson:2.9.0" diff --git a/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt b/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt index fd97e42..c39daac 100644 --- a/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt +++ b/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt @@ -13,6 +13,5 @@ class LinkSampleApplication : Application() { override fun onCreate() { super.onCreate() - Plaid.initialize(this) } } diff --git a/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java b/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java index 2d69692..9530121 100644 --- a/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java +++ b/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java @@ -15,6 +15,5 @@ public class LinkSampleApplicationJava extends Application { public void onCreate() { super.onCreate(); - Plaid.initialize(this); } } diff --git a/app/src/main/java/com/plaid/linksample/MainActivity.kt b/app/src/main/java/com/plaid/linksample/MainActivity.kt index 93605cb..e7c8a5c 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivity.kt +++ b/app/src/main/java/com/plaid/linksample/MainActivity.kt @@ -14,9 +14,8 @@ import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.plaid.link.Plaid -import com.plaid.link.linkTokenConfiguration -import com.plaid.link.openPlaidLink -import com.plaid.link.result.PlaidLinkResultHandler +import com.plaid.link.configuration.LinkTokenConfiguration +import com.plaid.link.result.LinkResultHandler import com.plaid.linksample.network.LinkTokenRequester class MainActivity : AppCompatActivity() { @@ -25,7 +24,7 @@ class MainActivity : AppCompatActivity() { private lateinit var tokenResult: TextView private val myPlaidResultHandler by lazy { - PlaidLinkResultHandler( + LinkResultHandler( onSuccess = { tokenResult.text = getString(R.string.public_token_result, it.publicToken) result.text = getString(R.string.content_success) @@ -77,11 +76,13 @@ class MainActivity : AppCompatActivity() { } private fun onLinkTokenSuccess(linkToken: String) { - this@MainActivity.openPlaidLink( - linkTokenConfiguration = linkTokenConfiguration { - token = linkToken - } + Plaid.create( + this.application, + LinkTokenConfiguration.Builder() + .token(linkToken) + .build() ) + .open(this) } private fun onLinkTokenError(error: Throwable) { diff --git a/app/src/main/java/com/plaid/linksample/MainActivityJava.java b/app/src/main/java/com/plaid/linksample/MainActivityJava.java index 392482b..fb95349 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivityJava.java +++ b/app/src/main/java/com/plaid/linksample/MainActivityJava.java @@ -16,20 +16,21 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; + import com.plaid.link.Plaid; import com.plaid.link.configuration.LinkTokenConfiguration; -import com.plaid.link.configuration.PlaidProduct; -import com.plaid.link.result.PlaidLinkResultHandler; +import com.plaid.link.result.LinkResultHandler; import com.plaid.linksample.network.LinkTokenRequester; -import java.util.ArrayList; + import kotlin.Unit; + public class MainActivityJava extends AppCompatActivity { private TextView result; private TextView tokenResult; - private final PlaidLinkResultHandler myPlaidResultHandler = new PlaidLinkResultHandler( + private LinkResultHandler myPlaidResultHandler = new LinkResultHandler( linkSuccess -> { tokenResult.setText(getString( R.string.public_token_result, @@ -40,15 +41,17 @@ public class MainActivityJava extends AppCompatActivity { }, linkExit -> { tokenResult.setText(""); - if (linkExit.error != null) { + if (linkExit.getError() != null) { result.setText(getString( R.string.content_exit, - linkExit.error.getDisplayMessage(), - linkExit.error.getErrorCode())); + linkExit.getError().getDisplayMessage(), + linkExit.getError().getErrorCode())); } else { result.setText(getString( R.string.content_cancel, - linkExit.metadata.status != null ? linkExit.metadata.status.jsonValue : "unknown")); + linkExit.getMetadata().getStatus() != null ? linkExit.getMetadata() + .getStatus() + .getJsonValue() : "unknown")); } return Unit.INSTANCE; } @@ -83,19 +86,17 @@ private void setOptionalEventListener() { * parameter reference */ private void openLink() { - ArrayList products = new ArrayList<>(); - products.add(PlaidProduct.TRANSACTIONS); LinkTokenRequester.INSTANCE.getToken() .subscribe(this::onLinkTokenSuccess, this::onLinkTokenError); } private void onLinkTokenSuccess(String token) { - Plaid.openLink( - this, + Plaid.create( + getApplication(), new LinkTokenConfiguration.Builder() .token(token) - .build() - .toLinkConfiguration()); + .build()) + .open(this); } private void onLinkTokenError(Throwable error) {