Updating

You can update a user using any of the VoiceLayerUser.PROPERTY constants.

Update a Single Property

To update a single property for a user:

VoiceLayerUser updatedUser = user.update(VoiceLayerUser.PROPERTY_NAME, "new_name");

or

user.update(VoiceLayerUser.PROPERTY_NAME, "new_name", new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser user, VoiceLayerException exception) {

    }
});

Update Multiple Properties

To update multiple properties on a user first create a map of property keys to their new values:

Map<String, Object> properties = new HashMap<>();
properties.put(VoiceLayerUser.PROPERTY_NAME, "new_name");
properties.put(VoiceLayerUser.PROPERTY_EMAIL, "new_email");

Note that if you want to update the user's email or password you will need to provide the user's current password for authentication:

properties.put(VoiceLayerUser.PROPERTY_CURRENT_PASSWORD, "password");

then update the perform the channel update:

VoiceLayerUser updatedUser = user.update(properties);

or

user.update(properties, new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser user, VoiceLayerException exception) {

    }
});

Update the Avatar Image

To update the user's avatar image:

VoiceLayerUser updatedUser = user.updateAvatar(avatarFile);

or

user.updateAvatar(avatarFile, new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser voiceLayerUser, VoiceLayerException exception) {

    }
});

Update Meta Data

To add or update meta data first create a map of meta data keys to values:

Map<String, Object> data = new HashMap<String, Object>();
data.put(metaKey, "meta_value");
data.put(metaKey2, 100);

If you pass a key that does not currently exist in the user's meta data, a new entry will be created. If the key already exists, the existing value for that key will be replaced with the new value provided.

then update the VoiceLayerUser.PROPERTY_DATA property for the user:

VoiceLayerUser updatedUser = user.update(VoiceLayerUser.PROPERTY_DATA, data);

or

user.update(VoiceLayerUser.PROPERTY_DATA, data, new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser user, VoiceLayerException exception) {

    }
});

You can also update the VoiceLayerUser.PROPERTY_DATA field as part of a multiple property update.

Remove a Single Meta Data Entry

To remove meta data for a user:

VoiceLayerUser updatedUser = user.removeMeta(metaKey);

or

user.removeMeta(metaKey, new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser user, VoiceLayerException exception) {

    }
});

Remove Multiple Meta Data Entries

First create a list of meta data keys to remove:

List<String> metaKeys = new ArrayList<String>();
metaKeys.add("meta_key");
metaKeys.add("meta_key_2");

then:

VoiceLayerUser updatedUser = user.removeMeta(metaKeys);

or

user.removeMeta(metaKeys, new VoiceLayerUpdateCallback<VoiceLayerUser>() {
    @Override
    public void onUpdateComplete(VoiceLayerUser user, VoiceLayerException exception) {

    }
});