zata@1.0.0
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
Param | Type | Description |
---|---|---|
path | string | Path to resource |
options | RequestOptions | Additional 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 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
Param | Type |
---|---|
path | string |
options | RequestOptions |
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: 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
Param | Type |
---|---|
path | string |
options | RequestOptions |
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: 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
Param | Type | Description |
---|---|---|
method | string | HTTP method to use |
path | string | Path to resource |
options | RequestOptions | Additional 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: 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
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 |