Class APIRunner
- java.lang.Object
-
- com.blackberry.workspaces.sdk.api.APIRunner
-
public class APIRunner extends Object
Provides configuration and low level methods for using the BlackBerry Workspaces Android SDK.
-
-
Constructor Summary
Constructors Constructor Description APIRunner(IConnection connection, ISessionCallbacks sessionCallbacks)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
sendAPIRequest(Class<T> returnType, APIHttpMethod method, String command, String input, String contentType, String headerToReturn, String version, Map<String,Object> requestFormParameters, Map<String,Object> requestQueryStringParameters)
Lower level method for sending API requests to the server.<T> T
sendAPIUploadRequest(Class<T> returnType, APIHttpMethod method, String command, String json, File data, String headerToReturn, String version, Long start, Map<String,Object> requestFormParameters)
Lower level method for uploading documents to the server.<T> T
sendAPIUploadRequest(Class<T> returnType, APIHttpMethod method, String command, String json, InputStream fileStream, FormDataContentDisposition fileInfo, String headerToReturn, String version, Long start, Map<String,Object> requestFormParameters)
Lower level method for uploading documents to the server.
-
-
-
Constructor Detail
-
APIRunner
public APIRunner(IConnection connection, ISessionCallbacks sessionCallbacks)
-
-
Method Detail
-
sendAPIUploadRequest
public <T> T sendAPIUploadRequest(Class<T> returnType, APIHttpMethod method, String command, String json, InputStream fileStream, FormDataContentDisposition fileInfo, String headerToReturn, String version, Long start, Map<String,Object> requestFormParameters)
Lower level method for uploading documents to the server.- Type Parameters:
T
- A class that is either a JSON class from this SDK, a class that implements InputStream, a String or void.- Parameters:
returnType
- The class that will be returned by the method. For most requests this would be a JSON class. For a request that expects to retrieve a value from a headerString
.class would be specified.method
- The HTTP method to be used in making the request. For example, GET versus POST.command
- The path of the API requests. For example: "/documents/{guid}/upload".json
- The request body used when performing a POST request.fileStream
- AnInputStream
object referring to the file to be uploaded.fileInfo
- AFormDataContentDisposition
instance containing information about the file to be uploaded.authToken
- The authorization token.headerToReturn
- Specifies the header value from the server response to be returned by the method. For most API calls this parameter would be null. When defined as a non-null value, the value from the first instance of the header in the server response will be returned by the method as a String.version
- Defines the API version for the command/API being executed. For example: "3.0".start
- A Long indicating the offset of a file chunk being uploaded. When uploading a file in its entirety the parameter should be null. Using this parameter it is possible to upload a file in chunks. A separate call to sendAPIUploadRequest would made for each chunk with the start parameter being set to the total size of the chunks that preceded the current request.requestFormParameters
- Defines the set of parameters for an API request that are sent as form data in the request body.- Returns:
- An instance of the class specified in returnType containing the response from the server.
-
sendAPIUploadRequest
public <T> T sendAPIUploadRequest(Class<T> returnType, APIHttpMethod method, String command, String json, File data, String headerToReturn, String version, Long start, Map<String,Object> requestFormParameters)
Lower level method for uploading documents to the server.- Type Parameters:
T
- A class that is either a JSON class from this SDK, a class that implements InputStream, a String or void.- Parameters:
returnType
- The class that will be returned by the method. For most requests this would be a JSON class. For a request that expects to retrieve a value from a headerString
.class would be specified.method
- The HTTP method to be used in making the request. For example, GET versus POST.command
- The path of the API requests. For example: "/documents/{guid}/upload".json
- The request body used when performing a POST request.data
- AFile
object referring to the file to be uploaded.authToken
- The authorization token.headerToReturn
- Specifies the header value from the server response to be returned by the method. For most API calls this parameter would be null. When defined as a non-null value, the value from the first instance of the header in the server response will be returned by the method as a String.version
- Defines the API version for the command/API being executed. For example: "3.0".start
- A Long indicating the offset of a file chunk being uploaded. When uploading a file in its entirety the parameter should be null. Using this parameter it is possible to upload a file in chunks. A separate call to sendAPIUploadRequest would made for each chunk with the start parameter being set to the total size of the chunks that preceded the current request.requestFormParameters
- Defines the set of parameters for an API request that are sent as form data in the request body.- Returns:
- An instance of the class specified in returnType containing the response from the server.
-
sendAPIRequest
public <T> T sendAPIRequest(Class<T> returnType, APIHttpMethod method, String command, String input, String contentType, String headerToReturn, String version, Map<String,Object> requestFormParameters, Map<String,Object> requestQueryStringParameters)
Lower level method for sending API requests to the server.- Type Parameters:
T
- A class that is either a JSON class from this SDK, a class that implements InputStream, a String or void.- Parameters:
returnType
- The class that will be returned by the method. For most requests this would be a JSON class. For a request that expects to retrieve a value from a headerString
.class would be specified.method
- The HTTP method to be used in making the request. For example, GET versus POST.command
- The path of the API requests. For example: "/authentication/parameters".input
- The request body used when performing a POST request.contentType
- The content type of the request data. For example: "application/json".authToken
- The authorization token.headerToReturn
- Specifies the header value from the server response to be returned by the method. For most API calls this parameter would be null. When defined as a non-null value, the value from the first instance of the header in the server response will be returned by the method as a String.version
- Defines the API version for the command/API being executed. For example: "3.0".requestFormParameters
- Defines the set of parameters for an API request that are sent as form data in the request body.requestQueryStringParameters
- Defines the set of parameters for an API request that are sent as URL parameters.- Returns:
- An instance of the class specified in returnType containing the response from the server.
-
-