Skip to content

Commit 1ad233f

Browse files
committed
improve README formatting
1 parent 5fec76c commit 1ad233f

File tree

1 file changed

+67
-96
lines changed

1 file changed

+67
-96
lines changed

README.md

Lines changed: 67 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,107 @@
1-
##Node JS SDK for Zoho CRM
1+
# Node JS SDK for Zoho CRM
22

3-
##Abstract
3+
## Abstract
44

55
Node SDK is a wrapper for Zoho CRM APIs. Hence invoking a Zoho CRM API from your Node application is just a function call which provide the most appropriate response.
66

77
This SDK supports both single user as well as multi user authentication.
88

9-
##Registering a Zoho Client
9+
## Registering a Zoho Client
1010

1111
Since Zoho CRM APIs are authenticated with OAuth2 standards, you should register your client app with Zoho. To register your app:
1212

13-
- Visit this page https://accounts.zoho.com/developerconsole.
13+
- Visit this page https://accounts.zoho.com/developerconsole.
14+
- Click on “Add Client ID”.
15+
- Enter Client Name, Client Domain and Redirect URI.
16+
- Select the Client Type as "Web based".
17+
- Click “Create”.
18+
- Your Client app would have been created and displayed by now.
19+
- The newly registered app's Client ID and Client Secret can be found by clicking Options → Edit. (Options is the three dot icon at the right corner).
1420

15-
- Click on “Add Client ID”.
16-
17-
- Enter Client Name, Client Domain and Redirect URI.
18-
19-
- Select the Client Type as "Web based".
20-
21-
- Click “Create”.
22-
23-
- Your Client app would have been created and displayed by now.
24-
25-
- The newly registered app's Client ID and Client Secret can be found by clicking Options → Edit.
(Options is the three dot icon at the right corner).
26-
27-
##Installation of Node CRM SDK
21+
## Installation of Node CRM SDK
2822

2923
Node JS SDK will be installed and a package named 'zcrmsdk' will be created in the installation directory.
3024

31-
>npm install zcrmsdk
25+
```console
26+
npm install zcrmsdk
27+
```
3228

3329
Once installed it can be used in the code as below,
3430

35-
>var ZCRMRestClient = require('zcrmsdk')
36-
37-
##API Usage
31+
```javascript
32+
var ZCRMRestClient = require('zcrmsdk')
33+
```
3834

39-
##Configurations
35+
## Configurations
4036

4137
Your OAuth Client details should be given to the SDK as a property file. In the SDK, you need to configure a file named oauth_configuration.properties. Please place the respective values in that file. You can place it under resources/ package from where the SDK is used.
4238

43-
44-
zcrmsdk will try reading file from **'resources/oauth_configuration.properties'**
45-
39+
zcrmsdk will try reading file from `'resources/oauth_configuration.properties'`
4640

4741
Please fill the values for the following keys alone.
4842
Based on your domain(EU,CN), please change the value of crm.iamurl. Default value set as US domain.
4943

