
Push Updates
Some data in Mammut I/O can be received via push updates. Currently this includes:
Stocks
Prices
Products
Categories
Updates are sent as soon as changes are available for the relevant data.
Push Update Mechanism
Mammut I/O sends push updates in JSON format via HTTP POST. A typical update looks like this:
{"entities": [ "mammut_stock" ],"changes": [{"action": "update","entityId": "1010-01220-0001-114","data": {"sku": "1010-01220-0001-114","ean": "7613062354047","quantity": 4,"inventoryType": "store","inventoryId": "213","modifiedAt": "2020-09-10T12:34:00Z","nextIntake": null}},{ /* more changes */ }]}
The structure of the data inside"data": {} depends on the type of data that is being sent.
Note: some I/O APIs send localized data. For push updates this means that every change contains data for each locale. Example:
{"entities": [ "mammut_category" ],"changes": [{"action": "update","entityId": "mammut-1121030","data": {"zh_CN": {"code": "mammut-1121030", "catalog": "mammut", "description": "T 恤衫和衬衫", "parent": "mammut-11210", "position": 557},"de_DE": {"code": "mammut-1121030", "catalog": "mammut", "description": "T-Shirts & Hemden", "parent": "mammut-11210", "position": 557},"en_GB": {"code": "mammut-1121030", "catalog": "mammut", "description": "T-Shirts & Shirts", "parent": "mammut-11210", "position": 557},/* ... */}}}
Complete models for each data type can be found here:
Stocks (mammut_stock): see Stocks model in the I/O Stocks API.
Prices (mammut_price): see Prices model in the I/O Prices API.
Products (mammut_product): see LocalizedProduct model in the I/O Products API.
Categories (mammut_category): see LocalizedCategory model in the I/O Products API.
Subscribe to Push Updates
To receive Mammut I/O push updates you need to provide an URL which can be registered in Mammut I/O. Contact your Mammut I/O administrator for assistance.
Data Transfer
HTTP Requests sending data updates are using Transfer-Encoding: chunked. Make sure to handle the request accordingly.
Example for NodeJS
let body = [];request.on('data', (chunk) => { body.push(chunk); }).on('end', () => { body = Buffer.concat(body).toString(); });
Read more at https://nodejs.org/es/docs/guides/anatomy-of-an-http-transaction/#request-body