Profile service

service = client.service().profileWithDefaults();

Depending on the client you initialised, ComapiClient or RxComapiClient , you have access to callbacks or reactive profile APIs.

The reactive version returns Observables you need to subscribe to. For the callback version, pass callback as the last parameter and the request is performed in the background, delivering results in the UI thread.


Data consistency

In order to manage concurrent updates of a conversation from many devices or websites, use ETag.

When obtaining profile details from our services you can find an ETag in the ComapiResult object. It describes what version of the server data you received.

When you want to update this data, pass the same ETag with the new profile details. If the server data changes before your next update, the services don’t allow the modification until you obtain the most recent version of the data and pass the correct ETag with the next update. This means you can keep consistency of the data across many devices.


Profile details

Get the profile details of a user registered in the same API space as the SDK:

service.getProfile(profileId,
   new Callback<ComapiResult<ComapiResult<ComapiProfile>>>(){/* implement */});
rxService.getProfile(profileId)
   .subscribe(new Observer<ComapiResult<ComapiProfile>>() {/* implement */});

The result contains a string-object map of properties associated with a given user profile.


Query profiles

Query profiles registered in an API space:

service.queryProfiles(queryString,
   new Callback<ComapiResult<List<ComapiProfile>>>(){/* implement */});
rxService.queryProfiles(queryString)
   .subscribe(new Observer<ComapiResult<List<ComapiProfile>>>() {/* implement */});

In the result you get a ComapiProfile object with a list of profile properties, each associated with a user profile conforming to provided query.

You can use the QueryBuilder helper class to construct a valid query string.

Learn more about query syntax.

Example

String queryString = new QueryBuilder().addExists("email").build();

and queryProfiles looks for all profiles containing a field named email.


Update profile

Update a user profile providing custom map of values that should be associated with it.

service.updateProfile(profileDetails, eTag,
   new Callback<ComapiResult<ComapiProfile>>(){/* implement */});
rxService.updateProfile(profileDetails, eTag)
   .subscribe(new Observer<ComapiResult<ComapiProfile>>(){/* implement */});

The result contains the updated details.


Patch profile

Applies a patch for a user profile.

This method doesn't erase previous profile details with different keys.

service.patchProfile(profileId, profileDetails, eTag,
   new Callback<ComapiResult<ComapiProfile>>(){/* implement */});
rxService.patchProfile(profileId, profileDetails, eTag)
   .subscribe(new Observer<ComapiResult<ComapiProfile>>(){/* implement */});