kobotoolbox@3.0.1
This adaptor exports the following namespaced functions:
This adaptor exports the following from common:
- alterState()
- cursor()
- dataPath()
- dataValue()
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- http
- lastReferenceValue()
- merge()
- sourceValue()
Functions
getDeploymentInfo
getDeploymentInfo(formId) ⇒ Operation
Get deployment information for a specific form. Calls /api/v2/assets/<id>/deployment/
.
Param | Type | Description |
---|---|---|
formId | string | Form Id to get the deployment information |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an object containing deployment information |
Example
getDeploymentInfo('aXecHjmbATuF6iGFmvBLBX');
getForms
getForms() ⇒ Operation
Make a request to fetch all survey forms accessible to the authorized user. Calls /api/v2/assets/?asset_type=survey
.
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an array of form objects |
Example
getForms();
getSubmissions
getSubmissions(formId, [options]) ⇒ Operation
Get submissions for a specific form. Calls /api/v2/assets/<formId>/data/
.
Param | Type | Default | Description |
---|---|---|---|
formId | string | Form Id to get the specific submissions | |
[options] | object | {} | Optional query params for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an array of submission objects |
Example: Get all submissions for a specific form
getSubmissions('aXecHjmbATuF6iGFmvBLBX');
Example: Get form submissions with a query
getSubmissions('aXecHjmbATuF6iGFmvBLBX', { query: { _submission_time:{ $gte: "2022-06-12T21:54:20" } } });
http
These functions belong to the http namespace.
http.get
get(path, [options]) ⇒ operation
Make a GET request to any KoboToolbox endpoint.
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
[options] | RequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body). Responses will be returned in JSON format |
references | An array of all previous data objects used in the Job |
Example: GET assets resource
http.get(
"/assets/",
)
http.post
post(path, data, [options]) ⇒ operation
Make a POST request to a KoboToolbox endpoint
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
data | any | the body data in JSON format | |
[options] | RequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body). Responses will be returned in JSON format |
references | An array of all previous data objects used in the Job |
Example: Create an asset resource
http.post(
'/assets/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);
http.put
put(path, data, [options]) ⇒ operation
Make a PUT request to a KoboToolbox endpoint
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
data | any | the body data in JSON format | |
[options] | RequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body). Responses will be returned in JSON format |
references | An array of all previous data objects used in the Job |
Example: Update an asset resource
http.put(
'assets/a4jAWzoa8SZWzZGhx84sB5/deployment/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);
Interfaces
KoboToolboxHttpState
State object
Properties
Name | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body). Responses will be returned in JSON format |
references | An array of all previous data objects used in the Job |
RequestOptions
Options object
Properties
Name | Type | Default | Description |
---|---|---|---|
query | object | An object of query parameters to be encoded into the URL | |
headers | object | An object of all request headers | |
[parseAs] | string | "'json'" | The response format to parse (e.g., 'json', 'text', or 'stream') |
RequestOptions
Options object
Properties
Name | Type | Default | Description |
---|---|---|---|
query | object | An object of query parameters to be encoded into the URL | |
headers | object | An object of all request headers | |
[parseAs] | string | "'json'" | The response format to parse (e.g., 'json', 'text', or 'stream') |