class ParseRESTCommand extends ParseRequest<JSONObject> {

  @Override
  protected Task<JSONObject> onResponseAsync(ParseHttpResponse response,
      ProgressCallback downloadProgressCallback) {
    String content;
    InputStream responseStream = null;
    try {
      responseStream = response.getContent();
      content = new String(ParseIOUtils.toByteArray(responseStream));
    } catch (IOException e) {
      return Task.forError(e);
    } finally {
      ParseIOUtils.closeQuietly(responseStream);
    }

    // We need to check for errors differently in /1/ than /2/ since object data in /2/ was
    // encapsulated in "data" and everything was 200, but /2/ everything is in the root JSON,
    // but errors are status 4XX.
    // See https://quip.com/4pbbA9HbOPjQ
    int statusCode = response.getStatusCode();
    if (statusCode >= 200 && statusCode < 600) { // Assume 3XX is handled by http library
      JSONObject json;
      try {
        json = new JSONObject(content);

        if (statusCode >= 400 && statusCode < 500) { // 4XX
          return Task.forError(newPermanentException(json.optInt("code"), json.optString("error")));
        } else if (statusCode >= 500) { // 5XX
          return Task.forError(newTemporaryException(json.optInt("code"), json.optString("error")));
        }

        return Task.forResult(json);
      } catch (JSONException e) {
        return Task.forError(newTemporaryException("bad json response", e));
      }
    }

    return Task.forError(newPermanentException(ParseException.OTHER_CAUSE, content));
  }

  public  ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      Map<String, ?> parameters,
      String sessionToken);
  public  ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      JSONObject jsonParameters,
      String sessionToken);
  private  ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      JSONObject jsonParameters,
      String localId, String sessionToken);
    ParseRESTCommand(Init<?> builder);

}