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

101 lines (100 loc) 3.34 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const OpenApi_1 = __importDefault(require("../../OpenApi")); const VERSION = "v22.0.0"; class Employees extends OpenApi_1.default { getVersion() { return this.version ? this.version : VERSION; } setVersion(version) { this.version = version; return this; } getUrlSegment() { return "api/"; } constructor(authToken) { super(authToken); this.version = ""; } /** * Use this endpoint to retrieve all Employees in bulk. Max number of items returned in a single call is 1000 * * @see https://apis.e-conomic.com/#Projects..tag/Employees/operation/GetAllEmployees * * @returns {Promise<HttpResponse>} */ getAll() { const requestObj = { method: "get", url: `${this.getUrlSegment()}${this.getVersion()}/employees`, }; return this._httpRequest(requestObj); } /** * This endpoint is to load a collection of Employees with pagination. * * @see https://apis.e-conomic.com/#Projects..tag/Employees/operation/GetPageOfEmployees * * @param {number} offset * @param {number} limit * @returns {Promise<HttpResponse>} */ get(offset = 0, limit = 100) { const requestObj = { method: "get", url: `${this.getUrlSegment()}${this.getVersion()}/employees/paged?skippages=${offset}&pagesize=${limit}`, }; return this._httpRequest(requestObj); } /** * This endpoint is to load a collection of Employees under an Employee Group with pagination. * * @param {number} groupNumber * @param {number} offset * @param {number} limit * @returns {Promise<HttpResponse>} */ getEmployeesByEmployeeGroup(groupNumber, skipPages = 0, limit = 100) { const requestObj = { method: "get", url: `${this.getUrlSegment()}${this.getVersion()}/employees/paged?skippages=${skipPages}&pagesize=${limit}&filter=groupNumber$eq:${groupNumber}`, }; return this._httpRequest(requestObj); } /** * This endpoint is to load a single Employee by id/number. * * @see https://apis.e-conomic.com/#Projects..tag/Employees/operation/GetEmployeeById * * @param {number} number * @returns {Promise<HttpResponse>} */ getFor(number) { const requestObj = { method: "get", url: `${this.getUrlSegment()}${this.getVersion()}/employees/${number}`, }; return this._httpRequest(requestObj); } /** * This endpoint is to to create a single Employee. * * @see https://apis.e-conomic.com/#Projects..tag/Employees/operation/CreateEmployee * * @param {CreateEmployee} createEmployee * @returns {Promise<HttpResponse>} */ create(createEmployee) { const requestObj = { method: "post", url: `${this.getUrlSegment()}${this.getVersion()}/employees`, data: createEmployee, }; return this._httpRequest(requestObj); } } exports.default = Employees;