public class HttpClientService extends Object implements ClientService
| Constructor and Description |
|---|
HttpClientService(org.apache.http.client.HttpClient httpClient,
ContentHelper contentHelper,
LoggerFacade logger) |
| Modifier and Type | Method and Description |
|---|---|
Optional<org.apache.http.client.methods.HttpGet> |
buildGetAcceptionApplicatonJson(String endpoint,
String authToken)
builds a HttpGet request object for the given endpoint using authToken as basic authentication header.
|
Optional<org.apache.http.client.methods.HttpGet> |
buildGetRequestUsingFormUrlEncoding(String endpoint,
String authToken)
Builds a HttpGet request object for the endpoint given by endpoint using authToken as basic authentication header
|
Optional<org.apache.http.client.methods.HttpGet> |
buildGetRequestUsingFormUrlEncoding(String endpoint,
String authToken,
org.apache.http.NameValuePair... params)
builds a HttpGet request object for the given endpoint using authToken as basic authentication header and params
as additional URL key/value parameters
|
Optional<org.apache.http.client.methods.HttpPost> |
buildPostRequestUsingApplicationJson(String endpoint,
org.apache.http.HttpEntity body)
builds a HttpPost request object for the given endpoint containing the provided body content
body will be posted using Content-Type of application/json
|
Optional<org.apache.http.client.methods.HttpPost> |
buildPostRequestUsingFormUrlEncoding(String endpoint,
String authToken,
org.apache.http.NameValuePair... params)
builds a HttpPost request object for the given endpoint containing the provided body content
body will be posted using Content-Type as application/x-www-form-urlencoded
|
Optional<org.apache.http.HttpEntity> |
executeEntityRequest(org.apache.http.client.methods.HttpRequestBase request)
executes the provided HttpRequestBase returning the result as a HttpEntity
|
Optional<org.json.JSONObject> |
executeJsonRequest(org.apache.http.client.methods.HttpRequestBase request)
executes the provided HttpRequestBase returning the result as a JSONObject
|
public HttpClientService(org.apache.http.client.HttpClient httpClient,
ContentHelper contentHelper,
LoggerFacade logger)
public Optional<org.json.JSONObject> executeJsonRequest(org.apache.http.client.methods.HttpRequestBase request)
executeJsonRequest in interface ClientServicerequest - the request to send/executepublic Optional<org.apache.http.HttpEntity> executeEntityRequest(org.apache.http.client.methods.HttpRequestBase request)
request - the request to send/executepublic Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding(String endpoint, String authToken)
buildGetRequestUsingFormUrlEncoding in interface ClientServiceendpoint - endpoint to perform get request onauthToken - authorization token for basic authenticationIllegalArgumentException - when either endpoint or authToken are null or emptypublic Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding(String endpoint, String authToken, org.apache.http.NameValuePair... params)
buildGetRequestUsingFormUrlEncoding in interface ClientServiceendpoint - endpoint to perform get request onauthToken - authorization token for basic authenticationparams - name/value pairs encoded and added to endpointIllegalArgumentException - when either endpoint or authToken are null or emptypublic Optional<org.apache.http.client.methods.HttpGet> buildGetAcceptionApplicatonJson(String endpoint, String authToken)
buildGetAcceptionApplicatonJson in interface ClientServiceendpoint - endpoint to perform get request onauthToken - authorization token for basic authenticationIllegalArgumentException - when either endpoint or authToken are null or emptypublic Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingApplicationJson(String endpoint, org.apache.http.HttpEntity body)
buildPostRequestUsingApplicationJson in interface ClientServiceendpoint - endpoint to perform post request onbody - JSON body to be sent with the requestpublic Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingFormUrlEncoding(String endpoint, String authToken, org.apache.http.NameValuePair... params)
buildPostRequestUsingFormUrlEncoding in interface ClientServiceendpoint - endpoint to perform post request onauthToken - authorization token for basic authenticationparams - name/value pairs sent as the entity of the requestCopyright © 2016–2021. All rights reserved.