Package com.hyperwallet.clientsdk.util
Class Request
- java.lang.Object
-
- com.hyperwallet.clientsdk.util.Message<Request>
-
- com.hyperwallet.clientsdk.util.Request
-
- Direct Known Subclasses:
MultipartRequest
public class Request extends Message<Request>
This class represents an HTTP Request message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequest.DefaultPasswordAuthenticator
-
Field Summary
Fields Modifier and Type Field Description protected HttpURLConnectionconnection
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestaddQueryParameter(String name, String value)Adds a Query Parameter to a list.protected voidbuildHeaders()A private method that loops through the headers Map, putting them on the Request or Response object.protected voidbuildQueryString()A private method that loops through the query parameter Map, building a String to be appended to the URL.cc.protea.util.http.ResponsedeleteResource()Issues a DELETE to the server.cc.protea.util.http.BinaryResponsegetBinaryResource()Issues a GET to the server.cc.protea.util.http.ResponsegetResource()Issues a GET to the server.cc.protea.util.http.ResponseheadResource()cc.protea.util.http.ResponseoptionsResource()cc.protea.util.http.ResponsepostResource()Issues a POST to the server.cc.protea.util.http.ResponseputResource()Issues a PUT to the server.protected cc.protea.util.http.ResponsereadResponse()A private method that handles reading the Responses from the server.RequestremoveQueryParameter(String name)Removes the specified Query Parameter.RequestsetBodyUrlEncoded(Map<String,String> map)cc.protea.util.http.ResponsetraceResource()-
Methods inherited from class com.hyperwallet.clientsdk.util.Message
addHeader, getBody, getHeader, getHeaders, getHeaders, removeHeader, setBody, setHeaders
-
-
-
-
Field Detail
-
connection
protected final HttpURLConnection connection
-
-
Constructor Detail
-
Request
public Request(String url, int connectionTimeout, int readTimeout, Proxy proxy, String proxyUsername, String proxyPassword)
The Constructor takes the url as a String, a proxy as a Proxy, and proxy credentials as a String.- Parameters:
url- The url parameter does not need the query string parameters if they are going to be supplied via calls toaddQueryParameter(String, String). You can, however, supply the query parameters in the URL if you wish.connectionTimeout- A specified timeout value, in milliseconds, to establish communications link to the resource byURLConnection.readTimeout- A specified timeout, in milliseconds, for reading data from an established connection to the resource byURLConnection.proxy- The Connection's Proxy valueproxyUsername- The Proxy usernameproxyPassword- The Proxy password
-
-
Method Detail
-
addQueryParameter
public Request addQueryParameter(String name, String value)
Adds a Query Parameter to a list. The list is converted to a String and appended to the URL when the Request is submitted.- Parameters:
name- The Query Parameter's namevalue- The Query Parameter's value- Returns:
- this Request, to support chained method calls
-
removeQueryParameter
public Request removeQueryParameter(String name)
Removes the specified Query Parameter.- Parameters:
name- The name of the Query Parameter to remove- Returns:
- this Request, to support chained method calls
-
getResource
public cc.protea.util.http.Response getResource() throws IOExceptionIssues a GET to the server.- Returns:
- The
Responsefrom the server - Throws:
IOException- aIOException
-
getBinaryResource
public cc.protea.util.http.BinaryResponse getBinaryResource() throws IOExceptionIssues a GET to the server.- Returns:
- The
Responsefrom the server - Throws:
IOException- aIOException
-
putResource
public cc.protea.util.http.Response putResource() throws IOExceptionIssues a PUT to the server.- Returns:
- The
Responsefrom the server - Throws:
IOException- aIOException
-
headResource
public cc.protea.util.http.Response headResource() throws IOException- Throws:
IOException
-
optionsResource
public cc.protea.util.http.Response optionsResource() throws IOException- Throws:
IOException
-
traceResource
public cc.protea.util.http.Response traceResource() throws IOException- Throws:
IOException
-
postResource
public cc.protea.util.http.Response postResource() throws IOExceptionIssues a POST to the server.- Returns:
- The
Responsefrom the server - Throws:
IOException- aIOException
-
deleteResource
public cc.protea.util.http.Response deleteResource() throws IOExceptionIssues a DELETE to the server.- Returns:
- The
Responsefrom the server - Throws:
IOException- aIOException
-
readResponse
protected cc.protea.util.http.Response readResponse() throws IOExceptionA private method that handles reading the Responses from the server.- Returns:
- a
Responsefrom the server. - Throws:
IOException- aIOException
-
buildQueryString
protected void buildQueryString() throws MalformedURLExceptionA private method that loops through the query parameter Map, building a String to be appended to the URL.- Throws:
MalformedURLException- aMalformedURLException
-
buildHeaders
protected void buildHeaders()
A private method that loops through the headers Map, putting them on the Request or Response object.
-
-