@zohocrm/nodejs-sdk-2.0
Version:
Node JS SDK for Zoho CRM
230 lines (204 loc) • 9.33 kB
JavaScript
const Header = require("../../../../../../routes/header").MasterModel;
const HeaderMap = require("../../../../../../routes/header_map").MasterModel;
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 NotesOperations{
/**
* The method to get notes
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @param {HeaderMap} headerInstance An instance of HeaderMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getNotes(paramInstance=null, headerInstance=null) {
if((paramInstance != null) && (!(paramInstance instanceof ParameterMap))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: paramInstance EXPECTED TYPE: ParameterMap", null, null);
}
if((headerInstance != null) && (!(headerInstance instanceof HeaderMap))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: headerInstance EXPECTED TYPE: HeaderMap", null, null);
}
var handlerInstance = new CommonAPIHandler();
var apiPath = '';
apiPath = apiPath.concat("/crm/v2/Notes");
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
handlerInstance.setParam(paramInstance);
handlerInstance.setHeader(headerInstance);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to create notes
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async createNotes(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/Notes");
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 notes
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async updateNotes(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/Notes");
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 notes
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async deleteNotes(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/Notes");
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 note
* @param {BigInt} id A BigInt representing the id
* @param {ParameterMap} paramInstance An instance of ParameterMap
* @param {HeaderMap} headerInstance An instance of HeaderMap
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getNote(id, paramInstance=null, headerInstance=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);
}
if((headerInstance != null) && (!(headerInstance instanceof HeaderMap))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: headerInstance EXPECTED TYPE: HeaderMap", null, null);
}
var handlerInstance = new CommonAPIHandler();
var apiPath = '';
apiPath = apiPath.concat("/crm/v2/Notes/");
apiPath = apiPath.concat(id.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
handlerInstance.setParam(paramInstance);
handlerInstance.setHeader(headerInstance);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to update note
* @param {BigInt} id A BigInt representing the id
* @param {BodyWrapper} request An instance of BodyWrapper
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async updateNote(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/Notes/");
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 note
* @param {BigInt} id A BigInt representing the id
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async deleteNote(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/Notes/");
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");
}
}
class GetNotesParam{
static PAGE = new Param("page", "com.zoho.crm.api.Notes.GetNotesParam");
static PER_PAGE = new Param("per_page", "com.zoho.crm.api.Notes.GetNotesParam");
static FIELDS = new Param("fields", "com.zoho.crm.api.Notes.GetNotesParam");
}
class GetNotesHeader{
static IF_MODIFIED_SINCE = new Header("If-Modified-Since", "com.zoho.crm.api.Notes.GetNotesHeader");
}
class DeleteNotesParam{
static IDS = new Param("ids", "com.zoho.crm.api.Notes.DeleteNotesParam");
}
class GetNoteParam{
static FIELDS = new Param("fields", "com.zoho.crm.api.Notes.GetNoteParam");
}
class GetNoteHeader{
static IF_MODIFIED_SINCE = new Header("If-Modified-Since", "com.zoho.crm.api.Notes.GetNoteHeader");
}
module.exports = {
GetNotesHeader : GetNotesHeader,
GetNoteParam : GetNoteParam,
GetNoteHeader : GetNoteHeader,
GetNotesParam : GetNotesParam,
MasterModel : NotesOperations,
NotesOperations : NotesOperations,
DeleteNotesParam : DeleteNotesParam
}