@friggframework/api-module-zoho-crm 2.0.0-next.0 → 2.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -197
- package/dist/api.d.ts +101 -0
- package/dist/api.js +521 -0
- package/dist/defaultConfig.json +13 -0
- package/dist/definition.d.ts +22 -0
- package/dist/definition.js +75 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +32 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.js +2 -0
- package/package.json +21 -10
- package/.env.example +0 -4
- package/CHANGELOG.md +0 -50
- package/api.js +0 -169
- package/defaultConfig.json +0 -13
- package/definition.js +0 -51
- package/images/image-1.jpg +0 -0
- package/images/image-10.jpg +0 -0
- package/images/image-11.jpg +0 -0
- package/images/image-12.jpg +0 -0
- package/images/image-2.jpg +0 -0
- package/images/image-3.jpg +0 -0
- package/images/image-5.jpg +0 -0
- package/images/image-6.jpg +0 -0
- package/images/image-7.jpg +0 -0
- package/images/image-9.jpg +0 -0
- package/images/image.jpg +0 -0
- package/index.js +0 -9
- package/jest-setup.js +0 -3
- package/jest-teardown.js +0 -2
- package/jest.config.js +0 -22
- package/tests/api.test.js +0 -195
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
export interface ZohoConfig {
|
|
2
|
+
client_id: string;
|
|
3
|
+
client_secret: string;
|
|
4
|
+
scope: string;
|
|
5
|
+
redirect_uri: string;
|
|
6
|
+
access_token?: string | null;
|
|
7
|
+
refresh_token?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface PaginationInfo {
|
|
10
|
+
per_page: number;
|
|
11
|
+
count: number;
|
|
12
|
+
page: number;
|
|
13
|
+
more_records: boolean;
|
|
14
|
+
next_page_token?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ZohoUser {
|
|
17
|
+
id: string;
|
|
18
|
+
first_name?: string;
|
|
19
|
+
last_name?: string;
|
|
20
|
+
full_name?: string;
|
|
21
|
+
email: string;
|
|
22
|
+
role?: {
|
|
23
|
+
name: string;
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
profile?: {
|
|
27
|
+
name: string;
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
status?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ZohoRole {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ZohoProfile {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ZohoContact {
|
|
43
|
+
id: string;
|
|
44
|
+
First_Name?: string;
|
|
45
|
+
Last_Name?: string;
|
|
46
|
+
Email?: string;
|
|
47
|
+
Phone?: string;
|
|
48
|
+
Account_Name?: {
|
|
49
|
+
name: string;
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
Owner?: {
|
|
53
|
+
name: string;
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
Lead_Source?: string;
|
|
57
|
+
Created_Time?: string;
|
|
58
|
+
Modified_Time?: string;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
export interface ZohoLead {
|
|
62
|
+
id: string;
|
|
63
|
+
First_Name?: string;
|
|
64
|
+
Last_Name?: string;
|
|
65
|
+
Email?: string;
|
|
66
|
+
Phone?: string;
|
|
67
|
+
Mobile?: string;
|
|
68
|
+
Company?: string;
|
|
69
|
+
Industry?: string;
|
|
70
|
+
Lead_Source?: string;
|
|
71
|
+
Lead_Status?: string;
|
|
72
|
+
Owner?: {
|
|
73
|
+
name: string;
|
|
74
|
+
id: string;
|
|
75
|
+
};
|
|
76
|
+
Converted__s?: boolean;
|
|
77
|
+
Converted_Date_Time?: string;
|
|
78
|
+
Created_Time?: string;
|
|
79
|
+
Modified_Time?: string;
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
}
|
|
82
|
+
export interface ZohoAccount {
|
|
83
|
+
id: string;
|
|
84
|
+
Account_Name?: string;
|
|
85
|
+
Account_Number?: string;
|
|
86
|
+
Account_Type?: string;
|
|
87
|
+
Industry?: string;
|
|
88
|
+
Annual_Revenue?: number;
|
|
89
|
+
Rating?: string;
|
|
90
|
+
Phone?: string;
|
|
91
|
+
Fax?: string;
|
|
92
|
+
Website?: string;
|
|
93
|
+
Ticker_Symbol?: string;
|
|
94
|
+
Ownership?: string;
|
|
95
|
+
Employees?: number;
|
|
96
|
+
SIC_Code?: string;
|
|
97
|
+
Billing_Street?: string;
|
|
98
|
+
Billing_City?: string;
|
|
99
|
+
Billing_State?: string;
|
|
100
|
+
Billing_Code?: string;
|
|
101
|
+
Billing_Country?: string;
|
|
102
|
+
Shipping_Street?: string;
|
|
103
|
+
Shipping_City?: string;
|
|
104
|
+
Shipping_State?: string;
|
|
105
|
+
Shipping_Code?: string;
|
|
106
|
+
Shipping_Country?: string;
|
|
107
|
+
Parent_Account?: {
|
|
108
|
+
name: string;
|
|
109
|
+
id: string;
|
|
110
|
+
};
|
|
111
|
+
Owner?: {
|
|
112
|
+
name: string;
|
|
113
|
+
id: string;
|
|
114
|
+
};
|
|
115
|
+
Description?: string;
|
|
116
|
+
Created_Time?: string;
|
|
117
|
+
Modified_Time?: string;
|
|
118
|
+
Created_By?: {
|
|
119
|
+
name: string;
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
Modified_By?: {
|
|
123
|
+
name: string;
|
|
124
|
+
id: string;
|
|
125
|
+
};
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
}
|
|
128
|
+
export interface UsersResponse {
|
|
129
|
+
users: ZohoUser[];
|
|
130
|
+
info?: PaginationInfo;
|
|
131
|
+
}
|
|
132
|
+
export interface RolesResponse {
|
|
133
|
+
roles: ZohoRole[];
|
|
134
|
+
}
|
|
135
|
+
export interface ProfilesResponse {
|
|
136
|
+
profiles: ZohoProfile[];
|
|
137
|
+
}
|
|
138
|
+
export interface ContactsResponse {
|
|
139
|
+
data: ZohoContact[];
|
|
140
|
+
info?: PaginationInfo;
|
|
141
|
+
}
|
|
142
|
+
export interface ContactResponse {
|
|
143
|
+
data: ZohoContact[];
|
|
144
|
+
}
|
|
145
|
+
export interface LeadsResponse {
|
|
146
|
+
data: ZohoLead[];
|
|
147
|
+
info?: PaginationInfo;
|
|
148
|
+
}
|
|
149
|
+
export interface LeadResponse {
|
|
150
|
+
data: ZohoLead[];
|
|
151
|
+
}
|
|
152
|
+
export interface AccountsResponse {
|
|
153
|
+
data: ZohoAccount[];
|
|
154
|
+
info?: PaginationInfo;
|
|
155
|
+
}
|
|
156
|
+
export interface AccountResponse {
|
|
157
|
+
data: ZohoAccount[];
|
|
158
|
+
}
|
|
159
|
+
export interface CreateResponse {
|
|
160
|
+
code: string;
|
|
161
|
+
details: {
|
|
162
|
+
id: string;
|
|
163
|
+
Created_Time: string;
|
|
164
|
+
Modified_Time: string;
|
|
165
|
+
Created_By?: {
|
|
166
|
+
name: string;
|
|
167
|
+
id: string;
|
|
168
|
+
};
|
|
169
|
+
Modified_By?: {
|
|
170
|
+
name: string;
|
|
171
|
+
id: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
message: string;
|
|
175
|
+
status: string;
|
|
176
|
+
}
|
|
177
|
+
export interface UpdateResponse {
|
|
178
|
+
code: string;
|
|
179
|
+
details: {
|
|
180
|
+
id: string;
|
|
181
|
+
Modified_Time: string;
|
|
182
|
+
Modified_By?: {
|
|
183
|
+
name: string;
|
|
184
|
+
id: string;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
message: string;
|
|
188
|
+
status: string;
|
|
189
|
+
}
|
|
190
|
+
export interface DeleteResponse {
|
|
191
|
+
code: string;
|
|
192
|
+
details: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
|
+
message: string;
|
|
196
|
+
status: string;
|
|
197
|
+
}
|
|
198
|
+
export interface ZohoNote {
|
|
199
|
+
id: string;
|
|
200
|
+
Note_Title?: string;
|
|
201
|
+
Note_Content: string;
|
|
202
|
+
Parent_Id?: {
|
|
203
|
+
module: {
|
|
204
|
+
api_name: string;
|
|
205
|
+
id: string;
|
|
206
|
+
};
|
|
207
|
+
id: string;
|
|
208
|
+
};
|
|
209
|
+
Owner?: {
|
|
210
|
+
name: string;
|
|
211
|
+
id: string;
|
|
212
|
+
};
|
|
213
|
+
Created_Time?: string;
|
|
214
|
+
Modified_Time?: string;
|
|
215
|
+
Created_By?: {
|
|
216
|
+
name: string;
|
|
217
|
+
id: string;
|
|
218
|
+
};
|
|
219
|
+
Modified_By?: {
|
|
220
|
+
name: string;
|
|
221
|
+
id: string;
|
|
222
|
+
};
|
|
223
|
+
[key: string]: any;
|
|
224
|
+
}
|
|
225
|
+
export interface CreateNoteData {
|
|
226
|
+
Note_Content: string;
|
|
227
|
+
Note_Title?: string;
|
|
228
|
+
}
|
|
229
|
+
export interface NotesResponse {
|
|
230
|
+
data: Array<{
|
|
231
|
+
code: string;
|
|
232
|
+
details: {
|
|
233
|
+
id: string;
|
|
234
|
+
Created_Time: string;
|
|
235
|
+
Modified_Time: string;
|
|
236
|
+
Created_By?: {
|
|
237
|
+
name: string;
|
|
238
|
+
id: string;
|
|
239
|
+
};
|
|
240
|
+
Modified_By?: {
|
|
241
|
+
name: string;
|
|
242
|
+
id: string;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
message: string;
|
|
246
|
+
status: string;
|
|
247
|
+
}>;
|
|
248
|
+
}
|
|
249
|
+
export interface NoteListResponse {
|
|
250
|
+
data: ZohoNote[];
|
|
251
|
+
info?: PaginationInfo;
|
|
252
|
+
}
|
|
253
|
+
export interface QueryParams {
|
|
254
|
+
fields?: string;
|
|
255
|
+
per_page?: number;
|
|
256
|
+
page?: number;
|
|
257
|
+
sort_by?: string;
|
|
258
|
+
sort_order?: 'asc' | 'desc';
|
|
259
|
+
cvid?: string;
|
|
260
|
+
page_token?: string;
|
|
261
|
+
type?: 'ActiveUsers' | 'CurrentUser' | 'AdminUsers' | 'AllUsers';
|
|
262
|
+
}
|
|
263
|
+
export interface SearchParams {
|
|
264
|
+
email?: string;
|
|
265
|
+
phone?: string;
|
|
266
|
+
criteria?: string;
|
|
267
|
+
word?: string;
|
|
268
|
+
fields?: string;
|
|
269
|
+
per_page?: number;
|
|
270
|
+
}
|
|
271
|
+
export interface TokenResponse {
|
|
272
|
+
access_token: string;
|
|
273
|
+
refresh_token: string;
|
|
274
|
+
api_domain: string;
|
|
275
|
+
token_type: string;
|
|
276
|
+
expires_in: number;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Configuration for a single notification watch item
|
|
280
|
+
*/
|
|
281
|
+
export interface NotificationWatchItem {
|
|
282
|
+
/** Unique channel ID (use timestamp or UUID) */
|
|
283
|
+
channel_id: number | string;
|
|
284
|
+
/** Events to watch in format: "Module.operation" (e.g., "Contacts.all", "Contacts.create", "Accounts.edit") */
|
|
285
|
+
events: string[];
|
|
286
|
+
/** Callback URL to receive notifications */
|
|
287
|
+
notify_url: string;
|
|
288
|
+
/** Optional verification token (max 50 characters) */
|
|
289
|
+
token?: string;
|
|
290
|
+
/** Channel expiry time (ISO 8601 format, max 1 week from now) */
|
|
291
|
+
channel_expiry?: string;
|
|
292
|
+
/** Include field changes in callback payload */
|
|
293
|
+
return_affected_field_values?: boolean;
|
|
294
|
+
/** Trigger notifications on related record actions */
|
|
295
|
+
notify_on_related_action?: boolean;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Request body for enabling notifications
|
|
299
|
+
*/
|
|
300
|
+
export interface NotificationWatchConfig {
|
|
301
|
+
watch: NotificationWatchItem[];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Response from notification API operations
|
|
305
|
+
*/
|
|
306
|
+
export interface NotificationResponse {
|
|
307
|
+
watch: Array<{
|
|
308
|
+
code: string;
|
|
309
|
+
details: {
|
|
310
|
+
channel_id: number | string;
|
|
311
|
+
events: string[];
|
|
312
|
+
channel_expiry: string;
|
|
313
|
+
resource_uri: string;
|
|
314
|
+
resource_id: string;
|
|
315
|
+
resource_name: string;
|
|
316
|
+
};
|
|
317
|
+
message: string;
|
|
318
|
+
status: string;
|
|
319
|
+
}>;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Response from getting notification details
|
|
323
|
+
*/
|
|
324
|
+
export interface NotificationDetailsResponse {
|
|
325
|
+
watch: Array<{
|
|
326
|
+
channel_id: number | string;
|
|
327
|
+
events: string[];
|
|
328
|
+
channel_expiry: string;
|
|
329
|
+
notify_url: string;
|
|
330
|
+
resource_uri: string;
|
|
331
|
+
resource_id: string;
|
|
332
|
+
resource_name: string;
|
|
333
|
+
token?: string;
|
|
334
|
+
}>;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Payload received in notification callback
|
|
338
|
+
*/
|
|
339
|
+
export interface NotificationCallbackPayload {
|
|
340
|
+
/** Server timestamp */
|
|
341
|
+
server_time: number;
|
|
342
|
+
/** Module name (e.g., "Contacts", "Accounts") */
|
|
343
|
+
module: string;
|
|
344
|
+
/** Resource URI */
|
|
345
|
+
resource_uri: string;
|
|
346
|
+
/** Array of affected record IDs */
|
|
347
|
+
ids: string[];
|
|
348
|
+
/** Fields that were affected (if return_affected_field_values enabled) */
|
|
349
|
+
affected_fields?: string[];
|
|
350
|
+
/** Operation type: "insert", "update", or "delete" */
|
|
351
|
+
operation: 'insert' | 'update' | 'delete';
|
|
352
|
+
/** Channel ID that triggered this notification */
|
|
353
|
+
channel_id: number | string;
|
|
354
|
+
/** Verification token (if provided during setup) */
|
|
355
|
+
token?: string;
|
|
356
|
+
}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/api-module-zoho-crm",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"prettier": "@friggframework/prettier-config",
|
|
5
5
|
"description": "Zoho CRM API module that lets the Frigg Framework interact with Zoho CRM",
|
|
6
|
-
"main": "index.js",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json",
|
|
10
|
+
"prepare": "npm run build",
|
|
8
11
|
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
|
|
9
|
-
"test": "
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest"
|
|
10
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*",
|
|
17
|
+
"defaultConfig.json",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE.md"
|
|
20
|
+
],
|
|
11
21
|
"author": "",
|
|
12
22
|
"license": "MIT",
|
|
13
23
|
"devDependencies": {
|
|
14
|
-
"@friggframework/devtools": "^
|
|
15
|
-
"@friggframework/test": "^
|
|
24
|
+
"@friggframework/devtools": "^2.0.0-next.16",
|
|
25
|
+
"@friggframework/test": "^2.0.0-next.16",
|
|
26
|
+
"@types/node": "^20.8.0",
|
|
16
27
|
"dotenv": "^16.0.3",
|
|
17
28
|
"eslint": "^8.22.0",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
29
|
+
"prettier": "^2.7.1",
|
|
30
|
+
"typescript": "^5.4.0",
|
|
31
|
+
"vitest": "^1.0.0"
|
|
21
32
|
},
|
|
22
33
|
"dependencies": {
|
|
23
|
-
"@friggframework/core": "^
|
|
34
|
+
"@friggframework/core": "^2.0.0-next.16"
|
|
24
35
|
},
|
|
25
36
|
"publishConfig": {
|
|
26
37
|
"access": "public"
|
|
27
38
|
},
|
|
28
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "fa3f5ec40cbb9300511849233bddb0c463bfab2a"
|
|
29
40
|
}
|
package/.env.example
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# v1.0.2 (Tue Aug 06 2024)
|
|
2
|
-
|
|
3
|
-
:tada: This release contains work from a new contributor! :tada:
|
|
4
|
-
|
|
5
|
-
Thank you, Fer Riffel ([@FerRiffel-LeftHook](https://github.com/FerRiffel-LeftHook)), for all your work!
|
|
6
|
-
|
|
7
|
-
#### 🐛 Bug Fix
|
|
8
|
-
|
|
9
|
-
- Updated icons for all Frigg API modules [#14](https://github.com/friggframework/api-module-library/pull/14) ([@FerRiffel-LeftHook](https://github.com/FerRiffel-LeftHook))
|
|
10
|
-
- Update icons for all Frigg API modules ([@FerRiffel-LeftHook](https://github.com/FerRiffel-LeftHook))
|
|
11
|
-
|
|
12
|
-
#### Authors: 1
|
|
13
|
-
|
|
14
|
-
- Fer Riffel ([@FerRiffel-LeftHook](https://github.com/FerRiffel-LeftHook))
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
# v1.0.1 (Mon Jul 15 2024)
|
|
19
|
-
|
|
20
|
-
:tada: This release contains work from new contributors! :tada:
|
|
21
|
-
|
|
22
|
-
Thanks for all your work!
|
|
23
|
-
|
|
24
|
-
:heart: Igor Schechtel ([@igorschechtel](https://github.com/igorschechtel))
|
|
25
|
-
|
|
26
|
-
:heart: Armando Alvarado ([@aaj](https://github.com/aaj))
|
|
27
|
-
|
|
28
|
-
#### 🐛 Bug Fix
|
|
29
|
-
|
|
30
|
-
- Unbabel Projects, Asana, and Zoho CRM [#10](https://github.com/friggframework/api-module-library/pull/10) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
31
|
-
- add public publish access for zoho-crm ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
32
|
-
- Add API module for Asana [#2](https://github.com/friggframework/api-module-library/pull/2) ([@igorschechtel](https://github.com/igorschechtel))
|
|
33
|
-
- Added Zoho CRM API module [#4](https://github.com/friggframework/api-module-library/pull/4) ([@aaj](https://github.com/aaj))
|
|
34
|
-
- Update README.md ([@aaj](https://github.com/aaj))
|
|
35
|
-
- Added README ([@aaj](https://github.com/aaj))
|
|
36
|
-
- Use single quotes ([@aaj](https://github.com/aaj))
|
|
37
|
-
- Added test for listProfile, left stumps for all the other tests ([@aaj](https://github.com/aaj))
|
|
38
|
-
- Better comments ([@aaj](https://github.com/aaj))
|
|
39
|
-
- Added missing scope ([@aaj](https://github.com/aaj))
|
|
40
|
-
- Added tests for all endpoints ([@aaj](https://github.com/aaj))
|
|
41
|
-
- Added all CRUD endpoints for User and Role entities ([@aaj](https://github.com/aaj))
|
|
42
|
-
- Added .env.example ([@aaj](https://github.com/aaj))
|
|
43
|
-
- Added JSON headers, added createRole ([@aaj](https://github.com/aaj))
|
|
44
|
-
- Initial Zoho CRM api module ([@aaj](https://github.com/aaj))
|
|
45
|
-
|
|
46
|
-
#### Authors: 3
|
|
47
|
-
|
|
48
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
49
|
-
- Armando Alvarado ([@aaj](https://github.com/aaj))
|
|
50
|
-
- Igor Schechtel ([@igorschechtel](https://github.com/igorschechtel))
|
package/api.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
const FormData = require('form-data');
|
|
2
|
-
const {OAuth2Requester, get} = require('@friggframework/core');
|
|
3
|
-
|
|
4
|
-
class Api extends OAuth2Requester {
|
|
5
|
-
constructor(params) {
|
|
6
|
-
super(params);
|
|
7
|
-
// The majority of the properties for OAuth are default loaded by OAuth2Requester.
|
|
8
|
-
// This includes the `client_id`, `client_secret`, `scopes`, and `redirect_uri`.
|
|
9
|
-
this.baseUrl = 'https://www.zohoapis.com/crm/v6';
|
|
10
|
-
this.authorizationUri = encodeURI(
|
|
11
|
-
`https://accounts.zoho.com/oauth/v2/auth?scope=${this.scope}&client_id=${this.client_id}&redirect_uri=${this.redirect_uri}&response_type=code&access_type=offline`
|
|
12
|
-
);
|
|
13
|
-
this.tokenUri = 'https://accounts.zoho.com/oauth/v2/token';
|
|
14
|
-
this.access_token = get(params, 'access_token', null);
|
|
15
|
-
this.refresh_token = get(params, 'refresh_token', null);
|
|
16
|
-
|
|
17
|
-
this.URLs = {
|
|
18
|
-
// Users
|
|
19
|
-
users: '/users',
|
|
20
|
-
user: (userId) => `/users/${userId}`,
|
|
21
|
-
|
|
22
|
-
// Roles
|
|
23
|
-
roles: '/settings/roles',
|
|
24
|
-
role: (roleId) => `/settings/roles/${roleId}`,
|
|
25
|
-
|
|
26
|
-
// Profiles
|
|
27
|
-
profiles: '/settings/profiles',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getAuthUri() {
|
|
32
|
-
return this.authorizationUri;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async getTokenFromCode(code) {
|
|
36
|
-
// I had to override OAuth2Requester.getTokenFromCode method so I could send a form-data,
|
|
37
|
-
// as described in the docs: https://www.zoho.com/crm/developer/docs/api/v6/access-refresh.html
|
|
38
|
-
const formData = new FormData();
|
|
39
|
-
formData.append('grant_type', 'authorization_code');
|
|
40
|
-
formData.append('client_id', this.client_id);
|
|
41
|
-
formData.append('client_secret', this.client_secret);
|
|
42
|
-
formData.append('redirect_uri', this.redirect_uri);
|
|
43
|
-
formData.append('scope', this.scope);
|
|
44
|
-
formData.append('code', code);
|
|
45
|
-
const options = {
|
|
46
|
-
body: formData,
|
|
47
|
-
headers: formData.getHeaders(),
|
|
48
|
-
url: this.tokenUri,
|
|
49
|
-
};
|
|
50
|
-
const response = await this._post(options, false);
|
|
51
|
-
await this.setTokens(response);
|
|
52
|
-
return response;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
addJsonHeaders(options) {
|
|
56
|
-
const jsonHeaders = {
|
|
57
|
-
'content-type': 'application/json',
|
|
58
|
-
Accept: 'application/json',
|
|
59
|
-
};
|
|
60
|
-
options.headers = {
|
|
61
|
-
...jsonHeaders,
|
|
62
|
-
...options.headers,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async _get(options, stringify) {
|
|
67
|
-
this.addJsonHeaders(options);
|
|
68
|
-
return super._get(options, stringify);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async _post(options, stringify) {
|
|
72
|
-
this.addJsonHeaders(options);
|
|
73
|
-
return super._post(options, stringify);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async _put(options, stringify) {
|
|
77
|
-
this.addJsonHeaders(options);
|
|
78
|
-
return super._put(options, stringify);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async _delete(options) {
|
|
82
|
-
this.addJsonHeaders(options);
|
|
83
|
-
const response = await super._delete(options);
|
|
84
|
-
return await this.parsedBody(response);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ************************** Users **********************************
|
|
88
|
-
// https://www.zoho.com/crm/developer/docs/api/v6/get-users.html
|
|
89
|
-
|
|
90
|
-
async listUsers(queryParams = {}) {
|
|
91
|
-
return this._get({
|
|
92
|
-
url: this.baseUrl + this.URLs.users,
|
|
93
|
-
query: {...queryParams},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async getUser(userId) {
|
|
98
|
-
return this._get({
|
|
99
|
-
url: this.baseUrl + this.URLs.user(userId),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async createUser(body = {}) {
|
|
104
|
-
return this._post({
|
|
105
|
-
url: this.baseUrl + this.URLs.users,
|
|
106
|
-
body: body
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async updateUser(userId, body = {}) {
|
|
111
|
-
return this._put({
|
|
112
|
-
url: this.baseUrl + this.URLs.user(userId),
|
|
113
|
-
body: body,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async deleteUser(userId) {
|
|
118
|
-
return this._delete({
|
|
119
|
-
url: this.baseUrl + this.URLs.user(userId),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ************************** Roles **********************************
|
|
124
|
-
// https://www.zoho.com/crm/developer/docs/api/v6/get-roles.html
|
|
125
|
-
|
|
126
|
-
async listRoles() {
|
|
127
|
-
return this._get({
|
|
128
|
-
url: this.baseUrl + this.URLs.roles
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async getRole(roleId) {
|
|
133
|
-
return this._get({
|
|
134
|
-
url: this.baseUrl + this.URLs.role(roleId)
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async createRole(body = {}) {
|
|
139
|
-
return this._post({
|
|
140
|
-
url: this.baseUrl + this.URLs.roles,
|
|
141
|
-
body: body
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async updateRole(roleId, body = {}) {
|
|
146
|
-
return this._put({
|
|
147
|
-
url: this.baseUrl + this.URLs.role(roleId),
|
|
148
|
-
body: body,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async deleteRole(roleId, queryParams = {}) {
|
|
153
|
-
return this._delete({
|
|
154
|
-
url: this.baseUrl + this.URLs.role(roleId),
|
|
155
|
-
query: {...queryParams},
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// ************************** Profiles **********************************
|
|
160
|
-
// https://www.zoho.com/crm/developer/docs/api/v6/get-profiles.html
|
|
161
|
-
|
|
162
|
-
async listProfiles() {
|
|
163
|
-
return this._get({
|
|
164
|
-
url: this.baseUrl + this.URLs.profiles
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
module.exports = {Api};
|
package/defaultConfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "zoho-crm",
|
|
3
|
-
"label": "Zoho CRM",
|
|
4
|
-
"productUrl": "https://www.zoho.com/crm/",
|
|
5
|
-
"apiDocs": "https://www.zoho.com/crm/developer/docs/",
|
|
6
|
-
"logoUrl": "https://friggframework.org/assets/img/zoho-icon.png",
|
|
7
|
-
"categories": [
|
|
8
|
-
"Sales",
|
|
9
|
-
"Marketing",
|
|
10
|
-
"CRM"
|
|
11
|
-
],
|
|
12
|
-
"description": "Zoho CRM acts as a single repository to bring your sales, marketing, and customer support activities together, and streamline your process, policy, and people in one platform."
|
|
13
|
-
}
|
package/definition.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
2
|
-
const {Api} = require('./api');
|
|
3
|
-
const {get} = require('@friggframework/core');
|
|
4
|
-
const config = require('./defaultConfig.json')
|
|
5
|
-
|
|
6
|
-
const Definition = {
|
|
7
|
-
API: Api,
|
|
8
|
-
getName: function() {
|
|
9
|
-
return config.name
|
|
10
|
-
},
|
|
11
|
-
moduleName: config.name,
|
|
12
|
-
requiredAuthMethods: {
|
|
13
|
-
getToken: async function(api, params) {
|
|
14
|
-
const code = get(params.data, 'code');
|
|
15
|
-
await api.getTokenFromCode(code);
|
|
16
|
-
},
|
|
17
|
-
apiPropertiesToPersist: {
|
|
18
|
-
credential: ['access_token', 'refresh_token'],
|
|
19
|
-
entity: [],
|
|
20
|
-
},
|
|
21
|
-
getCredentialDetails: async function (api, userId) {
|
|
22
|
-
const response = await api.listUsers({type: 'CurrentUser'});
|
|
23
|
-
const currentUser = response.users[0];
|
|
24
|
-
return {
|
|
25
|
-
identifiers: {externalId: currentUser.id, user: userId},
|
|
26
|
-
details: {},
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
getEntityDetails: async function (api, callbackParams, tokenResponse, userId) {
|
|
30
|
-
const response = await api.listUsers({type: 'CurrentUser'});
|
|
31
|
-
const currentUser = response.users[0];
|
|
32
|
-
return {
|
|
33
|
-
identifiers: {externalId: currentUser.id, user: userId},
|
|
34
|
-
details: {
|
|
35
|
-
name: currentUser.email
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
testAuthRequest: async function(api) {
|
|
40
|
-
return await api.listUsers();
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
env: {
|
|
44
|
-
client_id: process.env.ZOHO_CRM_CLIENT_ID,
|
|
45
|
-
client_secret: process.env.ZOHO_CRM_CLIENT_SECRET,
|
|
46
|
-
scope: process.env.ZOHO_CRM_SCOPE,
|
|
47
|
-
redirect_uri: `${process.env.REDIRECT_URI}/zoho-crm`,
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
module.exports = {Definition};
|
package/images/image-1.jpg
DELETED
|
Binary file
|
package/images/image-10.jpg
DELETED
|
Binary file
|