UNPKG

zcrmsdk

Version:
153 lines (137 loc) 5.87 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_GET; handlerInstance.categoryMethod = 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_POST; handlerInstance.categoryMethod = Constants.REQUEST_CATEGORY_CREATE; handlerInstance.contentType = "application/json"; handlerInstance.request = request; handlerInstance.mandatoryChecker = 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_PUT; handlerInstance.categoryMethod = Constants.REQUEST_CATEGORY_UPDATE; handlerInstance.contentType = "application/json"; handlerInstance.request = request; handlerInstance.mandatoryChecker = 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_DELETE; handlerInstance.categoryMethod = Constants.REQUEST_METHOD_DELETE; handlerInstance.param = 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_GET; handlerInstance.categoryMethod = 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.apiPath = apiPath; handlerInstance.httpMethod = Constants.REQUEST_METHOD_DELETE; handlerInstance.categoryMethod = 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 }