Skip to main content

inform@1.0.0

downloadAttachment(attachmentId, options)
getAttachmentMetadata(attachmentId)
getForm(formId, options)
getForms(options)
getSubmission(formId, submissionId)
getSubmissions(formId, options)

This adaptor exports the following namespaced functions:

http.get(path, options)
http.request(method, path, options)

This adaptor exports the following from common:

combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
merge()
scrubEmojis()
sourceValue()
util
combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
merge()
scrubEmojis()
sourceValue()
util

Functions

downloadAttachment

downloadAttachment(attachmentId, options) ⇒ Operation

Download an attachment in binary or base64 format

ParamTypeDescription
attachmentIdstringId of the attachment to be retrieved.
optionsobjectOptional request options. Supported options are: filename for the specific attachment to be downloaded, and parseAs for either 'stream or 'base64. Defaults to parseAs: stream.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Download an attachment

downloadAttachment('622038', {
filename:
'unicefbih/attachments/download_1.png',
});

Example: Download an attachment in base64 format

downloadAttachment('622038', {
filename:
'unicefbih/attachments/download_1.png',
parseAs: 'base64',
});

getAttachmentMetadata

getAttachmentMetadata(attachmentId) ⇒ Operation

Fetch a single attachment's metadata

ParamTypeDescription
attachmentIdstringId of the attachment to be retrieved.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example

getAttachmentMetadata('621985')

getForm

getForm(formId, options) ⇒ Operation

Get metadata or structural data for a single form

ParamTypeDescription
formIdstringId of the form to be retrieved.
optionsobject
options.structureOnlybooleanIf true, only the form structure is returned in JSON format.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Get a single form

getForm('6225')

Example: Get a single form structure

getForm('6225', {
structureOnly: true,
});

getForms

getForms(options) ⇒ Operation

Fetch all forms

ParamTypeDescription
optionsobjectOptional filter options. Some supported options are: public, tags, page, and page_size.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Get all forms without filter options

getForms()

Example: Get all forms with filter options

getForms({
public: true,
page: 1,
page_size: 5,
});

getSubmission

getSubmission(formId, submissionId) ⇒ Operation

Get a single data submission for a single form

ParamTypeDescription
formIdstringId of the form's submissions to be retrieved.
submissionIdstringId of the submission to be retrieved.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example

getSubmission('6225', '7783155')

getSubmissions

getSubmissions(formId, options) ⇒ Operation

Get submission data of a single form

ParamTypeDescription
formIdstringId of the form's submissions to be retrieved.
optionsobjectOptional filter options. Some supported options are: query, limit, start, page, and page_size.

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Get submissions without filter options

getSubmissions('6225');

Example: Get submissions with filter options

getSubmissions('6225', {
query: `{"_submission_time":{"$gte":"2024-11-05"}}`,
limit: 1,
});

http

These functions belong to the http namespace.

http.get

get(path, options) ⇒ Operation

Make a GET request to Inform

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Get all forms

http.get('forms')

http.request

request(method, path, options) ⇒ Operation

Make a general HTTP request to Inform

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
referencesan array of all previous data objects used in the Job

Example: Get all forms with a query

http.request('GET', 'forms', {
query: {
public: true,
page: 1,
page_size: 5,
},
});

Interfaces

RequestOptions

Options provided to the Inform request

Properties

NameTypeDescription
bodyobject | stringbody data to append to the request. JSON will be converted to a string.
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.