io.clarify.api
Class ClarifyResponse

java.lang.Object
  extended by io.clarify.api.ClarifyResponse

public class ClarifyResponse
extends Object

Wraps all of the details of a low-level Clarify SDK response into a single class that can be used to: 1) access the response code 2) a parsed version of the content (Using Resty), and 3) the response content (for your own parsing needs). This class depends on Resty, the underlying HTTP client used for calling the Clarify REST API. More details about this library, along with a link to the Javadoc, are available at http://beders.github.io/Resty/Resty/Overview.html


Constructor Summary
ClarifyResponse(us.monoid.web.JSONResource jsonResource)
          Initialize a new instance with the given Resty JSONResource returned by the Resty API
 
Method Summary
 us.monoid.web.JSONResource getJSONResource()
          Returns the underlying Resty JSONResource object, representing the parsed JSON response code See http://beders.github.io/Resty/Resty/Overview.html for more details on the Resty Java API
 Object getJSONValue(String path)
          Uses the Resty JSONResponse to perform attempt to get a JSON path from the response payload and return it.
 int getResponseCode()
          Returns the response code associated with this Clarify API call
 String getResponseContent()
          Returns the raw JSON content from the response, allowing the caller to parse the JSON response using their own library
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClarifyResponse

public ClarifyResponse(us.monoid.web.JSONResource jsonResource)
Initialize a new instance with the given Resty JSONResource returned by the Resty API

Parameters:
jsonResource - a JSONResource instance than can be used to navigate the parsed JSON response
Method Detail

getResponseCode

public int getResponseCode()
Returns the response code associated with this Clarify API call

Returns:
an int containing the response code as a result of the Clarify API call

getResponseContent

public String getResponseContent()
Returns the raw JSON content from the response, allowing the caller to parse the JSON response using their own library

Returns:
the JSON response payload as a String

getJSONResource

public us.monoid.web.JSONResource getJSONResource()
Returns the underlying Resty JSONResource object, representing the parsed JSON response code See http://beders.github.io/Resty/Resty/Overview.html for more details on the Resty Java API

Returns:
us.monoid.web.Resty.JSONResource that represents the parsed JSON response

getJSONValue

public Object getJSONValue(String path)
Uses the Resty JSONResponse to perform attempt to get a JSON path from the response payload and return it. The Resty Java API returns an Object type, so you will need to determine the proper type for casting. Note that it is usually a JSONObject when there is a complex JSON structure, a String, or a primitive JSON type.

Parameters:
path - is the entire URL path
Returns:
The result of the JSON path, usually a Resty us.monoid.json.JSONObject, a String, or a primitive value


Copyright © 2015 Clarify Inc. All Rights Reserved.