omnisend-node-sdk
Version:
🔹 Typesafe Omnisend API SDK for Node.js
61 lines (60 loc) • 4.18 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Batches = void 0;
const http_client_1 = require("../http-client");
class Batches {
constructor(http) {
/**
* @description ## Examples ## **Batch post contacts** ```json { "method": "POST", "endpoint": "contacts", "items": [ { "identifiers": [ { "type":"email", "id": "vanessa.kensington@example.com", "channels": { "email": { "status": "subscribed", "statusDate": "2019-05-30T14:11:12Z" } } } ] }, { "identifiers": [ { "type":"email", "id": "vanessa@example.com", "channels": { "email": { "status": "subscribed", "statusDate": "2019-05-30T14:11:12Z" } } } ], "firstName":"Vanessa" } ] } ``` **Batch post events (trigger event)** ```json { "method": "POST", "endpoint": "events", "eventID":"5a3a57235ff78f4307346af5", "items": [ { "email": "test@example.com", "phone": "+12025550142", "fields": { "size": "M", "bust": 100, "waterproof": true, "packageWeight": 12.2, "manualUrl": "http://www.example.com/uploads/prodManual.pdf", "validUntil": "2017-05-30T14:11:12Z" } }, { "email": "test2@example.com", "fields": { "size": "M", "bust": 100, "waterproof": true, "packageWeight": 12.2, "manualUrl": "http://www.example.com/uploads/prodManual.pdf", "validUntil": "2017-05-30T14:11:12Z" } } ] } ``` **Batch put products** ```json { "endpoint": "products", "method": "PUT", "items": [ { "productID": "123", "currency": "EUR", "title": "Book1", "productUrl": "https://mystore.com/book1", "variants": [ { "variantID": "abc", "title": "Book1", "price": 5 } ], "imageUrl": "https://mystore.com/book1.jpg" }, { "productID": "456", "currency": "EUR", "title": "Book2", "productUrl": "https://mystore.com/book2", "variants": [ { "variantID": "cde", "title": "Book2", "price": 23 } ], "imageUrl": "https://mystore.com/book2.jpg" } ] } ```
*
* @tags Batches
* @name PostBatches
* @summary Create batch
* @request POST:/batches
* @secure
*/
this.postBatches = (data, params = {}) => this.http.request(Object.assign({ path: `/batches`, method: "POST", body: data, secure: true, type: http_client_1.ContentType.Json, format: "json" }, params));
/**
* @description Get list of `batches`. List of batches is available for `7 days`. Query parameter `endpoint` is required. You can list batches with endpoint for which API Key has permission.
*
* @tags Batches
* @name GetBatches
* @summary List batches
* @request GET:/batches
* @secure
*/
this.getBatches = (query, params = {}) => this.http.request(Object.assign({ path: `/batches`, method: "GET", query, secure: true, format: "json" }, params));
/**
* @description Get `batch` info. Batch will be removed after `7 days`. You can get `batch` info, only if API Key has permission to view batch endpoint.
*
* @tags Batches
* @name GetBatch
* @summary Get batch
* @request GET:/batches/{batchID}
* @secure
*/
this.getBatch = (batchId, params = {}) => this.http.request(Object.assign({ path: `/batches/${batchId}`, method: "GET", secure: true, format: "json" }, params));
/**
* No description
*
* @tags Batches
* @name GetBatchBatchIdItems
* @summary List batch items
* @request GET:/batches/{batchID}/items
* @secure
*/
this.getBatchBatchIdItems = (batchId, params = {}) => this.http.request(Object.assign({ path: `/batches/${batchId}/items`, method: "GET", secure: true, format: "json" }, params));
/**
* No description
*
* @tags Batches
* @name GetBatchBatchIdItemsItemId
* @summary Get batch item
* @request GET:/batches/{batchID}/items/{itemID}
* @secure
*/
this.getBatchBatchIdItemsItemId = (batchId, itemId, params = {}) => this.http.request(Object.assign({ path: `/batches/${batchId}/items/${itemId}`, method: "GET", secure: true, format: "json" }, params));
this.http = http;
}
}
exports.Batches = Batches;