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();
}
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");
}
Aggregations