@Test public void currentUser_PUT() throws Exception { NCMBUserService userService = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); JSONObject params = new JSONObject(); params.put("key", "value"); userService.updateUser("dummyUserId", params); NCMBUser currentUser = NCMBUser.getCurrentUser(); Assert.assertEquals("dummyUserId", currentUser.getObjectId()); Assert.assertEquals("value", currentUser.getString("key")); JSONObject update = new JSONObject(); update.put("key", "value2"); userService.updateUser("dummyUserId", update); currentUser = NCMBUser.getCurrentUser(); Assert.assertEquals("dummyUserId", currentUser.getObjectId()); Assert.assertEquals("value2", currentUser.getString("key")); DateFormat format = NCMBDateFormat.getIso8601(); Date resultDate = format.parse("2014-06-04T11:28:30.348Z"); Assert.assertEquals(resultDate, currentUser.getUpdateDate()); }
public JSONObject updateUser(String userId, JSONObject params) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); NCMBResponse response = sendRequest(reqParams); try { params.put("objectId", userId); } catch (JSONException e) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, e.getMessage()); } updateUserCheckResponse(response); writeCurrentUser(params, response.responseData); return response.responseData; }
NCMBUserService extends NCMBService { public JSONObject updateUser(String userId, JSONObject params) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); NCMBResponse response = sendRequest(reqParams); try { params.put("objectId", userId); } catch (JSONException e) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, e.getMessage()); } updateUserCheckResponse(response); writeCurrentUser(params, response.responseData); return response.responseData; } }
NCMBUserService extends NCMBService { public JSONObject updateUser(String userId, JSONObject params) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); NCMBResponse response = sendRequest(reqParams); try { params.put("objectId", userId); } catch (JSONException e) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, e.getMessage()); } updateUserCheckResponse(response); writeCurrentUser(params, response.responseData); return response.responseData; } NCMBUserService(NCMBContext context); }
NCMBUserService extends NCMBService { public JSONObject updateUser(String userId, JSONObject params) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); NCMBResponse response = sendRequest(reqParams); try { params.put("objectId", userId); } catch (JSONException e) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, e.getMessage()); } updateUserCheckResponse(response); writeCurrentUser(params, response.responseData); return response.responseData; } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); }
NCMBUserService extends NCMBService { public JSONObject updateUser(String userId, JSONObject params) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); NCMBResponse response = sendRequest(reqParams); try { params.put("objectId", userId); } catch (JSONException e) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, e.getMessage()); } updateUserCheckResponse(response); writeCurrentUser(params, response.responseData); return response.responseData; } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_REGISTERED; static final int HTTP_STATUS_AUTHORIZED; static final int HTTP_STATUS_REQUEST_ACCEPTED; }