diff --git a/core/src/main/java/com/hyperwallet/android/Hyperwallet.java b/core/src/main/java/com/hyperwallet/android/Hyperwallet.java index d0eecf36..0b5f0aa9 100644 --- a/core/src/main/java/com/hyperwallet/android/Hyperwallet.java +++ b/core/src/main/java/com/hyperwallet/android/Hyperwallet.java @@ -121,7 +121,7 @@ public static Hyperwallet getDefault() { *
The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankAccount the {@code HyperwalletBankAccount} to be created; must not be null @@ -161,7 +161,7 @@ public void createBankAccount(@NonNull final HyperwalletBankAccount bankAccount, *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankAccountPagination the ordering and filtering criteria @@ -186,7 +186,7 @@ public void listBankAccounts(@Nullable final HyperwalletBankAccountPagination ba *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankCard the {@code HyperwalletBankCard} to be created; must not be null @@ -209,14 +209,14 @@ public void createBankCard(@NonNull final HyperwalletBankCard bankCard, *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodToken the Hyperwallet specific unique identifier for the {@code HyperwalletBankAccount} * being requested; must not be null * @param listener the callback handler of responses from the Hyperwallet platform; must not be null */ - public void getBankAccount(@NonNull String transferMethodToken, + public void getBankAccount(@NonNull final String transferMethodToken, @NonNull final HyperwalletListenerThe {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodToken the Hyperwallet specific unique identifier for the {@code HyperwalletBankCard} @@ -260,7 +260,7 @@ public void getBankCard(@NonNull final String transferMethodToken, *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankAccount the {@code HyperwalletBankAccount} to be created; must not be null @@ -289,7 +289,7 @@ public void updateBankAccount(@NonNull final HyperwalletBankAccount bankAccount, *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankCard the {@code HyperwalletBankCard} to be created; must not be null @@ -316,7 +316,7 @@ public void updateBankCard(@NonNull final HyperwalletBankCard bankCard, *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodToken the Hyperwallet specific unique identifier for the {@code HyperwalletBankAccount} @@ -348,7 +348,7 @@ public void deactivateBankAccount(@NonNull final String transferMethodToken, @Nu *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodToken the Hyperwallet specific unique identifier for the {@code HyperwalletBankCard} being @@ -394,7 +394,7 @@ public void deactivateBankCard(@NonNull final String transferMethodToken, @Nulla *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodPagination the ordering and filtering criteria @@ -434,7 +434,7 @@ public void listTransferMethods(@Nullable final HyperwalletTransferMethodPaginat *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankCardPagination the ordering and filtering criteria @@ -473,7 +473,7 @@ public void listBankCards(@Nullable final HyperwalletBankCardPagination bankCard *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param bankCardPagination the ordering and filtering criteria @@ -490,6 +490,30 @@ public void listPayPalAccounts(@Nullable final PayPalAccountPagination bankCardP performRestTransaction(builder, listener); } + /** + * Returns the {@link PayPalAccount} linked to the transfer method token specified, or null if none exists. + * + *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from + * processing the request.
+ * + *This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + * if the current one is expired or about to expire.
+ * + * @param transferMethodToken the Hyperwallet specific unique identifier for the {@code PayPalAccount} + * being requested; must not be null + * @param listener the callback handler of responses from the Hyperwallet platform; must not be null + */ + public void getPayPalAccount(@NonNull final String transferMethodToken, + @NonNull final HyperwalletListenerThe {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodConfigurationKeysQuery containing the transfer method configuration key query, @@ -525,7 +549,7 @@ public void retrieveTransferMethodConfigurationKeys( *The {@link HyperwalletListener} that is passed in to this method invocation will receive the responses from * processing the request.
* - *This function will requests a new authentication token via {@link HyperwalletAuthenticationTokenProvider} + *
This function will request a new authentication token via {@link HyperwalletAuthenticationTokenProvider} * if the current one is expired or about to expire.
* * @param transferMethodConfigurationFieldQuery containing a transfer method configuration key tuple of diff --git a/core/src/test/java/com/hyperwallet/android/transfermethod/HyperwalletGetPayPalTest.java b/core/src/test/java/com/hyperwallet/android/transfermethod/HyperwalletGetPayPalTest.java new file mode 100644 index 00000000..9722bae4 --- /dev/null +++ b/core/src/test/java/com/hyperwallet/android/transfermethod/HyperwalletGetPayPalTest.java @@ -0,0 +1,150 @@ +package com.hyperwallet.android.transfermethod; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + +import static com.hyperwallet.android.model.HyperwalletStatusTransition.StatusDefinition.ACTIVATED; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.CREATED_ON; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.EMAIL; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.STATUS; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.TOKEN; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.TRANSFER_METHOD_COUNTRY; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.TRANSFER_METHOD_CURRENCY; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodFields.TYPE; +import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.PAYPAL_ACCOUNT; + +import com.hyperwallet.android.Hyperwallet; +import com.hyperwallet.android.exception.HyperwalletException; +import com.hyperwallet.android.listener.HyperwalletListener; +import com.hyperwallet.android.model.HyperwalletError; +import com.hyperwallet.android.model.HyperwalletErrors; +import com.hyperwallet.android.model.PayPalAccount; +import com.hyperwallet.android.rule.HyperwalletExternalResourceManager; +import com.hyperwallet.android.rule.HyperwalletMockWebServer; +import com.hyperwallet.android.rule.HyperwalletSdkMock; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.robolectric.RobolectricTestRunner; + +import java.net.HttpURLConnection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import okhttp3.mockwebserver.RecordedRequest; + +@RunWith(RobolectricTestRunner.class) +public class HyperwalletGetPayPalTest { + @Rule + public HyperwalletMockWebServer mServer = new HyperwalletMockWebServer(); + @Rule + public HyperwalletSdkMock mSdkMock = new HyperwalletSdkMock(mServer); + @Rule + public HyperwalletExternalResourceManager mExternalResourceManager = new HyperwalletExternalResourceManager(); + @Rule + public MockitoRule mMockito = MockitoJUnit.rule(); + + @Mock + private HyperwalletListener