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

93 lines (92 loc) 2.55 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 Units extends RestApi_1.default { /** * @constructor */ constructor(props) { super(props); } getUrl() { throw new Error("Method not implemented."); } /** * Get collection of units. * * @see https://restdocs.e-conomic.com/#units * @param {number} offset * @param {number} limit * @returns {Promise<HttpResponse>} */ get(skipPages = 0, limit = 100) { const requestObj = { method: "get", url: `/units?skippages=${skipPages}&pagesize=${limit}`, }; return this._httpRequest(requestObj); } /** * Get a specific unit. * * @see https://restdocs.e-conomic.com/#get-units * @param {number} unitNumber * @returns {Promise<HttpResponse>} */ getFor(unitNumber) { const requestObj = { method: "get", url: `/units/${unitNumber}`, }; return this._httpRequest(requestObj); } /** * Create a new unit. * * @see https://restdocs.e-conomic.com/#post-units * @param {CreateUnit} unitData * @returns {Promise<HttpResponse<Unit>>} */ createUnit(unitData) { const requestObj = { method: "post", url: `/units`, data: unitData, }; return this._httpRequest(requestObj); } /** * Update an existing unit. * * @see https://restdocs.e-conomic.com/#put-units-unitnumber * @param {number} unitNumber * @param {UpdateUnit} unitData * @returns {Promise<HttpResponse<Supplier>>} */ updateUnit(unitNumber, unitData) { const requestObj = { method: "put", url: `/units/${unitNumber}`, data: unitData, }; return this._httpRequest(requestObj); } /** * Delete an existing unit. * * @see https://restdocs.e-conomic.com/#delete-units-unitnumber * @param {number} unitNumber * @returns {Promise<HttpResponse<void>>} */ deleteUnit(unitNumber) { const requestObj = { method: "delete", url: `/units/${unitNumber}`, }; return this._httpRequest(requestObj); } } exports.default = Units;