com.twilio.sdk
Class TwilioRestResponse

java.lang.Object
  extended by com.twilio.sdk.TwilioRestResponse

public class TwilioRestResponse
extends Object

TwilioRestResponse holds all the REST response data Before using the response, check IsError to see if an exception occurred with the data sent to Twilio ResponseText contains the raw string response Url and QueryString are from the request HttpStatus is the response code of the request.


Constructor Summary
TwilioRestResponse(String url, String text, int status)
          Instantiates a new twilio rest response.
 
Method Summary
 int getHttpStatus()
          Get the http status code associated with this response.
 ResponseParser getParser()
          Get an appropriate response parser for this response type
 String getQueryString()
          Get the query string that resulted in this response
 String getResponseText()
          Get the raw response body as a String
 String getUrl()
          Get the url that resulted in this response
 boolean isClientError()
          Determines if the response was a client side error (HTTP 4XX status)
 boolean isError()
          Determine if this request resulted in any kind of error
 boolean isJson()
          Method to determine if the response content type was a JSON type
 boolean isServerError()
          Determines if the response was a server side error (HTTP 5XX status)
 boolean isXml()
          Method to determine if the response content type was an XML type
 void setContentType(String contentType)
          Sets the content type.
 void setError(boolean error)
          Sets the error.
 void setHttpStatus(int httpStatus)
          Sets the http status.
 void setQueryString(String queryString)
          Sets the query string.
 void setResponseText(String responseText)
          Sets the response text.
 void setUrl(String url)
          Sets the url.
 Map<String,Object> toMap()
          Helper method to convert the response to a canonical object map.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwilioRestResponse

public TwilioRestResponse(String url,
                          String text,
                          int status)
Instantiates a new twilio rest response.

Parameters:
url - the url
text - the text
status - the status
Method Detail

getResponseText

public String getResponseText()
Get the raw response body as a String

Returns:
the response body

setResponseText

public void setResponseText(String responseText)
Sets the response text.

Parameters:
responseText - the new response text

getHttpStatus

public int getHttpStatus()
Get the http status code associated with this response.

Returns:
the int value of the response status

setHttpStatus

public void setHttpStatus(int httpStatus)
Sets the http status.

Parameters:
httpStatus - the new http status

getUrl

public String getUrl()
Get the url that resulted in this response

Returns:
the url

setUrl

public void setUrl(String url)
Sets the url.

Parameters:
url - the new url

getQueryString

public String getQueryString()
Get the query string that resulted in this response


setQueryString

public void setQueryString(String queryString)
Sets the query string.

Parameters:
queryString - the new query string

isError

public boolean isError()
Determine if this request resulted in any kind of error

Returns:
true if an error occured

setError

public void setError(boolean error)
Sets the error.

Parameters:
error - the new error

isClientError

public boolean isClientError()
Determines if the response was a client side error (HTTP 4XX status)

Returns:
true if this was a client error

isServerError

public boolean isServerError()
Determines if the response was a server side error (HTTP 5XX status)

Returns:
true if this was a server error

setContentType

public void setContentType(String contentType)
Sets the content type.

Parameters:
contentType - the new content type

isJson

public boolean isJson()
Method to determine if the response content type was a JSON type

Returns:
true if this looks like a JSON response

isXml

public boolean isXml()
Method to determine if the response content type was an XML type

Returns:
true if this looks like an XML response

getParser

public ResponseParser getParser()
Get an appropriate response parser for this response type

Returns:
a response parser capable of parsing this response body.

toMap

public Map<String,Object> toMap()
Helper method to convert the response to a canonical object map. This method will use the appropriate parser to map the response body to a Map of elements.

Returns:
a normalized Map of objects. Repeated elements are List values, sub-objects are Map values. All other types are String values.


Copyright © 2011 Twilio, Inc. All Rights Reserved.