@zohocrm/nodejs-sdk-2.0
Version:
Node JS SDK for Zoho CRM
160 lines (133 loc) • 4.14 kB
JavaScript
const Constants = require("../../../../../../utils/util/constants").MasterModel;
const SDKException = require("../exception/sdk_exception").MasterModel;
class Query{
module;
cvid;
fields;
page;
criteria;
keyModified = new Map();
/**
* The method to get the module
* @returns {String} A String representing the module
*/
getModule() {
return this.module;
}
/**
* The method to set the value to module
* @param {String} module A String representing the module
*/
setModule(module) {
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;
this.keyModified.set("module", 1);
}
/**
* The method to get the cvid
* @returns {String} A String representing the cvid
*/
getCvid() {
return this.cvid;
}
/**
* The method to set the value to cvid
* @param {String} cvid A String representing the cvid
*/
setCvid(cvid) {
if((cvid != null) && (!(Object.prototype.toString.call(cvid) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: cvid EXPECTED TYPE: String", null, null);
}
this.cvid = cvid;
this.keyModified.set("cvid", 1);
}
/**
* The method to get the fields
* @returns {Array} An Array representing the fields
*/
getFields() {
return this.fields;
}
/**
* The method to set the value to fields
* @param {Array} fields An Array representing the fields
*/
setFields(fields) {
if((fields != null) && (!(Object.prototype.toString.call(fields) == "[object Array]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: fields EXPECTED TYPE: Array", null, null);
}
this.fields = fields;
this.keyModified.set("fields", 1);
}
/**
* The method to get the page
* @returns {number} A number representing the page
*/
getPage() {
return this.page;
}
/**
* The method to set the value to page
* @param {number} page A number representing the page
*/
setPage(page) {
if((page != null) && (!(Object.prototype.toString.call(page) == "[object Number]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: page EXPECTED TYPE: number", null, null);
}
this.page = page;
this.keyModified.set("page", 1);
}
/**
* The method to get the criteria
* @returns {Criteria} An instance of Criteria
*/
getCriteria() {
return this.criteria;
}
/**
* The method to set the value to criteria
* @param {Criteria} criteria An instance of Criteria
*/
setCriteria(criteria) {
const Criteria = require("./criteria").MasterModel;
if((criteria != null) && (!(criteria instanceof Criteria))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: criteria EXPECTED TYPE: Criteria", null, null);
}
this.criteria = criteria;
this.keyModified.set("criteria", 1);
}
/**
* The method to check if the user has modified the given key
* @param {String} key A String representing the key
* @returns {number} A number representing the modification
*/
isKeyModified(key) {
if((key != null) && (!(Object.prototype.toString.call(key) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: key EXPECTED TYPE: String", null, null);
}
if(this.keyModified.has(key)) {
return this.keyModified.get(key);
}
return null;
}
/**
* The method to mark the given key as modified
* @param {String} key A String representing the key
* @param {number} modification A number representing the modification
*/
setKeyModified(key, modification) {
if((key != null) && (!(Object.prototype.toString.call(key) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: key EXPECTED TYPE: String", null, null);
}
if((modification != null) && (!(Object.prototype.toString.call(modification) == "[object Number]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: modification EXPECTED TYPE: number", null, null);
}
this.keyModified.set(key, modification);
}
}
module.exports = {
MasterModel : Query,
Query : Query
}