UNPKG

@zohocrm/nodejs-sdk-2.0

Version:
153 lines (137 loc) 5.92 kB
const Param = require("../../../../../../routes/param").MasterModel; const ParameterMap = require("../../../../../../routes/parameter_map").MasterModel; const APIResponse = require("../../../../../../routes/controllers/api_response").MasterModel; const CommonAPIHandler = require("../../../../../../routes/middlewares/common_api_handler").MasterModel; const Constants = require("../../../../../../utils/util/constants").MasterModel; const SDKException = require("../exception/sdk_exception").MasterModel; class TaxesOperations{ /** * The method to get taxes * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getTaxes() { var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } /** * The method to create taxes * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async createTaxes(request) { const BodyWrapper = require("./body_wrapper").MasterModel; if((request != null) && (!(request instanceof BodyWrapper))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: request EXPECTED TYPE: BodyWrapper", null, null); } var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_POST); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_CREATE); handlerInstance.setContentType("application/json"); handlerInstance.setRequest(request); handlerInstance.setMandatoryChecker(true); let ActionHandler = require.resolve("./action_handler"); return handlerInstance.apiCall(ActionHandler, "application/json"); } /** * The method to update taxes * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async updateTaxes(request) { const BodyWrapper = require("./body_wrapper").MasterModel; if((request != null) && (!(request instanceof BodyWrapper))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: request EXPECTED TYPE: BodyWrapper", null, null); } var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_PUT); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_UPDATE); handlerInstance.setContentType("application/json"); handlerInstance.setRequest(request); handlerInstance.setMandatoryChecker(true); let ActionHandler = require.resolve("./action_handler"); return handlerInstance.apiCall(ActionHandler, "application/json"); } /** * The method to delete taxes * @param {ParameterMap} paramInstance An instance of ParameterMap * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async deleteTaxes(paramInstance=null) { if((paramInstance != null) && (!(paramInstance instanceof ParameterMap))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: paramInstance EXPECTED TYPE: ParameterMap", null, null); } var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_DELETE); handlerInstance.setCategoryMethod(Constants.REQUEST_METHOD_DELETE); handlerInstance.setParam(paramInstance); let ActionHandler = require.resolve("./action_handler"); return handlerInstance.apiCall(ActionHandler, "application/json"); } /** * The method to get tax * @param {BigInt} id A BigInt representing the id * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getTax(id) { if((!(Object.prototype.toString.call(id) == "[object BigInt]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: id EXPECTED TYPE: BigInt", null, null); } var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes/"); apiPath = apiPath.concat(id.toString()); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } /** * The method to delete tax * @param {BigInt} id A BigInt representing the id * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async deleteTax(id) { if((!(Object.prototype.toString.call(id) == "[object BigInt]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: id EXPECTED TYPE: BigInt", null, null); } var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/org/taxes/"); apiPath = apiPath.concat(id.toString()); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_DELETE); handlerInstance.setCategoryMethod(Constants.REQUEST_METHOD_DELETE); let ActionHandler = require.resolve("./action_handler"); return handlerInstance.apiCall(ActionHandler, "application/json"); } } class DeleteTaxesParam{ static IDS = new Param("ids", "com.zoho.crm.api.Taxes.DeleteTaxesParam"); } module.exports = { MasterModel : TaxesOperations, TaxesOperations : TaxesOperations, DeleteTaxesParam : DeleteTaxesParam }