UNPKG

@omegabigdata/honoplay-api-helper-node

Version:
61 lines (54 loc) 1.51 kB
"use strict"; const { axiosClient } = require("./Helpers"); /** * @param {object} departmentModel - Department Model for Update * @param {!object} departmentModel.departments - departments name * @param {function} successCallback * @param {function} errorCallback */ const postDepartment = (departmentModel, successCallback, errorCallback) => { if (!departmentModel) { if (errorCallback) { errorCallback("Missing Parameters"); return; } throw new Error("Missing Parameters"); } const uri = `Department`; axiosClient .post(uri, departmentModel) .then(success => successCallback(success)) .catch(error => errorCallback(error)); }; /** * @param {!number} skip * @param {!number} take * @param {function} successCallback * @param {function} errorCallback */ const getDepartments = ( skip = null, take = null, successCallback, errorCallback ) => { if (typeof skip !== "number" || typeof take !== "number") { throw new Error("Values must be numeric"); } if (skip <= -1 && take <= -1) { throw new Error("Values must be positive"); } const uri = `Department?Skip=${skip}&Take=${take}`; axiosClient .get(uri) .then(success => { successCallback(success); }) .catch(error => { errorCallback(error); }); }; module.exports = { postDepartment, getDepartments };