public abstract class WatsonService extends Object
| Constructor and Description |
|---|
WatsonService(String name)
Instantiates a new Watson service.
|
| Modifier and Type | Method and Description |
|---|---|
protected com.squareup.okhttp.OkHttpClient |
configureHttpClient()
Configures the HTTP client.
|
protected com.squareup.okhttp.Response |
execute(com.squareup.okhttp.Request request)
Execute the HTTP request.
|
protected <T extends GenericModel> |
executeRequest(com.squareup.okhttp.Request request,
Class<T> returnType)
Executes the HTTP Request, reads and parses the HTTP Response.
|
protected void |
executeWithoutResponse(com.squareup.okhttp.Request request)
Execute the HTTP request and discard the response.
|
protected String |
getApiKey()
Gets the API key.
|
String |
getEndPoint()
Gets the API end point.
|
String |
getName()
Gets the name.
|
String |
getToken()
Gets an authorization token that can be use to authorize API calls.
|
void |
setApiKey(String apiKey)
Sets the API key.
|
protected void |
setAuthentication(com.squareup.okhttp.Request.Builder builder)
Sets the authentication.
|
void |
setDefaultHeaders(Map<String,String> headers)
Set the default headers to be used on every HTTP request.
|
void |
setEndPoint(String endPoint)
Sets the end point.
|
void |
setUsernameAndPassword(String username,
String password)
Sets the username and password.
|
String |
toString() |
protected static final String VERSION
public WatsonService(String name)
name - the service nameprotected com.squareup.okhttp.OkHttpClient configureHttpClient()
protected com.squareup.okhttp.Response execute(com.squareup.okhttp.Request request)
request - the HTTP requestprotected <T extends GenericModel> T executeRequest(com.squareup.okhttp.Request request, Class<T> returnType)
T - the POJO class that represents the responserequest - the requestreturnType - the return typeprotected void executeWithoutResponse(com.squareup.okhttp.Request request)
request - the requestprotected String getApiKey()
public String getEndPoint()
public String getToken()
public String getName()
public void setApiKey(String apiKey)
apiKey - the new API keyprotected void setAuthentication(com.squareup.okhttp.Request.Builder builder)
builder - the new authenticationpublic void setEndPoint(String endPoint)
endPoint - the new end pointpublic void setUsernameAndPassword(String username, String password)
username - the usernamepassword - the passwordpublic void setDefaultHeaders(Map<String,String> headers)
headers - name value pairs of headersCopyright © 2015–2016. All rights reserved.