Modifier and Type | Class and Description |
---|---|
static class |
API.REQUEST_TYPE
Valid methods
|
Modifier and Type | Field and Description |
---|---|
protected IAPIHttpClient |
client
The http client to use
|
protected org.apache.http.protocol.HttpContext |
context
Client context
|
protected boolean |
lockHost
Set this to true to autofill the hostname for any uri's.
|
protected long |
maxDownloadSize
Max download size
|
Constructor and Description |
---|
API(IAPIHttpClient client)
Create a new API instance
|
API(IAPIHttpClient client,
boolean lockHost)
Create a new API instance
|
API(IAPIHttpClient client,
boolean lockHost,
long maxDownloadSize)
Create a new API instance
|
Modifier and Type | Method and Description |
---|---|
protected IAPIResponse |
executeRequest(org.apache.http.client.methods.HttpUriRequest hr)
Execute a HttpRequest
|
IAPIResponse |
get(String url)
Perform a get-based request to some endpoint
|
IAPIResponse |
get(String url,
Map<String,String> headers)
Perform a get-based request to some endpoint
|
IAPIResponse |
post(String url,
InputStream payload,
long contentLength,
org.apache.http.entity.ContentType contentType,
Map<String,String> headers)
Perform a post-based request to some endpoint
|
IAPIResponse |
post(String url,
List<org.apache.http.NameValuePair> formData)
Perform a post-based request to some endpoint
|
IAPIResponse |
post(String url,
List<org.apache.http.NameValuePair> formData,
Map<String,PostFile> files)
Perform a post-based request to some endpoint
|
IAPIResponse |
post(String url,
List<org.apache.http.NameValuePair> formData,
Map<String,PostFile> files,
Map<String,String> headers)
Perform a post-based request to some endpoint
|
IAPIResponse |
post(String url,
PostFile file,
Map<String,String> headers)
Perform a post-based request to some endpoint
|
IAPIResponse |
post(String url,
String payload)
Send arbitrary post data to some endpoint
|
IAPIResponse |
post(String url,
String payload,
Map<String,String> headers)
Send arbitrary post data to some endpoint
|
IAPIResponse |
put(String url,
InputStream payload,
long contentLength,
org.apache.http.entity.ContentType contentType,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
IAPIResponse |
put(String url,
PostFile file,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
IAPIResponse |
put(String url,
String payload)
Perform a put-based request to some endpoint
|
IAPIResponse |
put(String url,
String payload,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
protected final org.apache.http.protocol.HttpContext context
protected final long maxDownloadSize
protected final IAPIHttpClient client
protected final boolean lockHost
public API(IAPIHttpClient client)
client
- The HttpClient instancepublic API(IAPIHttpClient client, boolean lockHost)
client
- The HttpClient instancelockHost
- If you want to auto set the host for uri'spublic API(IAPIHttpClient client, boolean lockHost, long maxDownloadSize)
client
- the HttpClient instancelockHost
- If you want to auto set the host for uri'smaxDownloadSize
- The maximum download size for any responsepublic IAPIResponse get(String url) throws APIException
get
in interface IApi
url
- The URLAPIException
- If something goes wrongpublic IAPIResponse get(String url, Map<String,String> headers) throws APIException
get
in interface IApi
url
- The URLheaders
- Extra headers to sendAPIException
- If something goes wrongpublic IAPIResponse post(String url, List<org.apache.http.NameValuePair> formData) throws APIException
post
in interface IApi
url
- The URLformData
- Key/Value pairs to sendAPIException
- If something goes wrongpublic IAPIResponse post(String url, List<org.apache.http.NameValuePair> formData, Map<String,PostFile> files) throws APIException
post
in interface IApi
url
- The URLformData
- Key/Value pairs to sendfiles
- Key/File files to sendAPIException
- If something goes wrongpublic IAPIResponse post(String url, List<org.apache.http.NameValuePair> formData, Map<String,PostFile> files, Map<String,String> headers) throws APIException
post
in interface IApi
url
- The URLformData
- Key/Value pairs to sendfiles
- Key/File files to sendheaders
- Extra headers to sendAPIException
- If something goes wrongpublic IAPIResponse post(String url, String payload) throws APIException
post
in interface IApi
url
- URLpayload
- Data to sendAPIException
- if something goes wrongpublic IAPIResponse post(String url, String payload, Map<String,String> headers) throws APIException
post
in interface IApi
url
- URLpayload
- Data to sendheaders
- Extra headers to sendAPIException
- if something goes wrongpublic IAPIResponse post(String url, InputStream payload, long contentLength, org.apache.http.entity.ContentType contentType, Map<String,String> headers) throws APIException
post
in interface IApi
url
- URLpayload
- Payload to sendheaders
- additional headers to sendAPIException
public IAPIResponse post(String url, PostFile file, Map<String,String> headers) throws APIException
post
in interface IApi
url
- URLfile
- A file to postheaders
- additional headers to sendAPIException
public IAPIResponse put(String url, String payload) throws APIException
put
in interface IApi
url
- URLpayload
- Payload to sendAPIException
public IAPIResponse put(String url, String payload, Map<String,String> headers) throws APIException
put
in interface IApi
url
- URLpayload
- Payload to sendheaders
- additional headers to sendAPIException
public IAPIResponse put(String url, InputStream payload, long contentLength, org.apache.http.entity.ContentType contentType, Map<String,String> headers) throws APIException
put
in interface IApi
url
- URLpayload
- Payload to sendcontentLength
- the length of the payloadcontentType
- the type of data in payloadheaders
- additional headers to sendAPIException
public IAPIResponse put(String url, PostFile file, Map<String,String> headers) throws APIException
put
in interface IApi
url
- URLfile
- file to sendheaders
- additional headersAPIException
protected IAPIResponse executeRequest(org.apache.http.client.methods.HttpUriRequest hr) throws APIException
hr
- requestAPIException
- If the request failedCopyright © 2017. All rights reserved.