UNPKG

@zohocrm/nodejs-sdk-2.0

Version:
85 lines (72 loc) 3.19 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 FieldsOperations{ module; /** * Creates an instance of FieldsOperations 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 fields * @param {ParameterMap} paramInstance An instance of ParameterMap * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getFields(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/settings/fields"); 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.Fields.GetFieldsParam"), this.module); handlerInstance.setParam(paramInstance); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } /** * The method to get field * @param {BigInt} id A BigInt representing the id * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getField(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/fields/"); 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.Fields.GetFieldParam"), this.module); let ResponseHandler = require.resolve("./response_handler"); return handlerInstance.apiCall(ResponseHandler, "application/json"); } } class GetFieldsParam{ static TYPE = new Param("type", "com.zoho.crm.api.Fields.GetFieldsParam"); } class GetFieldParam{ } module.exports = { GetFieldsParam : GetFieldsParam, GetFieldParam : GetFieldParam, MasterModel : FieldsOperations, FieldsOperations : FieldsOperations }