new ApiClient(window, baseServerUrl)
Create a new ApiClient
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
window |
Object | representing the context in which we are executing - provides reference to window.jQuery.ajax() | ||
baseServerUrl |
String | identifies the Roundware server to receive API requests | ||
options.fetch |
Boolean |
<optional> |
fetch | for testing purposes, you can inject the fetch mechanism to use for making network requests |
- Source:
Methods
get(path, options)
Make a GET request to the Roundware server
Parameters:
Name | Type | Description |
---|---|---|
path |
String | the path for your API request, such as "/streams" |
options |
Object | see the "send" method |
- Source:
- See:
-
- {send}
patch(path, options)
Make a PATCH request to the Roundware server
Parameters:
Name | Type | Description |
---|---|---|
path |
String | the path for your API request, such as "/streams" |
options |
Object | see the "send" method |
- Source:
- See:
-
- {send}
post(path, options)
Make a POST request to the Roundware server
Parameters:
Name | Type | Description |
---|---|---|
path |
String | the path for your API request, such as "/streams" |
options |
Object | see the "send" method |
- Source:
- See:
-
- {send}
send(path, data, options) → {Promise}
Transmit an Ajax request to the Roundware API. Note that the Roundware Server expects paths to end with a trailing slash: /sessions/ instead of /sessions
Parameters:
Name | Type | Description |
---|---|---|
path |
string | identifies the endpoint to receive the request |
data |
object | the payload to send |
options |
object | any additional options to add to the Ajax request |
- Source:
- To Do:
-
- might be a good place to implement exponential retry of certain types of errors
Returns:
- will resolve or reject depending on the status of the request
- Type
- Promise
setAuthToken(authToken)
Set the authorization token to use as the header for future API requests. Most Roundware API calls require an auth token to be set
Parameters:
Name | Type | Description |
---|---|---|
authToken |
String | characters to use in the authorization header |
- Source: