@zohocrm/nodejs-sdk-2.0
Version:
Node JS SDK for Zoho CRM
51 lines (45 loc) • 1.88 kB
JavaScript
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 RolesOperations{
/**
* The method to get roles
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getRoles() {
var handlerInstance = new CommonAPIHandler();
var apiPath = '';
apiPath = apiPath.concat("/crm/v2/settings/roles");
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
/**
* The method to get role
* @param {BigInt} id A BigInt representing the id
* @returns {APIResponse} An instance of APIResponse
* @throws {SDKException}
*/
async getRole(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/roles/");
apiPath = apiPath.concat(id.toString());
handlerInstance.setAPIPath(apiPath);
handlerInstance.setHttpMethod(Constants.REQUEST_METHOD_GET);
handlerInstance.setCategoryMethod(Constants.REQUEST_CATEGORY_READ);
let ResponseHandler = require.resolve("./response_handler");
return handlerInstance.apiCall(ResponseHandler, "application/json");
}
}
module.exports = {
MasterModel : RolesOperations,
RolesOperations : RolesOperations
}