Profile service

// service which methods will accept callbacks to deliver result, the request will be performed in the background delivering result in UI thread.
service = client.service().profileWithDefaults();
// service which methods will return observables you need to subscribe to
service = client.rxService().profileWithDefaults();

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


Data consistency

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

When obtaining profile details from our services you can find anETag in the ComapiResult object. This describes which version of 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 way, you can keep consistency of the data across many devices.


Profile details

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

service.getProfile(profileId,
   new Callback<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 string-object map with a list of profile properties, each associated with a user profile conforming to the provided query.

📘

Query syntax

You can use the QueryBuilder helper class to construct valid query string, for example:

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

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

Learn more about query syntax.


Update profile

Update your user profile, providing a custom map of values that should be associated with it:

service.updateProfile(profileDetails, eTag,
   new Callback<ComapiResult<List<ComapiProfile>>>(){/* implement */});
rxService.updateProfile(profileDetailsMap, eTag)
   .subscribe(new Observer<ComapiResult<List<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 */});