UNPKG

@zohocrm/nodejs-sdk-2.0

Version:
78 lines (65 loc) 2.72 kB
const Param = require("../../../../../../routes/param").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 LayoutsOperations{ module; /** * Creates an instance of LayoutsOperations with the given parameters * @param {String} module A String representing the module */ constructor(module=null){ if((module != null) && (!(Object.prototype.toString.call(module) == "[object String]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: module EXPECTED TYPE: String", null, null); } this.module = module; } /** * The method to get layouts * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getLayouts() { var handlerInstance = new CommonAPIHandler(); var apiPath = ''; apiPath = apiPath.concat("/crm/v2/settings/layouts"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ); await handlerInstance.addParam(new Param("module", "com.zoho.crm.api.Layouts.GetLayoutsParam"), this.module); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } /** * The method to get layout * @param {BigInt} id A BigInt representing the id * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getLayout(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/settings/layouts/"); apiPath = apiPath.concat(id.toString()); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET); handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ); await handlerInstance.addParam(new Param("module", "com.zoho.crm.api.Layouts.GetLayoutParam"), this.module); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } } class GetLayoutsParam{ } class GetLayoutParam{ } module.exports = { MasterModel : LayoutsOperations, LayoutsOperations : LayoutsOperations, GetLayoutsParam : GetLayoutsParam, GetLayoutParam : GetLayoutParam }