question

Eduardo Quiroz avatar image
Eduardo Quiroz asked Lee Tickett commented

Clover SDK - Customer.getPhoneNumbers() and Customer.getEmailAddresses() always empty

I'm using CustomerConnector to search for customers however the returned customers don't have any phone numbers or email addresses despite them actually having Phone numbers and Email addresses.

I have also made sure I have added the Customer's Read permission.
Clover Android SDKCustomers
1 comment
10 |2000

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

greyskymedia avatar image greyskymedia commented ·
I'd love help on this exact question too!
0 Likes 0 ·
Frank Faustino avatar image
Frank Faustino Deactivated answered Frank Faustino Deactivated edited
As was mentioned, the CustomerConnector.getCustomers() returns a Customer object that doesn't have the nested fields populated. Instead, use the CustomerConnector.getCustomer() method. If you need to get a list of customers with the phoneNumbers and emailAddresses populated, you can use both methods in conjunction. Just run a for loop on the result from the getCustomers() call and call getCustomers(customer.getId()) for each customer.

You can read more about the various methods available on CustomerConnector here: https://clover.github.io/clover-android-sdk/com/clover/sdk/v1/customer/CustomerConnector.html#getCustomer-java.lang.String-
10 |2000

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

Lee Tickett avatar image
Lee Tickett answered Lee Tickett commented
Are you trying to use CustomerConnector.getCustomers()? I suspect this doesn't expand any of the relational fields hence why you can't get phone numbers, addresses etc.
If you load a single customer using CustomerConnector.getCustomer(String id) the record appears to include the related entities. Is that any use?
Alternatively you can do something like this;
Cursor cursor;
Uri cUri = CustomerContract.Data.contentUriWithAccount(CloverAccount.getAccount(mContext));
cursor =
    getApplicationContext()
    .getContentResolver()
    .query(
        cUri
        , null
        , null
        , null
        , null
    );
com.clover.sdk.v1.customer.Customer customer = null;
if (cursor != null && cursor.moveToFirst()) {
    customer = new com.clover.sdk.v1.customer.Customer(new JSONObject(cursor.getString(2)));
}
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.

Suraj Dubey avatar image Suraj Dubey commented ·
@Lee Tickett

Hi

I have created order and through broadcast receiver I got the order_id.While creating order I added a customer for that order form POS. NOw I want customer details for that order.How I can get that

0 Likes 0 ·
Lee Tickett avatar image Lee Tickett Suraj Dubey commented ·

Hi @rapture100 please post a new question. I suspect you'll need the order.getCustomers() method.

0 Likes 0 ·
Bryanne Vega avatar image
Bryanne Vega answered
An alternative from the SDK to find a Customer by phone number/email is to query the REST API with the
&filter=phoneNumber=0123456789
Notice: If the the same customer has multiple customer records with the same phone number, you might want to merge them to avoid confusion (off topic, ask in another question for additional details).
10 |2000

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

Welcome to the
Clover Developer Community