@zohocrm/nodejs-sdk-2.0
Version:
Node JS SDK for Zoho CRM
266 lines (238 loc) • 11 kB
JavaScript
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 VariablesOperations{
/**
* The method to get variables
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getVariables(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/variables");
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
handlerInstance.setParam(paramInstance);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to create variables
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async createVariables(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/settings/variables");
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 variables
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async updateVariables(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/settings/variables");
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 variables
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async deleteVariables(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/variables");
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 variable by id
* @param {BigInt} id A BigInt representing the id
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getVariableById(id, paramInstance=null) {
if((!(Object.prototype.toString.call(id) == "[object BigInt]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: id EXPECTED TYPE: BigInt", null, 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/variables/");
apiPath = apiPath.concat(id.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
handlerInstance.setParam(paramInstance);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to update variable by id
* @param {BigInt} id A BigInt representing the id
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async updateVariableById(id, request) {
const BodyWrapper = require("./body_wrapper").MasterModel;
if((!(Object.prototype.toString.call(id) == "[object BigInt]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: id EXPECTED TYPE: BigInt", null, null);
}
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/settings/variables/");
apiPath = apiPath.concat(id.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_PUT);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_UPDATE);
handlerInstance.setContentType("application/json");
handlerInstance.setRequest(request);
let ActionHandler = require.resolve("./action_handler");
return handlerInstance.apiCall(ActionHandler, "application/json");
}
/**
* The method to delete variable
* @param {BigInt} id A BigInt representing the id
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async deleteVariable(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/variables/");
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");
}
/**
* The method to get variable for api name
* @param {String} apiName A String representing the apiName
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getVariableForAPIName(apiName, paramInstance=null) {
if((!(Object.prototype.toString.call(apiName) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: apiName EXPECTED TYPE: String", null, 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/variables/");
apiPath = apiPath.concat(apiName.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
handlerInstance.setParam(paramInstance);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to update variable by api name
* @param {String} apiName A String representing the apiName
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async updateVariableByAPIName(apiName, request) {
const BodyWrapper = require("./body_wrapper").MasterModel;
if((!(Object.prototype.toString.call(apiName) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: apiName EXPECTED TYPE: String", null, null);
}
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/settings/variables/");
apiPath = apiPath.concat(apiName.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_PUT);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_UPDATE);
handlerInstance.setContentType("application/json");
handlerInstance.setRequest(request);
let ActionHandler = require.resolve("./action_handler");
return handlerInstance.apiCall(ActionHandler, "application/json");
}
}
class GetVariablesParam{
static GROUP = new Param("group", "com.zoho.crm.api.Variables.GetVariablesParam");
}
class DeleteVariablesParam{
static IDS = new Param("ids", "com.zoho.crm.api.Variables.DeleteVariablesParam");
}
class GetVariableByIDParam{
static GROUP = new Param("group", "com.zoho.crm.api.Variables.GetVariableByIDParam");
}
class GetVariableForAPINameParam{
static GROUP = new Param("group", "com.zoho.crm.api.Variables.GetVariableForAPINameParam");
}
module.exports = {
MasterModel : VariablesOperations,
VariablesOperations : VariablesOperations,
GetVariableByIDParam : GetVariableByIDParam,
DeleteVariablesParam : DeleteVariablesParam,
GetVariableForAPINameParam : GetVariableForAPINameParam,
GetVariablesParam : GetVariablesParam
}