Interface UserProvider
-
public interface UserProvider
Setting tags and fields on a user are features. Your plan must support these features in order to work with them.
A provider which will offer a higher level of abstraction compared to the
UserService
You can create an instance of UserProvider like this:import zendesk.core.UserProvider; import zendesk.core.Zendesk; ... UserProvider provider = Zendesk.INSTANCE.provider().userProvider(); ...
Once you have an instance of the provider you can call methods on it and handle the results in callbacks. A success callback will give you the resource(s) that you are requesting. The error callback will be called if there was some issue with the method call and it will define details about the error in an
ErrorResponse
For example you can upload a file like this:
provider.addTags(Arrays.asList("tag", "foo", "bar"), new ZendeskCallback<User>() { @Override public void onSuccess(final User user) { // Handle success } @Override public void onError(final ErrorResponse errorResponse) { // Handle error } });
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
addTags(java.util.List<java.lang.String> tags, <any> callback)
Calls a user service to add tags to a user on behalf of the end-user.void
deleteTags(java.util.List<java.lang.String> tags, <any> callback)
Calls a user service to remove tags from a user on behalf of the end-user.void
getUser(<any> callback)
Calls a user service to get information about the current logged in user.void
getUserFields(<any> callback)
Gets a list of user field definitions that are available in your account.void
setUserFields(java.util.Map<java.lang.String,java.lang.String> userFields, <any> callback)
Sets the user fields for the current user.
-
-
-
Method Detail
-
addTags
void addTags(java.util.List<java.lang.String> tags, <any> callback)
Calls a user service to add tags to a user on behalf of the end-user.- Parameters:
tags
- A list of tags.callback
- Callback that will deliver the list of the user's tags after the call or anErrorResponse
- Since:
- 1.4.0.1
-
deleteTags
void deleteTags(java.util.List<java.lang.String> tags, <any> callback)
Calls a user service to remove tags from a user on behalf of the end-user.- Parameters:
tags
- A list of tagscallback
- Callback that will deliver the list of the user's tags after the call or anErrorResponse
-
getUserFields
void getUserFields(<any> callback)
Gets a list of user field definitions that are available in your account.Note that this retrieves the definitions, and not the values of the user fields for the current user. To retrieve the values you should call
#getUser(ZendeskCallback)
, and then callUser.getUserFields()
on the returnedUser
object.- Parameters:
callback
- Callback that will deliver a newly created list containingUserField
orErrorResponse
- Since:
- 1.4.0.1
-
setUserFields
void setUserFields(java.util.Map<java.lang.String,java.lang.String> userFields, <any> callback)
Sets the user fields for the current user.User fields must have been created in your Zendesk account before they can be set by this method. The userFields map is a map from the key of your user field to the value of your user field.
Map<String, String> userFields = new HashMap<>(); userFields.put("sdk_phone_number", "12345"); userProvider.setUserFields(userFields, new ZendeskCallback<Map<String, String>>() { // handle callbacks });
- Parameters:
userFields
- A map containing the fields to be set. The map is from a field's key to its valuecallback
- Callback that will deliver the map of the user's fields and their values after the call or anErrorResponse
- Since:
- 1.4.0.1
- See Also:
- Adding custom fields to users
-
getUser
void getUser(<any> callback)
Calls a user service to get information about the current logged in user.The
User
object which is returned from this method's callback only contains the user's tags and fields at this time.- Parameters:
callback
- Callback that will deliver a newly created request of typeUser
orErrorResponse
- Since:
- 1.4.0.1
-
-