communicator

Methods

(static) authenticate(survey) → {Promise}

Source:
Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:
Type
Promise

(static) getAuthHeader(url, credentialsopt) → {Promise}

Source:

Generates an Auhorization header that can be used to inject into piped requests (e.g. submissions).

Parameters:
Name Type Attributes Description
url string
credentials Object <optional>
Returns:

a promise that resolves with an auth header

Type
Promise

(static) getFormListUrl(server, idopt, customParamopt) → {string}

Source:

getFormListUrl

Parameters:
Name Type Attributes Description
server string
id string <optional>

Form id.

customParam string <optional>

custom query parameter

Returns:

url

Type
string

(static) getManifest(survey) → {Promise}

Source:

Obtains the XForm manifest

Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:
Type
Promise

(static) getMaxSize(survey) → {Promise.<string>}

Source:

Checks the maximum acceptable submission size the server accepts

Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:

promise resolving with max size stringified number

Type
Promise.<string>

(static) getSubmissionUrl(server) → {string}

Source:
Parameters:
Name Type Description
server string
Returns:

url

Type
string

(static) getUpdatedRequestOptions(options)

Source:

Updates request options.

Parameters:
Name Type Description
options object

(static) getXForm(survey) → {Promise}

Source:

Gets XForm from url

Parameters:
Name Type Description
survey *

survey object

Returns:
Type
Promise

(static) getXFormInfo(survey) → {Promise}

Source:

Gets form info

Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:
Type
Promise

(inner) _findFormAddInfo(formListXml, survey) → {Promise}

Source:

Finds the relevant form in an OpenRosa XML formList

Parameters:
Name Type Description
formListXml string

OpenRosa XML formList

survey module:survey-model~SurveyObject
Returns:

promise

Type
Promise

(inner) _request(options) → {Promise}

Source:

Sends a request to an OpenRosa server

Parameters:
Name Type Description
options Object

request options object

Returns:

promise

Type
Promise

(inner) _simplifyFormObj(formObj) → {object}

Source:

Convert arrays property values to strings, knowing that each xml node only occurs once in each xform node in /formList

Parameters:
Name Type Description
formObj *
Returns:

a simplified form object

Type
object

(inner) _xmlToJson(xml) → {Promise.<(string|Error)>}

Source:

transform XML to JSON for easier processing

Parameters:
Name Type Description
xml string

XML string

Returns:

a promise that resolves with JSON

Type
Promise.<(string|Error)>