question

Rohit Bhardwaj avatar image
Rohit Bhardwaj asked Lee Tickett commented

How to get customer's details using CustomerConnector?

Hi,

I have been trying to get the customer's list of address and phone numbers using CustomerConnector. I searched for a solution on the community but didn't get any relevant question. Here is my code which I'm using to get those details,

mCustomerList = customerConnector.getCustomers();

Log.d(CUSTAG, "Customer Name : " + customerList.get(i).getFirstName() + " " + customerList.get(i).getLastName());

List<PhoneNumber> phoneNumberList = mCustomerList.get(position).getPhoneNumbers();List<Address> addressList = mCustomerList.get(position).getAddresses();Log.d(CUSTAG, "Phone : " + phoneNumberList.size());
Log.d(CUSTAG, "Address : " + addressList.size());
I was able to get the FirstName and LastName quite easily but both the list size is always zero. I know it can be done using the customer's API but I wanted to try it using the CustomerConnector.

Please advice.

Customers
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Lee Tickett avatar image
Lee Tickett answered Lee Tickett commented
Same question essentially asked a few days back- see my reply https://community.clover.com/questions/16449/clover-sdk-customergetphonenumbers-and-customerget.html
Any questions, please shout!
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rohit Bhardwaj avatar image Rohit Bhardwaj commented ·

Hey @Lee Tickett,
I had read your answer before posting this question here. Your answer works for a single customer, I want the address and phone number for each and every customer using the CustomerConnector. I have used the customer's API for getting all the details but I wanted to use the SDK this time.

0 Likes 0 ·
Lee Tickett avatar image Lee Tickett Rohit Bhardwaj commented ·

What is it you want to do with each record? You should be able to extrapolate from my example (you basically need to iterate over the records in the cursor rather than just reading the first). Something like;

Cursor cursor;
Uri cUri = CustomerContract.Data.contentUriWithAccount(CloverAccount.getAccount(mContext));
cursor =
    getApplicationContext()
    .getContentResolver()
    .query(
        cUri
        , null
        , null
        , null
        , null
    );
List<com.clover.sdk.v1.customer.Customer> customers = null;
if (cursor != null && cursor.moveToFirst()) {
    while (!cursor.isAfterLast()) {
        customers.add(new com.clover.sdk.v1.customer.Customer(new JSONObject(cursor.getString(2))));
        cursor.moveToNext();
    }
}

0 Likes 0 ·

Welcome to the
Clover Developer Community