Skip to main content

zata@1.0.0

get(path, options)
post(path, options)
put(path, options)
request(method, path, 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

get

get(path, options) ⇒ Operation

Make a GET request to the Zata API

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsAdditional 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 all product types

get('data/product-type')

Example: Test Zata API connectivity

get('test')

post

post(path, options) ⇒ Operation

Make a POST request to the Zata API

ParamType
pathstring
optionsRequestOptions

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: Create a sale transaction

post('transaction/sale', {
body: {
"purchaseCode": "43034",
"paymentMethodID": 1,
"customerID": 1,
"transactionDate": "2024-01-01",
"note": "string",
"customerTIN": "123456789",
"customerName": "John Doe",
"customerPhone": "123456789",
"items": [
{
"productID": 1,
"units": 12.5,
"unitPrice": 1000,
"discountRate": 100,
"batchNumber": "string"
}
]
},
header: {
companyId: 1,
branchId: 1
}
})

Example: Create a company

post('company', {
body: {
name: "Zata Point Global Service",
address: "No 1, Zata Point Street, Zata Point",
phone: "08012345678",
email: "sample@sample.com",
tin: "123456789"
}
})

put

put(path, options) ⇒ Operation

Make a PUT request to the Zata API

ParamType
pathstring
optionsRequestOptions

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: Reduce product quantity

put('product/reduce-quantity/{productId}', {
body: {
quantity: 10,
description: 'reason for reducing quantity',
batchNumber: 'Batch Number'
},
header: {
companyId: 1,
branchId: 1
}
})

request

request(method, path, options) ⇒ Operation

Make a general HTTP request

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
optionsRequestOptionsAdditional 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: Create a new sale transaction

request("POST", "transaction/sale",
{
body: {
"purchaseCode": "43034",
"paymentMethodID": 1,
"customerID": 1,
"transactionDate": "2024-01-01",
"note": "string",
"customerTIN": "123456789",
"customerName": "John Doe",
"customerPhone": "12345678910",
"items": [
{
"productID": 1,
"units": 12.5,
"unitPrice": 1000,
"discountRate": 100,
"batchNumber": "string"
}
]
},
headers: {
companyId: 1,
branchId: 1
}
});

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