Android Client SDK
com.verivo.akula.http.AKServerAgent Class Reference

The AKHttpServerAgent class connects to the Akula server and always includes the current user's authentication token in the request. More...

Inheritance diagram for com.verivo.akula.http.AKServerAgent:
Inheritance graph

Public Member Functions

 AKServerAgent ()
 Constructor. More...
 
 AKServerAgent (Context context, int sslCertificateResourceID)
 Constructor. More...
 
void delete (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions, AKHttpResponseHandler responseHandler)
 Asynchronously execute a DELETE request with the given URL to be handled by the given response handler. More...
 
HttpResponse deleteSync (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions) throws IOException
 Synchronously execute a DELETE request with the given URL, data, and options. More...
 
void get (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions, AKHttpResponseHandler responseHandler)
 Asynchronously execute a GET request with the specified URL, data, and options to be handled by the given response handler. More...
 
HttpResponse getSync (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions) throws IOException
 Synchronously execute a GET request with the given URL, data, and options. More...
 
void post (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions, AKHttpResponseHandler responseHandler)
 Asynchronously execute a POST request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse postSync (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions) throws IOException
 Synchronously execute a POST request with the given URL, request data, and request options. More...
 
void put (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions, AKHttpResponseHandler responseHandler)
 Asynchronously execute a PUT request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse putSync (String endpoint, AKHttpRequestData requestData, AKHttpRequestOptions requestOptions) throws IOException
 Synchronously execute a PUT request with the given URL, request data, and request options. More...
 
- Public Member Functions inherited from com.verivo.akula.http.AKHttpAgent
 AKHttpAgent ()
 Constructor. More...
 
void delete (String url, AKHttpResponseHandler responseHandler)
 Asynchronously execute a DELETE request with the given URL to be handled by the given response handler. More...
 
void delete (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a DELETE request with the given URL, data, and options to be handled by the given response handler. More...
 
HttpResponse deleteSync (String url) throws IOException
 Synchronously execute a DELETE request with the given URL. More...
 
HttpResponse deleteSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a DELETE request with the given URL, data, and options. More...
 
void get (String url, AKHttpResponseHandler responseHandler)
 Asynchronously execute a GET request to the specified URL. More...
 
void get (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a GET request with the specified URL, data, and options to be handled by the given response handler. More...
 
AKHttpRequestData getAgentRequestData ()
 Get the request data associated with every request made through this agent. More...
 
AKHttpRequestOptions getAgentRequestOptions ()
 Get the request options associated with every request made through this agent. More...
 
HttpResponse getSync (String url) throws IOException
 Synchronously execute a GET request with the given URL. More...
 
HttpResponse getSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a GET request with the given URL, data, and options. More...
 
void post (String url, AKHttpRequestData data, AKHttpResponseHandler responseHandler)
 Asynchronously execute a POST request with the given URL and request data to be handled by the given response handler. More...
 
void post (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a POST request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse postSync (String url, AKHttpRequestData data) throws IOException
 Synchronously execute a POST request with the given URL and request data. More...
 
HttpResponse postSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a POST request with the given URL, request data, and request options. More...
 
void put (String url, AKHttpRequestData data, AKHttpResponseHandler responseHandler)
 Asynchronously execute a PUT request with the given URL and request data to be handled by the given response handler. More...
 
void put (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a PUT request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse putSync (String url, AKHttpRequestData data) throws IOException
 Synchronously execute a PUT request with the given URL and request data. More...
 
HttpResponse putSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a PUT request with the given URL, request data, and request options. More...
 
void send (HttpUriRequest request, AKHttpResponseHandler responseHandler, AKHttpRequestOptions options)
 Asynchronously send a raw HTTP request to be executed by the given client and handled by the given response handler. More...
 
HttpResponse sendSync (HttpUriRequest request, AKHttpRequestOptions options) throws IOException
 Synchronously send a raw HTTP request to be executed by the given client. More...
 

Static Public Attributes

static final String SESSION_KEY = "X-Ak-Session-Id"
 

Static Protected Attributes

static final String ACCEPT_KEY = "Accept"
 
static final String APPLICATION_JSON = "application/json"
 
static final String CONTENT_TYPE_KEY = "Content-Type"
 
static final String DEVICE_KEY = "X-Ak-Device-Id"
 

Additional Inherited Members

- Static Public Member Functions inherited from com.verivo.akula.http.AKHttpAgent
static boolean isSuccessfulHttpResponse (HttpResponse response)
 Determine if this HttpResponse is successful. More...
 
- Protected Member Functions inherited from com.verivo.akula.http.AKHttpAgent
HttpClient getHttpClient (AKHttpRequestOptions options)
 Get the properly setup HTTP client to use to make a request, based on the AKHttpRequestOptions object. More...
 

Detailed Description

The AKHttpServerAgent class connects to the Akula server and always includes the current user's authentication token in the request.

For the request methods of this class, specify the endpoint relative to the base URL of the app scope as set by the AK.init() method. For example, if the base URL of the app scope is http://www.mySampleURL.com/akula/myServerApp, and the specified endpoint is /data/jsonData, the full URL of the endpoint is http://www.mySampleURL.com/akula/myServerApp/data/jsonData.

This class is used by AKModel and AKCollection classes to fetch and save data, as well as most other requests to the Akula server (excluding login).

See Also
Remote Data Access

Constructor & Destructor Documentation

com.verivo.akula.http.AKServerAgent.AKServerAgent ( )

Constructor.

Version
1.0
com.verivo.akula.http.AKServerAgent.AKServerAgent ( Context  context,
int  sslCertificateResourceID 
)

Constructor.

Parameters
contextThe Context of the Android app. Typically you access the context by calling the Context.getApplicationContext() method in the onCreate() handler of the first activity in the app.
sslCertificateResourceID
Version
1.0

Member Function Documentation

void com.verivo.akula.http.AKServerAgent.delete ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a DELETE request with the given URL to be handled by the given response handler.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAn AKHttpRequestData containing the request data.
requestOptionsAn AKHttpRequestOptions object containing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Version
1.0
HttpResponse com.verivo.akula.http.AKServerAgent.deleteSync ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions 
) throws IOException

Synchronously execute a DELETE request with the given URL, data, and options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKServerAgent.get ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a GET request with the specified URL, data, and options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Version
1.0
HttpResponse com.verivo.akula.http.AKServerAgent.getSync ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions 
) throws IOException

Synchronously execute a GET request with the given URL, data, and options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid
Version
1.0
void com.verivo.akula.http.AKServerAgent.post ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a POST request with the given URL, request data, and request options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Version
1.0
HttpResponse com.verivo.akula.http.AKServerAgent.postSync ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions 
) throws IOException

Synchronously execute a POST request with the given URL, request data, and request options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKServerAgent.put ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a PUT request with the given URL, request data, and request options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Version
1.0
HttpResponse com.verivo.akula.http.AKServerAgent.putSync ( String  endpoint,
AKHttpRequestData  requestData,
AKHttpRequestOptions  requestOptions 
) throws IOException

Synchronously execute a PUT request with the given URL, request data, and request options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
endpointThe endpoint that will be appended to the base URL to compose the full URL of the HTTP request. The base URL is retrieved from AK.getBaseURL()
requestDataAKHttpRequestData object representing the request data.
requestOptionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0

Member Data Documentation

final String com.verivo.akula.http.AKServerAgent.ACCEPT_KEY = "Accept"
staticprotected
final String com.verivo.akula.http.AKServerAgent.APPLICATION_JSON = "application/json"
staticprotected
final String com.verivo.akula.http.AKServerAgent.CONTENT_TYPE_KEY = "Content-Type"
staticprotected
final String com.verivo.akula.http.AKServerAgent.DEVICE_KEY = "X-Ak-Device-Id"
staticprotected
final String com.verivo.akula.http.AKServerAgent.SESSION_KEY = "X-Ak-Session-Id"
static