UNPKG

@phasesdk/api-client-for-economic

Version:

e-conomic REST API Library for Node.js is a powerful tool designed to simplify integration with the e-conomic platform for developers building Node.js applications. With this library, developers can effortlessly leverage the full functionality of the e-co

104 lines (103 loc) 3.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const RestApi_1 = __importDefault(require("../RestApi")); class CustomerGroups extends RestApi_1.default { /** * @constructor */ constructor(props) { super(props); } getUrl() { throw new Error("Method not implemented."); } /** * Get collection of customer groups. * @see https://restdocs.e-conomic.com/#get-customer-groups * * @param {number} offset * @param {number} limit * @returns {Promise<HttpResponse>} */ get(skipPages = 0, limit = 100) { const requestObj = { method: "get", url: `/customer-groups?skippages=${skipPages}&pagesize=${limit}`, }; return this._httpRequest(requestObj); } /** * This endpoint allows you to fetch a collection of all customers in a specific customer group. * * @see https://restdocs.e-conomic.com/#get-customer-groups-customergroupnumber-customers * @param {number} customerGroupNumber * @returns {Promise<HttpResponse>} * */ getCustomerGroupCustomers(customerGroupNumber, skipPages = 0, limit = 100) { const requestObj = { method: "get", url: `/customer-groups/${customerGroupNumber}/customers?skippages=${skipPages}&pagesize=${limit}`, }; return this._httpRequest(requestObj); } /** * Create a new customer group * @see https://restdocs.e-conomic.com/#post-customer-groups * @param {CreateCustomerGroup} customerGroup * @returns {Promise<HttpResponse<CustomerGroup>>} */ createCustomerGroup(customerGroup) { const requestObj = { method: "post", url: `/customer-groups`, data: customerGroup, }; return this._httpRequest(requestObj); } /** * Get a specific customer group * @see https://restdocs.e-conomic.com/#get-customer-groups-customergroupnumber * @param {number} customerGroupNumber * @returns {Promise<HttpResponse<CustomerGroup>>} */ getFor(customerGroupNumber) { const requestObj = { method: "GET", url: `/customer-groups/${customerGroupNumber}`, }; return this._httpRequest(requestObj); } /** * Update an existing customer group * @see https://restdocs.e-conomic.com/#put-customer-groups-customergroupnumber * @param {number} customerGroupNumber * @param {Partial<CreateCustomerGroup>} customerGroup * @returns {Promise<HttpResponse<CustomerGroup>>} */ updateCustomerGroup(customerGroupNumber, customerGroup) { const requestObj = { method: "put", url: `/customer-groups/${customerGroupNumber}`, data: customerGroup, }; return this._httpRequest(requestObj); } /** * Delete an existing customer group * @see https://restdocs.e-conomic.com/#delete-customer-groups-customergroupnumber * @param {number} customerGroupNumber * @returns {Promise<HttpResponse<void>>} */ deleteCustomerGroup(customerGroupNumber) { const requestObj = { method: "delete", url: `/customer-groups/${customerGroupNumber}`, }; return this._httpRequest(requestObj); } } exports.default = CustomerGroups;