Skip to main content

sunbird-rc@1.0.1

del(path, options)
downloadCredential(id, options)
get(path, options)
getCredential(id, options)
issueCredential(body, options)
post(path, body, options)
put(path, body, options)
request(method, path, body, options)

This adaptor exports the following from common:

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

Functions

del

del(path, options) ⇒ Operation

Make a DELETE request

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

del("credentials/did:rcw:123abc");

downloadCredential

downloadCredential(id, options) ⇒ Operation

Download a Verifiable Credential as PDF (base64 encoded)

ParamTypeDescription
idstringThe credential ID to download
optionsobjectOptional request options. Can include templateId which will be added to headers

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

downloadCredential('did:rcw:123abc');

Example

downloadCredential('did:rcw:123abc', { templateId: 'template-001' });

get

get(path, options) ⇒ Operation

Make a GET request

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

get("patients");

getCredential

getCredential(id, options) ⇒ Operation

Get a Verifiable Credential by ID

ParamTypeDescription
idstringThe credential ID to retrieve
optionsobjectOptional request options. Can include templateId which will be added to headers

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

getCredential('did:rcw:123abc');

Example

getCredential('did:rcw:123abc', { templateId: 'template-001' });

issueCredential

issueCredential(body, options) ⇒ Operation

Issue a Verifiable Credential

ParamTypeDescription
bodyobjectCredential issuance payload containing credential, credentialSchemaId, credentialSchemaVersion, and tags
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

issueCredential({
credential: {
'@context': ['https://www.w3.org/2018/credentials/v1'],
type: ['VerifiableCredential', 'ProofOfAcademicEvaluationCredential'],
issuer: 'did:web:example.com:identifier:xxx',
issuanceDate: new Date().toISOString(),
credentialSubject: {
id: 'did:schema:xxx',
name: 'John Doe',
grade: 'A'
}
},
credentialSchemaId: 'did:schema:xxx',
credentialSchemaVersion: '1.0.0',
tags: ['demo', 'education']
});

post

post(path, body, options) ⇒ Operation

Make a POST request

ParamTypeDescription
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

post("patient", { "name": "Bukayo" });

put

put(path, body, options) ⇒ Operation

Make a PUT request

ParamTypeDescription
pathstringPath to resource
bodyobjectObject which will be attached to the PUT body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

put("template/cmhbkgjqo000ems0jvbeayn1h", {
"template": "some handlebars template..."
});

request

request(method, path, body, options) ⇒ Operation

Make a general HTTP request

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example

request("POST", "patient", { "name": "Bukayo" });

Interfaces

HttpState

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
bodyobject | stringbody data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
formobjectPass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.
tlsobjectTLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions