public class ApiClient extends Object
| Constructor and Description |
|---|
ApiClient(Configuration configuration) |
| Modifier and Type | Method and Description |
|---|---|
ApiClient |
addDefaultHeader(String key,
String value)
Add a default header.
|
<T> T |
deserialize(com.sun.jersey.api.client.ClientResponse response,
TypeRef returnType)
Deserialize response body to Java object according to the Content-Type.
|
String |
escapeString(String str)
Escape the given string to be used as URL query value.
|
String |
formatDate(Date date)
Format the given Date object into string.
|
String |
getBasePath() |
DateFormat |
getDateFormat()
Get the date format used to parse/format date parameters.
|
ApiClient |
getDateFormat(DateFormat dateFormat)
Set the date format used to parse/format date parameters.
|
Map<String,com.sun.jersey.api.client.Client> |
getHostMap()
Get the map of API base paths to Jersey Client objects
|
<T> T |
invokeAPI(String path,
String method,
List<Pair> queryParams,
Object body,
Map<String,String> headerParams,
Map<String,Object> formParams,
String accept,
String contentType,
TypeRef returnType)
Invoke API by sending HTTP request with the given options.
|
boolean |
isDebugging()
Check that whether debugging is enabled for this API client.
|
List<Pair> |
parameterToPairs(String collectionFormat,
String name,
Object value) |
String |
parameterToString(Object param)
Format the given parameter object into string.
|
Date |
parseDate(String str)
Parse the given string into Date object.
|
String |
selectHeaderAccept(String[] accepts)
Select the Accept header's value from the given accepts array:
if JSON exists in the given array, use it;
otherwise use all of them (joining into a string)
|
String |
selectHeaderContentType(String[] contentTypes)
Select the Content-Type header's value from the given array:
if JSON exists in the given array, use it;
otherwise use the first one of the array.
|
String |
serialize(Object obj,
String contentType)
Serialize the given Java object into string according the given
Content-Type (only JSON is supported for now).
|
ApiClient |
setBasePath(String basePath) |
ApiClient |
setDebugging(boolean debugging)
Enable/disable debugging for this API client.
|
ApiClient |
setUserAgent(String userAgent)
Set the User-Agent header's value (by adding to the default header map).
|
public ApiClient(Configuration configuration)
public String getBasePath()
public Map<String,com.sun.jersey.api.client.Client> getHostMap()
public ApiClient setUserAgent(String userAgent)
public ApiClient addDefaultHeader(String key, String value)
key - The header's keyvalue - The header's valuepublic boolean isDebugging()
public ApiClient setDebugging(boolean debugging)
debugging - To enable (true) or disable (false) debuggingpublic DateFormat getDateFormat()
public ApiClient getDateFormat(DateFormat dateFormat)
public String parameterToString(Object param)
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value)
public String selectHeaderAccept(String[] accepts)
accepts - The accepts array to select frompublic String selectHeaderContentType(String[] contentTypes)
contentTypes - The Content-Type array to select frompublic String escapeString(String str)
public String serialize(Object obj, String contentType) throws ApiException
ApiExceptionpublic <T> T deserialize(com.sun.jersey.api.client.ClientResponse response,
TypeRef returnType)
throws ApiException
ApiExceptionpublic <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String,String> headerParams, Map<String,Object> formParams, String accept, String contentType, TypeRef returnType) throws ApiException
path - The sub-path of the HTTP URLmethod - The request method, one of "GET", "POST", "PUT", and "DELETE"queryParams - The query parametersbody - The request body objectheaderParams - The header parametersformParams - The form parametersaccept - The request's Accept headercontentType - The request's Content-Type headerreturnType - The return type into which to deserialize the responseApiExceptionCopyright © 2016. All Rights Reserved.