UNPKG

@zohocrm/nodejs-sdk-2.0

Version:
173 lines (155 loc) 7.33 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 NotificationOperations{ /** * The method to enable notifications * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async enableNotifications(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/actions/watch"); 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 get notification details * @param {ParameterMap} paramInstance An instance of ParameterMap * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async getNotificationDetails(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/actions/watch"); 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 notifications * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async updateNotifications(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/actions/watch"); 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 update notification * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async updateNotification(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/actions/watch"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_PATCH); 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 disable notifications * @param {ParameterMap} paramInstance An instance of ParameterMap * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async disableNotifications(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/actions/watch"); 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 disable notification * @param {BodyWrapper} request An instance of BodyWrapper * @returns {APIResponse} An instance of APIResponse * @throws {SDKException} */ async disableNotification(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/actions/watch"); handlerInstance.setAPIPath(apiPath); handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_PATCH); 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"); } } class GetNotificationDetailsParam{ static PAGE = new Param("page", "com.zoho.crm.api.Notification.GetNotificationDetailsParam"); static PER_PAGE = new Param("per_page", "com.zoho.crm.api.Notification.GetNotificationDetailsParam"); static CHANNEL_ID = new Param("channel_id", "com.zoho.crm.api.Notification.GetNotificationDetailsParam"); static MODULE = new Param("module", "com.zoho.crm.api.Notification.GetNotificationDetailsParam"); } class DisableNotificationsParam{ static CHANNEL_IDS = new Param("channel_ids", "com.zoho.crm.api.Notification.DisableNotificationsParam"); } module.exports = { GetNotificationDetailsParam : GetNotificationDetailsParam, DisableNotificationsParam : DisableNotificationsParam, MasterModel : NotificationOperations, NotificationOperations : NotificationOperations }