50-
51-
```
52-
44+
```ini
5345
[zoho]
54-
crm.iamurl=
55-
crm.clientid=
56-
crm.clientsecret=
57-
crm.redirecturl=
58-
46+
crm.iamurl=
47+
crm.clientid=
48+
crm.clientsecret=
49+
crm.redirecturl=
5950
```
6051

61-
crm.clientid, crm.clientsecret and crm.redirecturl are your OAuth client’s configurations that you get after registering your Zoho client.
62-
crm.iamurl is the accounts URL. It may be accounts.zoho.com or accounts.zoho.eu. If the crm.iamurl is not specified, by default the URL will be accounts.zoho.com.
52+
`crm.clientid`, `crm.clientsecret`, and `crm.redirecturl` are your OAuth client’s configurations that you get after registering your Zoho client. `crm.iamurl` is the accounts URL. It may be `accounts.zoho.com` or `accounts.zoho.eu`. If `crm.iamurl` is not specified, the default URL will be `accounts.zoho.com`.
6353

64-
In configuration.properties file:
54+
In `configuration.properties` file:
6555

66-
```
56+
```ini
6757
[crm]
68-
api.url=
69-
api.user_identifier=
70-
api.tokenmanagement=
58+
api.url=
59+
api.user_identifier=
60+
api.tokenmanagement=
7161

7262
[mysql]
7363
username=
74-
password=
75-
64+
password=
7665
```
77-
api.url is the URL used to call APIs. By default, the URL is www.zohoapis.com.
78-
api.user_identifier will be empty by default. For single user authentication, this key can be filled with the respective email id, so that all calls happens by using this user's authentication.
79-
api.tokenmanagement is given as a measure to manage and maintain tokens. If tokenmanagement is not provided, then sdk's default implementation(mysql) will be followed.
80-
username and password can be given here if you already have one created for your MySQL.
81-
The above keys specified in configuration.properties file are all optional.
82-
83-
user_identifier can be set in two ways .
84-
1.Mentioning it in api.user_identifier in configuration.properties file
85-
2.Can be set via code using set setUserIdentifier.
66+
`api.url` is the URL used to call APIs (default `www.zohoapis.com`).
67+
`api.user_identifier` will be empty by default. For single user authentication, this key can be filled with the respective email id so that all API calls use this user's authentication.
68+
`api.tokenmanagement` can be used to provide an alternative token storage function. If not specified the default implementation (MySQL) will be used.
69+
`username` and `password` are the credentials used to access MySQL
70+
The above keys specified in `configuration.properties` file are all optional.
8671

87-
If user_identifier is not set via both the ways then default value 'zcrm_default_user' will be set by the sdk itself .
72+
`user_identifier` can be set by either:
73+
1. Specifying `api.user_identifier` in the `configuration.properties` file or
74+
1. Via code by using set `setUserIdentifier()`
8875

76+
If `user_identifier` is not set the default value (`zcrm_default_user`) will be used.
8977

90-
##Token Storage Mechanism
9178

92-
To use the default token storage provided by the SDK, the following are to be done:
79+
## Token Storage Mechanism
9380

94-
**Mysql should be running in default port in localhost.**
81+
To use the default token storage mechanism:
82+
**MySQL should be running on the default port (3306) on localhost.**
83+
Create a database named `zohooauth` with a table named `"oauthtokens"` with the columns `"useridentifier" (varchar), "accesstoken" (varchar), "refreshtoken" (varchar), and "expirytime" (bigint)`.
9584

96-
Database with name **zohooauth** should be created and a table with below configurations should be present in the database. Table, named **"oauthtokens"**, should have the columns **"useridentifier" (varchar) "accesstoken" (varchar), "refreshtoken" (varchar) and "expirytime" (bigint)**.
85+
With this configuration in place, storage and retrieval of tokens will be handled by the SDK.
9786

98-
Once the configuration is set, storage and retrieval of tokens will be handled by the SDK.
99-
If the user wants to utilize their own mechanism, they can mention it in configuration.properties by providing the respective module in api.tokenmanagement.
87+
### Custom Token Storage
88+
If you want to use another token storage mechanism, you can declare it in `configuration.properties` by specifying the respective module in `api.tokenmanagement`.
10089

101-
This module should contain the below methods,
102-
**saveOAuthTokens(token_obj)**
103-
**updateOAuthTokens(token_obj)**
104-
Irrespective of response, the next execution happens. So care should be taken by the user in handling their module.
105-
**getOAuthTokens()**
106-
The expected response for this method : JSON array containing json response with expirytime, refreshtoken and accesstoken fields.
90+
This module should contain the methods:
91+
- `saveOAuthTokens(token_obj)`
92+
- `updateOAuthTokens(token_obj)`
93+
- `getOAuthTokens()` - shall return a JSON array containing expirytime, refreshtoken and accesstoken fields.
10794

108-
109-
##Generating self-authorized grant and refresh token
95+
## Generating self-authorized grant and refresh token
11096

