@Test public void updatePush() throws Exception { Exception error = null; JSONObject json = null; try { NCMBPushService pushService = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); JSONObject params = new JSONObject(); params.put("title", "title_update"); params.put("message", "message_update"); json = pushService.updatePush("7FrmPTBKSNtVjajm", params); } catch (NCMBException e) { error = e; } Assert.assertNull(error); Assert.assertEquals("2014-06-04T11:28:30.348Z", json.getString("updateDate")); }
public JSONObject updatePush(String pushId, JSONObject params) throws NCMBException { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } else if (params == null) { throw new NCMBException(NCMBException.INVALID_JSON, "params must no be null"); } else if (params.has("deliveryTime") && params.has("immediateDeliveryFlag")) { throw new NCMBException(NCMBException.INVALID_JSON, "'deliveryTime' and 'immediateDeliveryFlag' can not be set at the same time."); } RequestParams request = createRequestParams(pushId, params, null, NCMBRequest.HTTP_METHOD_PUT); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_PUSH_UPDATED) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Updated failed."); } return response.responseData; }
NCMBPushService extends NCMBService { public JSONObject updatePush(String pushId, JSONObject params) throws NCMBException { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } else if (params == null) { throw new NCMBException(NCMBException.INVALID_JSON, "params must no be null"); } else if (params.has("deliveryTime") && params.has("immediateDeliveryFlag")) { throw new NCMBException(NCMBException.INVALID_JSON, "'deliveryTime' and 'immediateDeliveryFlag' can not be set at the same time."); } RequestParams request = createRequestParams(pushId, params, null, NCMBRequest.HTTP_METHOD_PUT); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_PUSH_UPDATED) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Updated failed."); } return response.responseData; } }
NCMBPushService extends NCMBService { public JSONObject updatePush(String pushId, JSONObject params) throws NCMBException { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } else if (params == null) { throw new NCMBException(NCMBException.INVALID_JSON, "params must no be null"); } else if (params.has("deliveryTime") && params.has("immediateDeliveryFlag")) { throw new NCMBException(NCMBException.INVALID_JSON, "'deliveryTime' and 'immediateDeliveryFlag' can not be set at the same time."); } RequestParams request = createRequestParams(pushId, params, null, NCMBRequest.HTTP_METHOD_PUT); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_PUSH_UPDATED) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Updated failed."); } return response.responseData; } NCMBPushService(NCMBContext context); }
NCMBPushService extends NCMBService { public JSONObject updatePush(String pushId, JSONObject params) throws NCMBException { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } else if (params == null) { throw new NCMBException(NCMBException.INVALID_JSON, "params must no be null"); } else if (params.has("deliveryTime") && params.has("immediateDeliveryFlag")) { throw new NCMBException(NCMBException.INVALID_JSON, "'deliveryTime' and 'immediateDeliveryFlag' can not be set at the same time."); } RequestParams request = createRequestParams(pushId, params, null, NCMBRequest.HTTP_METHOD_PUT); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_PUSH_UPDATED) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Updated failed."); } return response.responseData; } NCMBPushService(NCMBContext context); JSONObject sendPush(JSONObject params); void sendPushInBackground(final JSONObject params, ExecuteServiceCallback callback); JSONObject updatePush(String pushId, JSONObject params); void updatePushInBackground(final String pushId, final JSONObject params, final ExecuteServiceCallback callback); void deletePush(String pushId); void deletePushInBackground(String pushId, DoneCallback callback); NCMBPush fetchPush(String pushId); void fetchPushInBackground(final String pushId, final FetchCallback callback); List searchPush(JSONObject conditions); void searchPushInBackground(JSONObject conditions, final SearchPushCallback callback); void sendPushReceiptStatusInBackground(String pushId, ExecuteServiceCallback callback); }
NCMBPushService extends NCMBService { public JSONObject updatePush(String pushId, JSONObject params) throws NCMBException { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } else if (params == null) { throw new NCMBException(NCMBException.INVALID_JSON, "params must no be null"); } else if (params.has("deliveryTime") && params.has("immediateDeliveryFlag")) { throw new NCMBException(NCMBException.INVALID_JSON, "'deliveryTime' and 'immediateDeliveryFlag' can not be set at the same time."); } RequestParams request = createRequestParams(pushId, params, null, NCMBRequest.HTTP_METHOD_PUT); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_PUSH_UPDATED) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Updated failed."); } return response.responseData; } NCMBPushService(NCMBContext context); JSONObject sendPush(JSONObject params); void sendPushInBackground(final JSONObject params, ExecuteServiceCallback callback); JSONObject updatePush(String pushId, JSONObject params); void updatePushInBackground(final String pushId, final JSONObject params, final ExecuteServiceCallback callback); void deletePush(String pushId); void deletePushInBackground(String pushId, DoneCallback callback); NCMBPush fetchPush(String pushId); void fetchPushInBackground(final String pushId, final FetchCallback callback); List searchPush(JSONObject conditions); void searchPushInBackground(JSONObject conditions, final SearchPushCallback callback); void sendPushReceiptStatusInBackground(String pushId, ExecuteServiceCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_PUSH_CREATED; static final int HTTP_STATUS_PUSH_UPDATED; static final int HTTP_STATUS_PUSH_DELETED; static final int HTTP_STATUS_PUSH_GOTTEN; static final int HTTP_STATUS_PUSH_RECEIPTSTATUS; }