Package com.hellosign.sdk.http
Class HttpClient
- java.lang.Object
-
- com.hellosign.sdk.http.HttpClient
-
public class HttpClient extends java.lang.ObjectAbstracts HTTP requests.
-
-
Constructor Summary
Constructors Constructor Description HttpClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FileasFile(java.lang.String fileName)Executes the request and returns the response as a File.intasHttpCode()Executes the request and returns the HTTP response code.org.json.JSONObjectasJson()Executes the request and returns the response as a JSONObject.HttpClientdelete(java.lang.String url)Initializes a DELETE request to the given URL.HttpClientget(java.lang.String url)Initializes a GET request to the given URL.java.lang.StringgetLastResponse()Returns the response to the last HTTP request as a string.longgetLastResponseAsFile(java.io.File f)Returns the last HTTP request body as a file.java.lang.IntegergetLastResponseCode()Returns the HTTP status code for the last request.HttpClientoptions(java.lang.String url)Makes an OPTIONS request to the given URLHttpClientpost(java.lang.String url)Initializes a POST request to the given URL.HttpClientput(java.lang.String url)Makes a PUT request to the given URLHttpClientwithAuth(Authentication auth)HttpClientwithGetParam(java.lang.String key, java.lang.String value)HttpClientwithGetParams(java.util.Map<java.lang.String,java.lang.String> params)HttpClientwithPostField(java.lang.String key, java.io.Serializable value)HttpClientwithPostFields(java.util.Map<java.lang.String,java.io.Serializable> fields)
-
-
-
Method Detail
-
withAuth
public HttpClient withAuth(Authentication auth)
-
withGetParam
public HttpClient withGetParam(java.lang.String key, java.lang.String value)
-
withGetParams
public HttpClient withGetParams(java.util.Map<java.lang.String,java.lang.String> params)
-
withPostField
public HttpClient withPostField(java.lang.String key, java.io.Serializable value)
-
withPostFields
public HttpClient withPostFields(java.util.Map<java.lang.String,java.io.Serializable> fields)
-
getLastResponse
public java.lang.String getLastResponse()
Returns the response to the last HTTP request as a string.- Returns:
- String or null if the request has not been created
-
getLastResponseCode
public java.lang.Integer getLastResponseCode()
Returns the HTTP status code for the last request.- Returns:
- Integer or null if the request has not been created
-
getLastResponseAsFile
public long getLastResponseAsFile(java.io.File f) throws HelloSignExceptionReturns the last HTTP request body as a file.- Parameters:
f- File that should contain the response- Returns:
- long bytes written
- Throws:
HelloSignException- thrown if there is a problem writing to the file or reading the response stream
-
asJson
public org.json.JSONObject asJson() throws HelloSignExceptionExecutes the request and returns the response as a JSONObject.- Returns:
- JSONObject response
- Throws:
HelloSignException- thrown if there is a problem executing the request
-
asFile
public java.io.File asFile(java.lang.String fileName) throws HelloSignExceptionExecutes the request and returns the response as a File.- Parameters:
fileName- String name of destination file- Returns:
- File response
- Throws:
HelloSignException- thrown if there is a problem executing the request
-
asHttpCode
public int asHttpCode() throws HelloSignExceptionExecutes the request and returns the HTTP response code.- Returns:
- int HTTP response code
- Throws:
HelloSignException- thrown if no request has been performed
-
get
public HttpClient get(java.lang.String url) throws HelloSignException
Initializes a GET request to the given URL.- Parameters:
url- String url- Returns:
- HttpClient
- Throws:
HelloSignException- thrown if the url is invalid
-
post
public HttpClient post(java.lang.String url) throws HelloSignException
Initializes a POST request to the given URL.- Parameters:
url- String url- Returns:
- HttpClient
- Throws:
HelloSignException- thrown if the url is invalid
-
delete
public HttpClient delete(java.lang.String url) throws HelloSignException
Initializes a DELETE request to the given URL.- Parameters:
url- String url- Returns:
- HttpClient
- Throws:
HelloSignException- thrown if the url is invalid
-
put
public HttpClient put(java.lang.String url) throws HelloSignException
Makes a PUT request to the given URL- Parameters:
url- String url- Returns:
- HttpClient
- Throws:
HelloSignException- thrown if the url is invalid
-
options
public HttpClient options(java.lang.String url) throws HelloSignException
Makes an OPTIONS request to the given URL- Parameters:
url- String URL- Returns:
- HttpClient
- Throws:
HelloSignException- thrown if the URL is invalid
-
-