Skip to content

Commit

Permalink
Merge pull request #2 from zoho/beta
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
tharunpargi authored Aug 6, 2024
2 parents 7209f85 + 8404431 commit 6571e96
Show file tree
Hide file tree
Showing 2,013 changed files with 216,164 additions and 12 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ License

## Latest Version

- [2.0.0](/versions/2.0.0/README.md)

- Handled Error Structure in MassDeleteTags API.

- [1.0.0](/versions/1.0.0/README.md)

- NodeJS SDK upgraded to support v7 APIs.
Expand All @@ -48,7 +52,7 @@ For older versions, please [refer](https://github.com/zoho/zohocrm-nodejs-sdk-7.
## Including the SDK in your project
You can include the SDK to your project using:

For including the latest [version](https://github.com/zoho/zohocrm-nodejs-sdk-7.0/releases/tag/1.0.0) using npm
For including the latest [version](https://github.com/zoho/zohocrm-nodejs-sdk-7.0/releases/tag/2.0.0) using npm

- Install **Node** from [nodejs.org](https://nodejs.org/en/download/) (if not installed).

Expand Down Expand Up @@ -106,4 +110,4 @@ For example, if you generate the tokens for your Sandbox environment in the CN d
> - For **Mass Convert API**, you will need to provide the **ZohoCRM.settings.fields.ALL** scope along with the **ZohoCRM.mass_convert.leads.CREATE** and **ZohoCRM.mass_convert.leads.READ** scope while generating the OAuthtoken. Otherwise, the system returns the **OAUTH-SCOPE-MISMATCH** error.

---
For more details, kindly refer [here](/versions/1.0.0/README.md).
For more details, kindly refer [here](/versions/2.0.0/README.md).
2 changes: 1 addition & 1 deletion lib/config/json_details.json

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions lib/core/com/zoho/crm/api/mass_delete_tags/error_detail1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {SDKException} from "../exception/sdk_exception.js";
import {Constants} from "../../../../../../utils/util/constants.js";

class ErrorDetail1{

apiName;
jsonPath;
keyModified = new Map();
/**
* The method to get the apiName
* @returns {String} A String representing the apiName
*/
getAPIName() {
return this.apiName;

}

/**
* The method to set the value to apiName
* @param {String} apiName A String representing the apiName
*/
setAPIName(apiName) {
if((apiName != null) && (!(Object.prototype.toString.call(apiName) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: apiName EXPECTED TYPE: String", null, null);
}
this.apiName = apiName;
this.keyModified.set("api_name", 1);

}

/**
* The method to get the jsonPath
* @returns {String} A String representing the jsonPath
*/
getJsonPath() {
return this.jsonPath;

}

/**
* The method to set the value to jsonPath
* @param {String} jsonPath A String representing the jsonPath
*/
setJsonPath(jsonPath) {
if((jsonPath != null) && (!(Object.prototype.toString.call(jsonPath) == "[object String]"))) {
throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: jsonPath EXPECTED TYPE: String", null, null);
}
this.jsonPath = jsonPath;
this.keyModified.set("json_path", 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);

}

}
export {
ErrorDetail1 as MasterModel,
ErrorDetail1 as ErrorDetail1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { APIException } from "./api_exception.js";
export { Tag } from "./tag.js";
export { ErrorDetail1 } from "./error_detail1.js";
export * as StatusActionResponse from "./status_action_response.js";
export { StatusResponseWrapper } from "./status_response_wrapper.js";
export { Module } from "./module.js";
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Constants {
static REQUEST_METHOD_DELETE = "DELETE";
static REQUEST_METHOD_GET = "GET";
static ZOHO_SDK = "X-ZOHO-SDK";
static SDK_VERSION = "1.0.0";
static SDK_VERSION = "2.0.0";
static MYSQL_HOST = "localhost";
static MYSQL_DATABASE_NAME = "zohooauth";
static MYSQL_USER_NAME = "root";
Expand Down Expand Up @@ -238,7 +238,7 @@ class Constants {
static API_CALL_EXCEPTION = "Exception in current API call execution : ";
static CORE = "core";
static SAVE_TOKEN_ERROR = "Exception in saving tokens";
static SET_TO_CONTENT_TYPE = ["/crm/bulk/v7/read", "/crm/bulk/v7/write", "/crm/v7/__zia_org_enrichment", "crm/v7/__zia_people_enrichment"];
static SET_TO_CONTENT_TYPE = ["/crm/bulk/v7/read", "/crm/bulk/v7/write", "/crm/v7/__zia_org_enrichment", "crm/v7/__zia_people_enrichment", "/crm/v7/settings/audit_log_export"];
static CONTENT_TYPE_HEADER = "Content-Type";
static EVENTS_MODULE_PARAMS = ["startDateTime", "endDateTime"];
static FILE_BODY_WRAPPER = "file_body_wrapper";
Expand Down
12 changes: 6 additions & 6 deletions lib/utils/util/datatype_converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class DatatypeConverter {
for (let data of obj) {
if (data instanceof Date) {
if (data.getHours() == 0 && data.getMinutes() == 0 && data.getSeconds() == 0) {
list.push(this.postConvert(data, Constants.DATE_NAMESPACE));
list.push(this.postConvert(data, Constants.DATE_NAMESPACE.toLowerCase()));
}
else {
list.push(this.postConvert(data, Constants.DATETIME_NAMESPACE));
list.push(this.postConvert(data, Constants.DATETIME_NAMESPACE.toLowerCase()));
}
}
else if (data instanceof Map) {
Expand All @@ -98,10 +98,10 @@ class DatatypeConverter {
}
else if (value instanceof Date) {
if (value.getHours() == 0 && value.getMinutes() == 0 && value.getSeconds() == 0) {
requestObject[key] = this.postConvert(value, Constants.DATE_NAMESPACE);
requestObject[key] = this.postConvert(value, Constants.DATE_NAMESPACE.toLowerCase());
}
else {
requestObject[key] = this.postConvert(value, Constants.DATETIME_NAMESPACE);
requestObject[key] = this.postConvert(value, Constants.DATETIME_NAMESPACE.toLowerCase());
}
}
else if (value instanceof Map) {
Expand All @@ -115,10 +115,10 @@ class DatatypeConverter {
}
else if (obj instanceof Date) {
if (obj.getHours() == 0 && obj.getMinutes() == 0 && obj.getSeconds() == 0) {
return this.postConvert(obj, Constants.DATE_NAMESPACE);
return this.postConvert(obj, Constants.DATE_NAMESPACE.toLowerCase());
}
else {
return this.postConvert(obj, Constants.DATETIME_NAMESPACE);
return this.postConvert(obj, Constants.DATETIME_NAMESPACE.toLowerCase());
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zohocrm/nodejs-sdk-7.0",
"version": "1.0.0",
"version": "2.0.0",
"description": "Node JS SDK for Zoho CRM",
"main": "lib/index.js",
"type": "module",
Expand Down
67 changes: 67 additions & 0 deletions samples/apis/getSupportedAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as ZOHOCRMSDK from "@zohocrm/nodejs-sdk-7.0";

class GetSupportedAPI {

static async initialize() {
let environment = ZOHOCRMSDK.USDataCenter.PRODUCTION();
let token = new ZOHOCRMSDK.OAuthBuilder()
.clientId("client_id")
.clientSecret("client_secret")
.grantToken("grant_token")
.build();

await (await new ZOHOCRMSDK.InitializeBuilder())
.environment(environment)
.token(token)
.initialize();
}
static async getSupportedAPI() {
let filters = null;
let apisOperations = new ZOHOCRMSDK.Apis.APIsOperations(filters);
let response = await apisOperations.getSupportedAPI();

if (response != null) {
console.log("Status Code: " + response.getStatusCode());

if (response.getStatusCode() == 204) {
console.log("No Content");
return;
}

let responseHandler = response.getObject();

if (responseHandler instanceof ZOHOCRMSDK.Apis.ResponseWrapper) {
let responseWrapper = responseHandler;
let apis = responseWrapper.getApis();

if (apis != null) {
apis.forEach(api => {
console.log("API Path: " + api.getPath());
let operationTypes = api.getOperationTypes();

operationTypes.forEach(operationType => {
console.log("API Operation Method: " + operationType.getMethod());
console.log("API Operation OAuthScope: " + operationType.getOauthScope());
console.log("API Operation MaxCredits: " + operationType.getMaxCredits());
console.log("API Operation MinCredits: " + operationType.getMinCredits());
});
});
}
} else if (responseHandler instanceof ZOHOCRMSDK.Apis.APIException) {
let exception = responseHandler;
console.log("Status: " + exception.getStatus().getValue());
console.log("Code: " + exception.getCode().getValue());
console.log("Details: ");

for (let [key, value] of Object.entries(exception.getDetails())) {
console.log(`${key}: ${value}`);
}

console.log("Message: " + exception.getMessage());
}
}
}
}

await GetSupportedAPI.initialize();
await GetSupportedAPI.getSupportedAPI()
83 changes: 83 additions & 0 deletions samples/audit_log_exports/createAuditlogExport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import * as ZOHOCRMSDK from "@zohocrm/nodejs-sdk-7.0";

class CreateAuditlogExport {

static async initialize() {
let environment = ZOHOCRMSDK.USDataCenter.PRODUCTION();
let token = new ZOHOCRMSDK.OAuthBuilder()
.clientId("client_id")
.clientSecret("client_secret")
.grantToken("grant_token")
.build();

await (await new ZOHOCRMSDK.InitializeBuilder())
.environment(environment)
.token(token)
.initialize();
}
static async createAuditlogExport() {
const auditLogExportOperations = new ZOHOCRMSDK.AuditExportLog.AuditLogExportOperations();
const request = new ZOHOCRMSDK.AuditExportLog.BodyWrapper();
const auditLogExport = [];

const auditLogExport1 = new ZOHOCRMSDK.AuditExportLog.AuditLogExport();
const criteria = new ZOHOCRMSDK.AuditExportLog.Criteria();
criteria.setComparator("between");

const field = new ZOHOCRMSDK.AuditExportLog.Field();
field.setAPIName("audited_time");
await criteria.setField(field);

const values = [];
values.push(new Date(2024, 2, 20, 10, 10, 19));
values.push(new Date(2024, 2, 20, 10, 10, 10));
criteria.setValue(values);

await auditLogExport1.setCriteria(criteria);
auditLogExport.push(auditLogExport1);
request.setAuditLogExport(auditLogExport);

const response = await auditLogExportOperations.createAuditlogExport(request);
if (response) {
console.log("Status Code: " + response.getStatusCode());
const actionHandler = response.getObject();
if (actionHandler instanceof ZOHOCRMSDK.AuditExportLog.ActionWrapper) {
const actionWrapper = actionHandler;
const actionResponses = actionWrapper.getAuditLogExport();
for (const actionResponse of actionResponses) {
if (actionResponse instanceof ZOHOCRMSDK.AuditExportLog.SuccessResponse) {
const successResponse = actionResponse;
console.log("Status: " + successResponse.getStatus().getValue());
console.log("Code: " + successResponse.getCode().getValue());
console.log("Details: ");
for (let [key, value] of Object.entries(successResponse.getDetails())) {
console.log(key + ": " + value);
}
console.log("Message: " + successResponse.getMessage());
} else if (actionResponse instanceof ZOHOCRMSDK.AuditExportLog.APIException) {
const exception = actionResponse;
console.log("Status: " + exception.getStatus().getValue());
console.log("Code: " + exception.getCode().getValue());
console.log("Details: ");
for (let [key, value] of Object.entries(exception.getDetails())) {
console.log(key + ": " + value);
}
console.log("Message: " + exception.getMessage());
}
}
} else if (actionHandler instanceof ZOHOCRMSDK.AuditExportLog.APIException) {
const exception = actionHandler;
console.log("Status: " + exception.getStatus().getValue());
console.log("Code: " + exception.getCode().getValue());
console.log("Details: ");
for (const [key, value] of Object.entries(exception.getDetails())) {
console.log(key + ": " + value);
}
console.log("Message: " + exception.getMessage());
}
}
}
}

await CreateAuditlogExport.initialize();
await CreateAuditlogExport.createAuditlogExport()
Loading

0 comments on commit 6571e96

Please sign in to comment.