UNPKG

@omegabigdata/honoplay-api-helper-node

Version:
91 lines (84 loc) 2.29 kB
'use strict'; const { axiosClient } = require('./Helpers'); /** * @param {object} questionCategoryModel - questionCategory Model for Post * @param {!string} questionCategoryModel.name * @param {function} successCallback * @param {function} errorCallback */ const postQuestionCategory = ( questionCategoryModel, successCallback, errorCallback ) => { if (!questionCategoryModel) { if (errorCallback) { errorCallback('Missing Parameters'); return; } throw new Error('Missing Parameters'); } const uri = `QuestionCategory`; axiosClient .post(uri, questionCategoryModel) .then(success => successCallback(success)) .catch(error => errorCallback(error)); }; /** * @param {object} questionCategoryModel - questionCategory Model for Update * @param {!number} questionCategoryModel.id - questionCategory id * @param {!string} questionCategoryModel.name - questionCategory name * @param {function} successCallback * @param {function} errorCallback */ const putQuestionCategoryModel = ( questionCategoryModel, successCallback, errorCallback ) => { if (!questionCategoryModel) { if (errorCallback) { errorCallback('Missing Parameters'); return; } throw new Error('Missing Parameters'); } const uri = `QuestionCategory`; axiosClient .put(uri, questionCategoryModel) .then(success => successCallback(success)) .catch(error => errorCallback(error)); }; /** * @param {!number} skip * @param {!number} take * @param {function} successCallback * @param {function} errorCallback */ const getQuestionCategories = ( 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 = `QuestionCategory?Skip=${skip}&Take=${take}`; axiosClient .get(uri) .then(success => { successCallback(success); }) .catch(error => { errorCallback(error); }); }; module.exports = { postQuestionCategory, putQuestionCategoryModel, getQuestionCategories };