use of com.backendless.core.responder.policy.BackendlessUserAdaptingPolicy in project Android-SDK by Backendless.
the class UserService method register.
public BackendlessUser register(BackendlessUser user) throws BackendlessException {
checkUserToBeProper(user);
BackendlessSerializer.serializeUserProperties(user);
String password = user.getPassword();
BackendlessUser userToReturn = Invoker.invokeSync(USER_MANAGER_SERVER_ALIAS, "register", new Object[] { user.getProperties() }, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
user.clearProperties();
userToReturn.setPassword(password);
user.putProperties(userToReturn.getProperties());
return userToReturn;
}
use of com.backendless.core.responder.policy.BackendlessUserAdaptingPolicy in project Android-SDK by Backendless.
the class UserService method register.
public void register(final BackendlessUser user, final AsyncCallback<BackendlessUser> responder) {
try {
checkUserToBeProper(user);
BackendlessSerializer.serializeUserProperties(user);
Invoker.invokeAsync(USER_MANAGER_SERVER_ALIAS, "register", new Object[] { user.getProperties() }, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
response.setPassword(user.getPassword());
user.clearProperties();
user.putProperties(response.getProperties());
if (responder != null)
responder.handleResponse(response);
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
}, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
} catch (BackendlessException e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.core.responder.policy.BackendlessUserAdaptingPolicy in project Android-SDK by Backendless.
the class UserServiceAndroidExtra method getBackendlessUser.
private void getBackendlessUser(final AccessToken accessToken, final Map<String, String> facebookFieldsMappings, final AsyncCallback<BackendlessUser> responder) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
FacebookBundle facebookBundle = new FacebookBundle(response, accessToken);
Object[] requestData = new Object[] { null, facebookBundle.accessToken, null, null, facebookFieldsMappings };
Invoker.invokeAsync(UserService.USER_MANAGER_SERVER_ALIAS, "loginWithFacebook", requestData, responder, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();
}
use of com.backendless.core.responder.policy.BackendlessUserAdaptingPolicy in project Android-SDK by Backendless.
the class UserService method update.
public void update(final BackendlessUser user, final AsyncCallback<BackendlessUser> responder) {
try {
checkUserToBeProperForUpdate(user);
BackendlessSerializer.serializeUserProperties(user);
if (user.getUserId() != null && user.getUserId().equals(""))
throw new IllegalArgumentException(ExceptionMessage.WRONG_USER_ID);
Invoker.invokeAsync(USER_MANAGER_SERVER_ALIAS, "update", new Object[] { user.getProperties() }, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
user.clearProperties();
user.putProperties(response.getProperties());
if (responder != null)
responder.handleResponse(response);
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
}, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.core.responder.policy.BackendlessUserAdaptingPolicy in project Android-SDK by Backendless.
the class UserService method update.
public BackendlessUser update(final BackendlessUser user) throws BackendlessException {
checkUserToBeProperForUpdate(user);
BackendlessSerializer.serializeUserProperties(user);
if (user.getUserId() != null && user.getUserId().equals(""))
throw new IllegalArgumentException(ExceptionMessage.WRONG_USER_ID);
BackendlessUser userToReturn = Invoker.invokeSync(USER_MANAGER_SERVER_ALIAS, "update", new Object[] { user.getProperties() }, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
user.clearProperties();
user.putProperties(userToReturn.getProperties());
return userToReturn;
}
Aggregations