public class ApiInvoker extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ApiInvoker.NestedContent |
| Constructor and Description |
|---|
ApiInvoker() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDefaultHeader(String key,
String value)
Allows adding default headers to requests.
|
static Object |
deserialize(String json,
String containerType,
Class cls,
ApiInvoker.NestedContent nestedContent)
Deserialize a received response String.
|
String |
escapeString(String str)
String escaping.
|
static ApiInvoker |
getInstance()
Allows retrieving an instance of
ApiInvoker. |
Object |
invokeAPI(String host,
String path,
String method,
Map<String,String> queryParams,
Object body,
Map<String,String> headerParams,
String contentType)
Serialize an Object.
|
static String |
serialize(Object obj)
Serialize an Object.
|
public static ApiInvoker getInstance()
ApiInvoker.ApiInvoker object.public void addDefaultHeader(String key, String value)
key - the keyvalue - the valuepublic String escapeString(String str)
str - the String to escapepublic static Object deserialize(String json, String containerType, Class cls, ApiInvoker.NestedContent nestedContent) throws ApiException
json - the received json StringcontainerType - the containerTypecls - the class of the objectnestedContent - contains the name of the Pojo, contained in a List of Lists. null if no nested content is present.APIException - if an exception occurs during deserializationApiExceptionpublic static String serialize(Object obj) throws ApiException
obj - the Object to serializeAPIException - if an exception occurs during serializationApiExceptionpublic Object invokeAPI(String host, String path, String method, Map<String,String> queryParams, Object body, Map<String,String> headerParams, String contentType) throws ApiException
host - the targeted hostpath - the targeted rest endpointmethod - the HTTP methodqueryParams - the query parametersbody - the obligatory body of a postheaderParams - the HTTP header parameterscontentType - the content typeAPIException - if an exception occurs during querying of the API.ApiExceptionCopyright © 2015. All rights reserved.