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
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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)
| Param | Type | Description |
|---|---|---|
| id | string | The credential ID to download |
| options | object | Optional request options. Can include templateId which will be added to headers |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example
get("patients");
getCredential
getCredential(id, options) ⇒ Operation
Get a Verifiable Credential by ID
| Param | Type | Description |
|---|---|---|
| id | string | The credential ID to retrieve |
| options | object | Optional request options. Can include templateId which will be added to headers |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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
| Param | Type | Description |
|---|---|---|
| body | object | Credential issuance payload containing credential, credentialSchemaId, credentialSchemaVersion, and tags |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| body | object | Object which will be attached to the POST body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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
| Param | Type | Description |
|---|---|---|
| path | string | Path to resource |
| body | object | Object which will be attached to the PUT body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an 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
| Param | Type | Description |
|---|---|---|
| method | string | HTTP method to use |
| path | string | Path to resource |
| body | object | Object which will be attached to the POST body |
| options | RequestOptions | Optional request options |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
Example
request("POST", "patient", { "name": "Bukayo" });
Interfaces
HttpState
State object
Properties
| Name | Description |
|---|---|
| data | the parsed response body |
| response | the response from the HTTP server, including headers, statusCode, body, etc |
| references | an array of all previous data objects used in the Job |
RequestOptions
Options provided to the HTTP request
Properties
| Name | Type | Description |
|---|---|---|
| body | object | string | body 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). |
| errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code. |
| form | object | Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body. |
| query | object | An object of query parameters to be encoded into the URL. |
| headers | object | An object of headers to append to the request. |
| parseAs | string | Parse the response body as json, text or stream. By default will use the response headers. |
| timeout | number | Request timeout in ms. Default: 300 seconds. |
| tls | object | TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions |