Search in sources :

Example 1 with CustomerDetailsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSession method getCustomerDetails.

/**
 * Gets the CustomerDetails from the GC gateway
 *
 * @param productId, the productId for which you want to look up customerDetails
 * @param countryCode, the country of the customer
 * @param values, the
 */
public void getCustomerDetails(Context context, String productId, CountryCode countryCode, List<KeyValuePair> values, OnCustomerDetailsCallCompleteListener listener) {
    if (context == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, context may not be null");
    }
    if (productId == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, productId may not be null");
    }
    if (countryCode == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, countryCode may not be null");
    }
    if (values == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, values may not be null");
    }
    CustomerDetailsAsyncTask task = new CustomerDetailsAsyncTask(context, productId, countryCode, values, communicator, listener);
    task.execute();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) CustomerDetailsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask)

Example 2 with CustomerDetailsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class CustomerDetailsAsyncTaskTest method testCustomerDetailsAsyncTaskWithValidRequest.

@Test
public void testCustomerDetailsAsyncTaskWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
    Listener listener = new Listener(waitForAsyncTaskCallBack);
    KeyValuePair keyValuePair = new KeyValuePair();
    keyValuePair.setKey("fiscalNumber");
    keyValuePair.setValue("4605092222");
    List<KeyValuePair> values = new ArrayList<>();
    values.add(keyValuePair);
    // Create the CustomerDetailsAsyncTask and start the test by running execute
    CustomerDetailsAsyncTask customerDetailsAsyncTask = new CustomerDetailsAsyncTask(getContext(), "9000", CountryCode.SE, values, getCommunicator(), listener);
    customerDetailsAsyncTask.execute();
    // Test that the getCustomerDetails call returns within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncTaskCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the customer details response from the listener
    CustomerDetailsResponse customerDetailsResponse = listener.getCustomerDetailsResponse();
    assertNotNull(customerDetailsResponse);
    assertEquals(customerDetailsResponse.getCountry(), "Sweden");
}
Also used : KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) ArrayList(java.util.ArrayList) CustomerDetailsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) CustomerDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.CustomerDetailsResponse) Test(org.junit.Test)

Aggregations

CustomerDetailsAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask)2 CustomerDetailsResponse (com.globalcollect.gateway.sdk.client.android.sdk.model.CustomerDetailsResponse)1 KeyValuePair (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1