All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.factual.driver.ClearResponse Maven / Gradle / Ivy

The newest version!
package com.factual.driver;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Represents the response from running a Clear request against Factual.
 * 
 * @author brandon
 */
public class ClearResponse extends Response {
  private String factualId;
  private String commitId;

  /**
   * Constructor, parses from a JSON response String.
   */
  public ClearResponse(InternalResponse resp) {
    super(resp);
    try {
      JSONObject rootJsonObj = new JSONObject(resp.getContent());
      Response.withMeta(this, rootJsonObj);
      parseResponse(rootJsonObj.getJSONObject(Constants.RESPONSE));
    } catch (JSONException e) {
      throw new RuntimeException(e);
    }
  }

  private void parseResponse(JSONObject jo) throws JSONException {
    factualId = jo.getString(Constants.CLEAR_FACTUAL_ID);
    commitId = jo.getString(Constants.CLEAR_COMMIT_ID);
  }

  /**
   * @return the factual id that submit was performed on
   */
  public String getFactualId() {
    return factualId;
  }

  /**
   * @return the commit id associated with this clear
   */
  public String getCommitId() {
    return commitId;
  }

  @Override
  public String getJson() {
    return resp.getContent();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy