@friggframework/api-module-zoho-crm 2.0.0-next.2 → 2.0.0-next.3
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 +16 -1
- package/dist/api.d.ts +16 -1
- package/dist/api.js +84 -0
- package/dist/types.d.ts +44 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ If you've already done this, skip to the next section.
|
|
|
52
52
|
```shell
|
|
53
53
|
ZOHO_CRM_CLIENT_ID=your_client_id
|
|
54
54
|
ZOHO_CRM_CLIENT_SECRET=your_client_secret
|
|
55
|
-
ZOHO_CRM_SCOPE=ZohoCRM.users.ALL
|
|
55
|
+
ZOHO_CRM_SCOPE=ZohoCRM.users.ALL ZohoCRM.org.ALL ZohoCRM.settings.roles.ALL ZohoCRM.settings.profiles.ALL ZohoCRM.modules.contacts.ALL ZohoCRM.modules.leads.ALL ZohoCRM.modules.accounts.ALL ZohoCRM.modules.calls.ALL
|
|
56
56
|
REDIRECT_URI=http://localhost:3000/redirect
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -90,6 +90,21 @@ If you've already done this, skip to the next section.
|
|
|
90
90
|
- `getAccount(accountId)` - Get a specific account by ID
|
|
91
91
|
- `searchAccounts(searchParams)` - Search accounts by phone, criteria, or word
|
|
92
92
|
|
|
93
|
+
### Calls
|
|
94
|
+
- `logCall(callData)` - Log a call in the Zoho CRM Calls module
|
|
95
|
+
- `updateCall(callId, callData)` - Update an existing call record
|
|
96
|
+
|
|
97
|
+
**Call Data Fields:**
|
|
98
|
+
| Field | Type | Required | Description |
|
|
99
|
+
|-------|------|----------|-------------|
|
|
100
|
+
| `Subject` | string | Yes | Call subject/title |
|
|
101
|
+
| `Call_Type` | string | Yes | `Inbound`, `Outbound`, or `Missed` |
|
|
102
|
+
| `Call_Start_Time` | string | Yes | ISO 8601 datetime |
|
|
103
|
+
| `Call_Duration` | string | Yes* | `mm:ss` format (*required for Inbound/Outbound, cannot be zero) |
|
|
104
|
+
| `Description` | string | No | Call notes |
|
|
105
|
+
| `Who_Id` | string | No | Contact/Lead ID to associate |
|
|
106
|
+
| `$se_module` | string | No | Module for Who_Id: `Contacts` or `Leads` |
|
|
107
|
+
|
|
93
108
|
## Using the API Module from the Terminal
|
|
94
109
|
|
|
95
110
|
With your `.env` in place, you can test the API from a Node terminal.
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Requester } from '@friggframework/core';
|
|
2
|
-
import { ZohoConfig, QueryParams, SearchParams, UsersResponse, RolesResponse, ProfilesResponse, ContactsResponse, ContactResponse, LeadsResponse, LeadResponse, AccountsResponse, AccountResponse, TokenResponse, CreateNoteData, NotesResponse, NoteListResponse, NotificationWatchConfig, NotificationResponse, NotificationDetailsResponse } from './types';
|
|
2
|
+
import { ZohoConfig, QueryParams, SearchParams, UsersResponse, RolesResponse, ProfilesResponse, ContactsResponse, ContactResponse, LeadsResponse, LeadResponse, AccountsResponse, AccountResponse, TokenResponse, CreateNoteData, NotesResponse, NoteListResponse, NotificationWatchConfig, NotificationResponse, NotificationDetailsResponse, ZohoCallData, CallsResponse } from './types';
|
|
3
3
|
export declare class Api extends OAuth2Requester {
|
|
4
4
|
URLs: Record<string, string | ((id: string) => string)>;
|
|
5
5
|
private static readonly CONTACTS_DEFAULT_FIELDS;
|
|
@@ -98,4 +98,19 @@ export declare class Api extends OAuth2Requester {
|
|
|
98
98
|
* @see https://www.zoho.com/crm/developer/docs/api/v8/notifications/get-details.html
|
|
99
99
|
*/
|
|
100
100
|
getNotificationDetails(): Promise<NotificationDetailsResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Log a call in Zoho CRM Calls module
|
|
103
|
+
* @param callData - Call record data with Subject, Call_Type, Call_Start_Time, Call_Duration
|
|
104
|
+
* @returns Promise<CallsResponse> Created call response
|
|
105
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/insert-records.html
|
|
106
|
+
*/
|
|
107
|
+
logCall(callData: ZohoCallData): Promise<CallsResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Update an existing call record in Zoho CRM Calls module
|
|
110
|
+
* @param callId - Zoho Call ID to update
|
|
111
|
+
* @param callData - Partial call data to update (e.g., Description, Subject)
|
|
112
|
+
* @returns Promise<CallsResponse> Updated call response
|
|
113
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/update-records.html
|
|
114
|
+
*/
|
|
115
|
+
updateCall(callId: string, callData: Partial<ZohoCallData>): Promise<CallsResponse>;
|
|
101
116
|
}
|
package/dist/api.js
CHANGED
|
@@ -26,6 +26,8 @@ class Api extends core_1.OAuth2Requester {
|
|
|
26
26
|
accounts: '/Accounts',
|
|
27
27
|
account: (accountId) => `/Accounts/${accountId}`,
|
|
28
28
|
accountSearch: '/Accounts/search',
|
|
29
|
+
calls: '/Calls',
|
|
30
|
+
call: (callId) => `/Calls/${callId}`,
|
|
29
31
|
notificationsWatch: '/actions/watch',
|
|
30
32
|
};
|
|
31
33
|
}
|
|
@@ -201,6 +203,12 @@ class Api extends core_1.OAuth2Requester {
|
|
|
201
203
|
});
|
|
202
204
|
}
|
|
203
205
|
catch (error) {
|
|
206
|
+
// Zoho returns 204 No Content with empty body when no results found
|
|
207
|
+
// This causes JSON parsing to fail with "Unexpected end of JSON input"
|
|
208
|
+
if (error?.message?.includes('Unexpected end of JSON input') ||
|
|
209
|
+
error?.message?.includes('invalid json response body')) {
|
|
210
|
+
return { data: [], info: undefined };
|
|
211
|
+
}
|
|
204
212
|
throw error;
|
|
205
213
|
}
|
|
206
214
|
}
|
|
@@ -247,6 +255,11 @@ class Api extends core_1.OAuth2Requester {
|
|
|
247
255
|
});
|
|
248
256
|
}
|
|
249
257
|
catch (error) {
|
|
258
|
+
// Zoho returns 204 No Content with empty body when no results found
|
|
259
|
+
if (error?.message?.includes('Unexpected end of JSON input') ||
|
|
260
|
+
error?.message?.includes('invalid json response body')) {
|
|
261
|
+
return { data: [], info: undefined };
|
|
262
|
+
}
|
|
250
263
|
throw error;
|
|
251
264
|
}
|
|
252
265
|
}
|
|
@@ -293,6 +306,11 @@ class Api extends core_1.OAuth2Requester {
|
|
|
293
306
|
});
|
|
294
307
|
}
|
|
295
308
|
catch (error) {
|
|
309
|
+
// Zoho returns 204 No Content with empty body when no results found
|
|
310
|
+
if (error?.message?.includes('Unexpected end of JSON input') ||
|
|
311
|
+
error?.message?.includes('invalid json response body')) {
|
|
312
|
+
return { data: [], info: undefined };
|
|
313
|
+
}
|
|
296
314
|
throw error;
|
|
297
315
|
}
|
|
298
316
|
}
|
|
@@ -514,6 +532,72 @@ class Api extends core_1.OAuth2Requester {
|
|
|
514
532
|
throw error;
|
|
515
533
|
}
|
|
516
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Log a call in Zoho CRM Calls module
|
|
537
|
+
* @param callData - Call record data with Subject, Call_Type, Call_Start_Time, Call_Duration
|
|
538
|
+
* @returns Promise<CallsResponse> Created call response
|
|
539
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/insert-records.html
|
|
540
|
+
*/
|
|
541
|
+
async logCall(callData) {
|
|
542
|
+
if (!callData.Subject) {
|
|
543
|
+
throw new Error('callData.Subject is required');
|
|
544
|
+
}
|
|
545
|
+
if (!callData.Call_Type) {
|
|
546
|
+
throw new Error('callData.Call_Type is required');
|
|
547
|
+
}
|
|
548
|
+
if (!callData.Call_Start_Time) {
|
|
549
|
+
throw new Error('callData.Call_Start_Time is required');
|
|
550
|
+
}
|
|
551
|
+
// Duration is mandatory for Inbound/Outbound calls and cannot be zero
|
|
552
|
+
if ((callData.Call_Type === 'Inbound' || callData.Call_Type === 'Outbound') && !callData.Call_Duration) {
|
|
553
|
+
throw new Error('callData.Call_Duration is required for Inbound/Outbound calls');
|
|
554
|
+
}
|
|
555
|
+
const body = {
|
|
556
|
+
data: [callData]
|
|
557
|
+
};
|
|
558
|
+
try {
|
|
559
|
+
return await this._post({
|
|
560
|
+
url: this.baseUrl + this.URLs.calls,
|
|
561
|
+
body: body,
|
|
562
|
+
headers: {
|
|
563
|
+
'Content-Type': 'application/json',
|
|
564
|
+
},
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
catch (error) {
|
|
568
|
+
throw error;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Update an existing call record in Zoho CRM Calls module
|
|
573
|
+
* @param callId - Zoho Call ID to update
|
|
574
|
+
* @param callData - Partial call data to update (e.g., Description, Subject)
|
|
575
|
+
* @returns Promise<CallsResponse> Updated call response
|
|
576
|
+
* @see https://www.zoho.com/crm/developer/docs/api/v8/update-records.html
|
|
577
|
+
*/
|
|
578
|
+
async updateCall(callId, callData) {
|
|
579
|
+
if (!callId) {
|
|
580
|
+
throw new Error('callId is required');
|
|
581
|
+
}
|
|
582
|
+
if (!callData || Object.keys(callData).length === 0) {
|
|
583
|
+
throw new Error('callData must contain at least one field to update');
|
|
584
|
+
}
|
|
585
|
+
const body = {
|
|
586
|
+
data: [callData]
|
|
587
|
+
};
|
|
588
|
+
try {
|
|
589
|
+
return await this._put({
|
|
590
|
+
url: this.baseUrl + this.URLs.call(callId),
|
|
591
|
+
body: body,
|
|
592
|
+
headers: {
|
|
593
|
+
'Content-Type': 'application/json',
|
|
594
|
+
},
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
catch (error) {
|
|
598
|
+
throw error;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
517
601
|
}
|
|
518
602
|
exports.Api = Api;
|
|
519
603
|
Api.CONTACTS_DEFAULT_FIELDS = 'id,First_Name,Last_Name,Email,Phone,Mobile,Account_Name,Company,Owner,Lead_Source,Created_Time,Modified_Time';
|
package/dist/types.d.ts
CHANGED
|
@@ -354,3 +354,47 @@ export interface NotificationCallbackPayload {
|
|
|
354
354
|
/** Verification token (if provided during setup) */
|
|
355
355
|
token?: string;
|
|
356
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Data for creating/updating a call record in Zoho CRM Calls module
|
|
359
|
+
*/
|
|
360
|
+
export interface ZohoCallData {
|
|
361
|
+
/** Call subject/title (required) */
|
|
362
|
+
Subject: string;
|
|
363
|
+
/** Call type: Inbound, Outbound, or Missed (required) */
|
|
364
|
+
Call_Type: 'Inbound' | 'Outbound' | 'Missed';
|
|
365
|
+
/** Call start time in ISO 8601 format (required) */
|
|
366
|
+
Call_Start_Time: string;
|
|
367
|
+
/** Call duration in "HH:mm" or "mm:ss" format (required for Inbound/Outbound, cannot be zero) */
|
|
368
|
+
Call_Duration: string;
|
|
369
|
+
/** Call notes/description */
|
|
370
|
+
Description?: string;
|
|
371
|
+
/** Contact or Lead ID to associate the call with */
|
|
372
|
+
Who_Id?: string;
|
|
373
|
+
/** Module name for the Who_Id association: "Contacts" or "Leads" */
|
|
374
|
+
$se_module?: string;
|
|
375
|
+
/** Additional custom fields */
|
|
376
|
+
[key: string]: any;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Response from Calls module operations
|
|
380
|
+
*/
|
|
381
|
+
export interface CallsResponse {
|
|
382
|
+
data: Array<{
|
|
383
|
+
code: string;
|
|
384
|
+
details: {
|
|
385
|
+
id: string;
|
|
386
|
+
Created_Time: string;
|
|
387
|
+
Modified_Time: string;
|
|
388
|
+
Created_By?: {
|
|
389
|
+
name: string;
|
|
390
|
+
id: string;
|
|
391
|
+
};
|
|
392
|
+
Modified_By?: {
|
|
393
|
+
name: string;
|
|
394
|
+
id: string;
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
message: string;
|
|
398
|
+
status: string;
|
|
399
|
+
}>;
|
|
400
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/api-module-zoho-crm",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.3",
|
|
4
4
|
"prettier": "@friggframework/prettier-config",
|
|
5
5
|
"description": "Zoho CRM API module that lets the Frigg Framework interact with Zoho CRM",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "fd8e7d7ad197886b7bd94a68fd26c179358f4b67"
|
|
40
40
|
}
|