11197
For self client apps, the self authorized grant token should be generated from the Zoho Developer Console (https://accounts.zoho.com/developerconsole)
11298

113-
114-
- Visit https://accounts.zoho.com/developerconsole
115-
116-
- Click Options → Self Client of the client for which you wish to authorize.
117-
118-
- Enter one or more (comma separated) valid Zoho CRM scopes that you wish to authorize in the “Scope” field and choose the time of expiry. Provide “aaaserver.profile.READ” scope along with Zoho CRM scopes.
119-
- Copy the grant token for backup.
120-
121-
- Generate refresh_token from grant token by making a POST request with the URL below https://accounts.zoho.com/oauth/v2/token?code={grant_token}&redirect_uri={redirect_uri}&client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code
122-
123-
- Copy the refresh token for backup.
99+
- Visit https://accounts.zoho.com/developerconsole
100+
- Click Options → Self Client of the client for which you wish to authorize.
101+
- Enter one or more (comma separated) valid Zoho CRM scopes that you wish to authorize in the “Scope” field and choose the time of expiry. Provide “aaaserver.profile.READ” scope along with Zoho CRM scopes.
102+
- Copy the grant token for backup.
103+
- Generate refresh_token from grant token by making a POST request with the URL below https://accounts.zoho.com/oauth/v2/token?code={grant_token}&redirect_uri={redirect_uri}&client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code
104+
- Copy the refresh token for backup.
124105

125106
Please note that the generated grant token is valid only for the stipulated time you chose while generating it. Hence, the access and refresh tokens should be generated within that time.
126107

@@ -129,7 +110,7 @@ Each time server is restarted, this function has to be called and both the confi
129110
**All functions return promises in zcrm node sdk.**
130111

131112

132-
##Initialize
113+
## Initialize
133114

134115
Below snippet has to be called before starting the app
135116

@@ -141,24 +122,21 @@ ZCRMRestClient.initialize().then(function(){
141122
...
142123
143124
});
144-
145125
```
146126

147-
##Generating access and refresh token from granttoken
127+
## Generating access and refresh token from granttoken
148128

149129
```
150-
151130
ZCRMRestClient.generateAuthTokens(user_identifier,grant_token).then(function(auth_response){
152131
153132
console.log("access token :"+auth_response.access_token);
154133
console.log("refresh token :"+auth_response.refresh_token);
155134
console.log("expires in :"+auth_response.expires_in);
156135
157136
});
158-
159137
```
160138

161-
##Generating access token from refresh token
139+
## Generating access token from refresh token
162140

163141
This will be handled by sdk itself if the access and refresh token is generated by sdk.Developer need not call this explicitly.
164142

@@ -170,10 +148,9 @@ ZCRMRestClient.generateAuthTokenfromRefreshToken(user_identifier,refresh_token).
170148
console.log("expires in :"+auth_response.expires_in);
171149
172150
});
173-
174151
```
175152

176-
##Sample API Calls
153+
## Sample API Calls
177154

178155
```
179156
var input ={};
@@ -194,7 +171,7 @@ crmclient.API.MODULES.get(input).then(function(response){
194171
195172
var record = data[i];
196173
var name = record.Full_Name;
197-
174+
198175
result+="<br><span>"+name+"</span>";
199176
200177
}
@@ -206,7 +183,7 @@ crmclient.API.MODULES.get(input).then(function(response){
206183

207184

208185

209-
##Hierarchy
186+
## Hierarchy
210187
zcrmsdk
211188

212189
```
@@ -248,20 +225,14 @@ zcrmsdk
248225
executeFunctionsInPost
249226
```
250227

251-
252228
As appearing in the hierarchy, zcrmsdk entity class has instance variables to fetch its own properties and to fetch data of its immediate child entities through an API call.
253229

254230
For example, to call an API to get module data, the request should be zcrmsdk.API.MODULES.{operation_type}. The operation types can be GET, POST, PUT, DELETE or CREATE.
255231

256-
257-
258-
##Response Handling
232+
## Response Handling
259233
All API calls will give the actual API response given by Zoho APIs, except file download.
260234

261235
For file download, the response will contain an extra field filename.
262236

263-
##Error Handling:
264-
All errors will be thrown explicitly and care should be taken in catching the same.
265-
266-
267-
237+
## Error Handling:
238+
All errors will be thrown explicitly and care should be taken to catch them.

0 commit comments

Comments
 (0)