@ecodrix/erix-api 1.0.7 → 1.0.8
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/dist/cli.js +3 -3
- package/dist/index.d.ts +41 -11
- package/dist/ts/browser/index.global.js +9 -9
- package/dist/ts/browser/index.global.js.map +1 -1
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/index.cjs.map +1 -1
- package/dist/ts/cjs/index.d.cts +41 -11
- package/dist/ts/esm/index.d.ts +41 -11
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/resources/crm/activities.ts +10 -9
- package/src/resources/crm/analytics.ts +12 -11
- package/src/resources/crm/automationDashboard.ts +4 -3
- package/src/resources/crm/automations.ts +20 -18
- package/src/resources/crm/leads.ts +93 -23
- package/src/resources/crm/payments.ts +2 -1
- package/src/resources/crm/pipelines.ts +12 -12
- package/src/resources/crm/scoring.ts +4 -3
- package/src/resources/crm/sequences.ts +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecodrix/erix-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"author": "ECODrIx Team <contact@ecodrix.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",
|
|
@@ -19,35 +19,35 @@ export class Notes extends APIResource {
|
|
|
19
19
|
* List all notes for a specific lead.
|
|
20
20
|
*/
|
|
21
21
|
async list<T = any>(leadId: string) {
|
|
22
|
-
return this.get<T>(`/api/
|
|
22
|
+
return this.get<T>(`/api/crm/leads/${leadId}/notes`);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Add a note to a lead.
|
|
27
27
|
*/
|
|
28
28
|
async create<T = any>(leadId: string, params: { content: string }) {
|
|
29
|
-
return this.post<T>(`/api/
|
|
29
|
+
return this.post<T>(`/api/crm/leads/${leadId}/notes`, params);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Update an existing note.
|
|
34
34
|
*/
|
|
35
35
|
async update<T = any>(noteId: string, content: string) {
|
|
36
|
-
return this.patch<T>(`/api/
|
|
36
|
+
return this.patch<T>(`/api/crm/notes/${noteId}`, { content });
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Pin or unpin a note to the top of the feed.
|
|
41
41
|
*/
|
|
42
42
|
async pin<T = any>(noteId: string, isPinned = true) {
|
|
43
|
-
return this.patch<T>(`/api/
|
|
43
|
+
return this.patch<T>(`/api/crm/notes/${noteId}/pin`, { isPinned });
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Delete a note.
|
|
48
48
|
*/
|
|
49
49
|
async delete(noteId: string) {
|
|
50
|
-
return this.deleteRequest(`/api/
|
|
50
|
+
return this.deleteRequest(`/api/crm/notes/${noteId}`);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -63,27 +63,28 @@ export class Activities extends APIResource {
|
|
|
63
63
|
* Retrieve the complete chronological timeline for a lead.
|
|
64
64
|
*/
|
|
65
65
|
async timeline<T = any>(leadId: string, params?: { page?: number; limit?: number }) {
|
|
66
|
-
return this.get<T>(`/api/
|
|
66
|
+
return this.get<T>(`/api/crm/leads/${leadId}/timeline`, { params } as any);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* List specific activities (filtered by type).
|
|
71
71
|
*/
|
|
72
72
|
async list<T = any>(leadId: string, params?: { type?: string; page?: number; limit?: number }) {
|
|
73
|
-
return this.get<T>(
|
|
73
|
+
return this.get<T>(`/api/crm/leads/${leadId}/activities`, { params: { ...params } } as any);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Generic method to log a business activity/event.
|
|
78
78
|
*/
|
|
79
79
|
async log<T = any>(params: LogActivityParams) {
|
|
80
|
-
return this.post<T>(
|
|
80
|
+
return this.post<T>(`/api/crm/leads/${params.leadId}/activities`, params);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Specific method to log communication outcomes.
|
|
85
85
|
*/
|
|
86
86
|
async logCall<T = any>(leadId: string, params: LogCallParams) {
|
|
87
|
-
return this.post<T>(`/api/
|
|
87
|
+
return this.post<T>(`/api/crm/leads/${leadId}/calls`, params);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
|
|
@@ -14,76 +14,77 @@ export class Analytics extends APIResource {
|
|
|
14
14
|
* KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
|
|
15
15
|
*/
|
|
16
16
|
async overview<T = any>(params?: AnalyticsParams) {
|
|
17
|
-
return this.get<T>("/api/
|
|
17
|
+
return this.get<T>("/api/crm/analytics/overview", { params } as any);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Stage-by-stage lead counts and conversion percentages.
|
|
22
22
|
*/
|
|
23
23
|
async funnel<T = any>(pipelineId: string) {
|
|
24
|
-
return this.get<T>("/api/
|
|
24
|
+
return this.get<T>("/api/crm/analytics/funnel", { params: { pipelineId } } as any);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Revenue forecast: deal value × stage probability.
|
|
29
29
|
*/
|
|
30
30
|
async forecast<T = any>(pipelineId?: string) {
|
|
31
|
-
return this.get<T>("/api/
|
|
31
|
+
return this.get<T>("/api/crm/analytics/forecast", { params: { pipelineId } } as any);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Lead source breakdown: count, conversion rate, total value per source.
|
|
36
36
|
*/
|
|
37
37
|
async sources<T = any>(params?: AnalyticsParams) {
|
|
38
|
-
return this.get<T>("/api/
|
|
38
|
+
return this.get<T>("/api/crm/analytics/sources", { params } as any);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Team leaderboard: won deals, revenue, activity count, conversion rate per member.
|
|
43
43
|
*/
|
|
44
44
|
async team<T = any>(params?: AnalyticsParams) {
|
|
45
|
-
return this.get<T>("/api/
|
|
45
|
+
return this.get<T>("/api/crm/analytics/team", { params } as any);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Daily activity counts by type. For activity calendar.
|
|
50
50
|
*/
|
|
51
51
|
async heatmap<T = any>(params?: AnalyticsParams) {
|
|
52
|
-
return this.get<T>("/api/
|
|
52
|
+
return this.get<T>("/api/crm/analytics/heatmap", { params } as any);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Score distribution: how many leads in each score bucket.
|
|
57
57
|
*/
|
|
58
58
|
async scores<T = any>() {
|
|
59
|
-
return this.get<T>("/api/
|
|
59
|
+
return this.get<T>("/api/crm/analytics/scores");
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Avg time leads spend in each stage. Helps find bottlenecks.
|
|
64
64
|
*/
|
|
65
65
|
async stageTime<T = any>(pipelineId: string) {
|
|
66
|
-
return this.get<T>("/api/
|
|
66
|
+
return this.get<T>("/api/crm/analytics/stage-time", { params: { pipelineId } } as any);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Tiered Growth Report matching business sophistication.
|
|
71
71
|
*/
|
|
72
72
|
async tiered<T = any>(params?: AnalyticsParams) {
|
|
73
|
-
return this.get<T>("/api/
|
|
73
|
+
return this.get<T>("/api/crm/analytics/tiered", { params } as any);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Consolidated analytics including CRM overview and WhatsApp.
|
|
78
78
|
*/
|
|
79
79
|
async summary<T = any>(params?: AnalyticsParams) {
|
|
80
|
-
return this.get<T>("/api/
|
|
80
|
+
return this.get<T>("/api/crm/analytics/summary", { params } as any);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* WhatsApp volume and delivery analytics.
|
|
85
85
|
*/
|
|
86
86
|
async whatsapp<T = any>(params?: AnalyticsParams) {
|
|
87
|
-
return this.get<T>("/api/
|
|
87
|
+
return this.get<T>("/api/crm/analytics/whatsapp", { params } as any);
|
|
88
88
|
}
|
|
89
|
+
|
|
89
90
|
}
|
|
@@ -5,20 +5,21 @@ export class AutomationDashboard extends APIResource {
|
|
|
5
5
|
* Retrieve summary statistics for automation health.
|
|
6
6
|
*/
|
|
7
7
|
async stats<T = any>() {
|
|
8
|
-
return this.get<T>("/api/
|
|
8
|
+
return this.get<T>("/api/crm/automation/stats");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* List recent EventLog entries (automation logs).
|
|
13
13
|
*/
|
|
14
14
|
async logs<T = any>(params?: { limit?: number; status?: string }) {
|
|
15
|
-
return this.get<T>("/api/
|
|
15
|
+
return this.get<T>("/api/crm/automation/logs", { params } as any);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Re-emit a failed event log to process its automations again.
|
|
20
20
|
*/
|
|
21
21
|
async retryFailedEvent<T = any>(logId: string) {
|
|
22
|
-
return this.post<T>(`/api/
|
|
22
|
+
return this.post<T>(`/api/crm/automation/logs/${logId}/retry`, {});
|
|
23
23
|
}
|
|
24
|
+
|
|
24
25
|
}
|
|
@@ -13,56 +13,57 @@ export class Automations extends APIResource {
|
|
|
13
13
|
* List all automation rules for the tenant.
|
|
14
14
|
*/
|
|
15
15
|
async list<T = any>() {
|
|
16
|
-
return this.get<T>("/api/
|
|
16
|
+
return this.get<T>("/api/crm/automations");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a new automation rule.
|
|
21
21
|
*/
|
|
22
22
|
async create<T = any>(payload: AutomationRulePayload) {
|
|
23
|
-
return this.post<T>("/api/
|
|
23
|
+
return this.post<T>("/api/crm/automations", payload);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Update an existing automation rule.
|
|
28
28
|
*/
|
|
29
29
|
async update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>) {
|
|
30
|
-
return this.patch<T>(`/api/
|
|
30
|
+
return this.patch<T>(`/api/crm/automations/${ruleId}`, payload as any);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Enable or disable an automation rule.
|
|
35
35
|
*/
|
|
36
36
|
async toggle<T = any>(ruleId: string) {
|
|
37
|
-
return this.patch<T>(`/api/
|
|
37
|
+
return this.patch<T>(`/api/crm/automations/${ruleId}/toggle`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Delete an automation rule.
|
|
42
42
|
*/
|
|
43
|
-
async
|
|
44
|
-
return this.deleteRequest
|
|
43
|
+
async delete<T = any>(ruleId: string) {
|
|
44
|
+
return this.deleteRequest(`/api/crm/automations/${ruleId}`);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
|
|
47
48
|
/**
|
|
48
49
|
* Bulk delete rules.
|
|
49
50
|
*/
|
|
50
51
|
async bulkDelete<T = any>(ruleIds: string[]) {
|
|
51
|
-
return this.post<T>("/api/
|
|
52
|
+
return this.post<T>("/api/crm/automations/bulk-delete", { ids: ruleIds });
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* Dry-run test an automation rule against a specific lead.
|
|
56
57
|
*/
|
|
57
58
|
async test<T = any>(ruleId: string, leadId: string) {
|
|
58
|
-
return this.post<T>(`/api/
|
|
59
|
+
return this.post<T>(`/api/crm/automations/${ruleId}/test`, { leadId });
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Get available event triggers for automations.
|
|
63
64
|
*/
|
|
64
65
|
async getAvailableEvents<T = any>() {
|
|
65
|
-
return this.post<T>("/api/
|
|
66
|
+
return this.post<T>("/api/crm/automations/events", {});
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -78,14 +79,14 @@ export class Automations extends APIResource {
|
|
|
78
79
|
endDate?: string;
|
|
79
80
|
},
|
|
80
81
|
) {
|
|
81
|
-
return this.get<T>(`/api/
|
|
82
|
+
return this.get<T>(`/api/crm/automations/${ruleId}/enrollments`, { params });
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Get an enrollment detail.
|
|
86
87
|
*/
|
|
87
88
|
async getEnrollment<T = any>(enrollmentId: string) {
|
|
88
|
-
return this.get<T>(`/api/
|
|
89
|
+
return this.get<T>(`/api/crm/automations/enrollments/${enrollmentId}`);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
@@ -93,7 +94,7 @@ export class Automations extends APIResource {
|
|
|
93
94
|
*/
|
|
94
95
|
async pauseEnrollment<T = any>(ruleId: string, enrollmentId: string) {
|
|
95
96
|
return this.post<T>(
|
|
96
|
-
`/api/
|
|
97
|
+
`/api/crm/automations/${ruleId}/enrollments/${enrollmentId}/pause`,
|
|
97
98
|
{},
|
|
98
99
|
);
|
|
99
100
|
}
|
|
@@ -103,7 +104,7 @@ export class Automations extends APIResource {
|
|
|
103
104
|
*/
|
|
104
105
|
async resumeEnrollment<T = any>(ruleId: string, enrollmentId: string) {
|
|
105
106
|
return this.post<T>(
|
|
106
|
-
`/api/
|
|
107
|
+
`/api/crm/automations/${ruleId}/enrollments/${enrollmentId}/resume`,
|
|
107
108
|
{},
|
|
108
109
|
);
|
|
109
110
|
}
|
|
@@ -112,28 +113,28 @@ export class Automations extends APIResource {
|
|
|
112
113
|
* List workflow runs.
|
|
113
114
|
*/
|
|
114
115
|
async runs<T = any>(ruleId: string) {
|
|
115
|
-
return this.get<T>(`/api/
|
|
116
|
+
return this.get<T>(`/api/crm/automations/${ruleId}/runs`);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
120
|
* Get run details.
|
|
120
121
|
*/
|
|
121
122
|
async getRun<T = any>(runId: string) {
|
|
122
|
-
return this.get<T>(`/api/
|
|
123
|
+
return this.get<T>(`/api/crm/automations/runs/${runId}`);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
/**
|
|
126
127
|
* Resume a paused run.
|
|
127
128
|
*/
|
|
128
129
|
async resumeRun<T = any>(runId: string) {
|
|
129
|
-
return this.post<T>(`/api/
|
|
130
|
+
return this.post<T>(`/api/crm/automations/runs/${runId}/resume`, {});
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
134
|
* Abort a running workflow.
|
|
134
135
|
*/
|
|
135
136
|
async abortRun<T = any>(runId: string) {
|
|
136
|
-
return this.post<T>(`/api/
|
|
137
|
+
return this.post<T>(`/api/crm/automations/runs/${runId}/abort`, {});
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
@@ -146,6 +147,7 @@ export class Automations extends APIResource {
|
|
|
146
147
|
* @param payload - Arbitrary data forwarded to the node context.
|
|
147
148
|
*/
|
|
148
149
|
async webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any) {
|
|
149
|
-
return this.post<T>("/api/
|
|
150
|
+
return this.post<T>("/api/crm/webhook-event", { ruleId, eventName, payload });
|
|
150
151
|
}
|
|
152
|
+
|
|
151
153
|
}
|
|
@@ -3,12 +3,23 @@ import { APIResource } from "../../resource";
|
|
|
3
3
|
/**
|
|
4
4
|
* Valid statuses for a CRM Lead.
|
|
5
5
|
*/
|
|
6
|
-
export type LeadStatus =
|
|
6
|
+
export type LeadStatus =
|
|
7
|
+
| "new"
|
|
8
|
+
| "contacted"
|
|
9
|
+
| "qualified"
|
|
10
|
+
| "won"
|
|
11
|
+
| "lost"
|
|
12
|
+
| "archived";
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
15
|
* Common lead acquisition sources. Additional string values are allowed.
|
|
10
16
|
*/
|
|
11
|
-
export type LeadSource =
|
|
17
|
+
export type LeadSource =
|
|
18
|
+
| "website"
|
|
19
|
+
| "whatsapp"
|
|
20
|
+
| "direct"
|
|
21
|
+
| "referral"
|
|
22
|
+
| string;
|
|
12
23
|
|
|
13
24
|
/**
|
|
14
25
|
* Parameters for creating a new CRM Lead.
|
|
@@ -91,7 +102,7 @@ export class Leads extends APIResource {
|
|
|
91
102
|
* @returns The newly created Lead document.
|
|
92
103
|
*/
|
|
93
104
|
async create<T = any>(params: CreateLeadParams) {
|
|
94
|
-
return this.post<T>("/api/
|
|
105
|
+
return this.post<T>("/api/crm/leads", params);
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
/**
|
|
@@ -101,7 +112,7 @@ export class Leads extends APIResource {
|
|
|
101
112
|
* @returns The newly created or updated Lead document.
|
|
102
113
|
*/
|
|
103
114
|
async upsert<T = any>(params: UpsertLeadParams) {
|
|
104
|
-
return this.post<T>("/api/
|
|
115
|
+
return this.post<T>("/api/crm/leads/upsert", params);
|
|
105
116
|
}
|
|
106
117
|
|
|
107
118
|
/**
|
|
@@ -139,7 +150,7 @@ export class Leads extends APIResource {
|
|
|
139
150
|
* @param leads - Array of leads to import.
|
|
140
151
|
*/
|
|
141
152
|
async import<T = any>(leads: Partial<CreateLeadParams>[]) {
|
|
142
|
-
return this.post<T>("/api/
|
|
153
|
+
return this.post<T>("/api/crm/leads/import", { leads });
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
/**
|
|
@@ -153,7 +164,7 @@ export class Leads extends APIResource {
|
|
|
153
164
|
if (Array.isArray(queryParams.tags)) {
|
|
154
165
|
queryParams.tags = queryParams.tags.join(",");
|
|
155
166
|
}
|
|
156
|
-
return this.get<T>("/api/
|
|
167
|
+
return this.get<T>("/api/crm/leads", { params: queryParams } as any);
|
|
157
168
|
}
|
|
158
169
|
|
|
159
170
|
/**
|
|
@@ -167,14 +178,21 @@ export class Leads extends APIResource {
|
|
|
167
178
|
* }
|
|
168
179
|
* ```
|
|
169
180
|
*/
|
|
170
|
-
async *listAutoPaging<T = any>(
|
|
181
|
+
async *listAutoPaging<T = any>(
|
|
182
|
+
params?: ListLeadsParams,
|
|
183
|
+
): AsyncGenerator<T, void, unknown> {
|
|
171
184
|
let currentPage = params?.page || 1;
|
|
172
185
|
let hasMore = true;
|
|
173
186
|
|
|
174
187
|
while (hasMore) {
|
|
175
|
-
const response: any = await this.list<any>({
|
|
188
|
+
const response: any = await this.list<any>({
|
|
189
|
+
...params,
|
|
190
|
+
page: currentPage,
|
|
191
|
+
});
|
|
176
192
|
|
|
177
|
-
const items = Array.isArray(response.data)
|
|
193
|
+
const items = Array.isArray(response.data)
|
|
194
|
+
? response.data
|
|
195
|
+
: response || [];
|
|
178
196
|
|
|
179
197
|
if (items.length === 0) {
|
|
180
198
|
hasMore = false;
|
|
@@ -203,7 +221,7 @@ export class Leads extends APIResource {
|
|
|
203
221
|
* @returns The Lead document, or a 404 error if not found.
|
|
204
222
|
*/
|
|
205
223
|
async retrieve<T = any>(leadId: string) {
|
|
206
|
-
return this.get<T>(`/api/
|
|
224
|
+
return this.get<T>(`/api/crm/leads/${leadId}`);
|
|
207
225
|
}
|
|
208
226
|
|
|
209
227
|
/**
|
|
@@ -213,7 +231,7 @@ export class Leads extends APIResource {
|
|
|
213
231
|
*/
|
|
214
232
|
async retrieveByPhone<T = any>(phone: string) {
|
|
215
233
|
// URL-encode the phone to handle '+' safe
|
|
216
|
-
return this.get<T>(`/api/
|
|
234
|
+
return this.get<T>(`/api/crm/leads/phone/${encodeURIComponent(phone)}`);
|
|
217
235
|
}
|
|
218
236
|
|
|
219
237
|
/**
|
|
@@ -224,7 +242,7 @@ export class Leads extends APIResource {
|
|
|
224
242
|
*/
|
|
225
243
|
async retrieveByRef<T = any>(refKey: string, refValue: string) {
|
|
226
244
|
return this.get<T>(
|
|
227
|
-
`/api/
|
|
245
|
+
`/api/crm/leads/ref/${encodeURIComponent(refKey)}/${encodeURIComponent(refValue)}`,
|
|
228
246
|
);
|
|
229
247
|
}
|
|
230
248
|
|
|
@@ -236,7 +254,7 @@ export class Leads extends APIResource {
|
|
|
236
254
|
* @returns The updated Lead document.
|
|
237
255
|
*/
|
|
238
256
|
async update<T = any>(leadId: string, params: Partial<CreateLeadParams>) {
|
|
239
|
-
return this.
|
|
257
|
+
return this.patch<T>(`/api/crm/leads/${leadId}`, params);
|
|
240
258
|
}
|
|
241
259
|
|
|
242
260
|
/**
|
|
@@ -246,7 +264,7 @@ export class Leads extends APIResource {
|
|
|
246
264
|
* @param stageId - Target stage ID.
|
|
247
265
|
*/
|
|
248
266
|
async move<T = any>(leadId: string, stageId: string) {
|
|
249
|
-
return this.patch<T>(`/api/
|
|
267
|
+
return this.patch<T>(`/api/crm/leads/${leadId}/move`, { stageId });
|
|
250
268
|
}
|
|
251
269
|
|
|
252
270
|
/**
|
|
@@ -256,8 +274,15 @@ export class Leads extends APIResource {
|
|
|
256
274
|
* @param outcome - "won" | "lost"
|
|
257
275
|
* @param reason - Reason for the outcome.
|
|
258
276
|
*/
|
|
259
|
-
async convert<T = any>(
|
|
260
|
-
|
|
277
|
+
async convert<T = any>(
|
|
278
|
+
leadId: string,
|
|
279
|
+
outcome: "won" | "lost",
|
|
280
|
+
reason?: string,
|
|
281
|
+
) {
|
|
282
|
+
return this.post<T>(`/api/crm/leads/${leadId}/convert`, {
|
|
283
|
+
outcome,
|
|
284
|
+
reason,
|
|
285
|
+
});
|
|
261
286
|
}
|
|
262
287
|
|
|
263
288
|
/**
|
|
@@ -266,8 +291,11 @@ export class Leads extends APIResource {
|
|
|
266
291
|
* @param leadId - ID of the lead.
|
|
267
292
|
* @param options - Tags to add or remove.
|
|
268
293
|
*/
|
|
269
|
-
async tags<T = any>(
|
|
270
|
-
|
|
294
|
+
async tags<T = any>(
|
|
295
|
+
leadId: string,
|
|
296
|
+
options: { add?: string[]; remove?: string[] },
|
|
297
|
+
) {
|
|
298
|
+
return this.patch<T>(`/api/crm/leads/${leadId}/tags`, options);
|
|
271
299
|
}
|
|
272
300
|
|
|
273
301
|
/**
|
|
@@ -276,7 +304,7 @@ export class Leads extends APIResource {
|
|
|
276
304
|
* @param leadId - ID of the lead.
|
|
277
305
|
*/
|
|
278
306
|
async recalculateScore<T = any>(leadId: string) {
|
|
279
|
-
return this.post<T>(`/api/
|
|
307
|
+
return this.post<T>(`/api/crm/leads/${leadId}/score`, {});
|
|
280
308
|
}
|
|
281
309
|
|
|
282
310
|
/**
|
|
@@ -289,14 +317,56 @@ export class Leads extends APIResource {
|
|
|
289
317
|
leadId: string,
|
|
290
318
|
metadata: { refs?: Record<string, any>; extra?: Record<string, any> },
|
|
291
319
|
) {
|
|
292
|
-
return this.patch<T>(`/api/
|
|
320
|
+
return this.patch<T>(`/api/crm/leads/${leadId}/metadata`, metadata);
|
|
293
321
|
}
|
|
294
322
|
|
|
295
323
|
/**
|
|
296
324
|
* Introspect available custom fields configured by the tenant limit.
|
|
297
325
|
*/
|
|
298
326
|
async fields<T = any>() {
|
|
299
|
-
return this.get<T>("/api/
|
|
327
|
+
return this.get<T>("/api/crm/leads/fields");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* List all notes for a specific lead.
|
|
332
|
+
*/
|
|
333
|
+
async notes<T = any>(leadId: string) {
|
|
334
|
+
return this.get<T>(`/api/crm/leads/${leadId}/notes`);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Retrieve the complete chronological timeline for a lead.
|
|
339
|
+
*/
|
|
340
|
+
async activities<T = any>(
|
|
341
|
+
leadId: string,
|
|
342
|
+
params?: { page?: number; limit?: number },
|
|
343
|
+
) {
|
|
344
|
+
return this.get<T>(`/api/crm/leads/${leadId}/timeline`, { params } as any);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Add a note to a lead.
|
|
349
|
+
*/
|
|
350
|
+
async createNote<T = any>(leadId: string, params: { content: string }) {
|
|
351
|
+
return this.post<T>(`/api/crm/leads/${leadId}/notes`, params);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Update an existing note.
|
|
356
|
+
*/
|
|
357
|
+
async updateNote<T = any>(
|
|
358
|
+
leadId: string,
|
|
359
|
+
noteId: string,
|
|
360
|
+
params: { content: string },
|
|
361
|
+
) {
|
|
362
|
+
return this.patch<T>(`/api/crm/notes/${noteId}`, params);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Delete a note.
|
|
367
|
+
*/
|
|
368
|
+
async deleteNote<T = any>(leadId: string, noteId: string) {
|
|
369
|
+
return this.deleteRequest(`/api/crm/notes/${noteId}`);
|
|
300
370
|
}
|
|
301
371
|
|
|
302
372
|
/**
|
|
@@ -305,7 +375,7 @@ export class Leads extends APIResource {
|
|
|
305
375
|
* @param leadId - The ID of the lead to archive.
|
|
306
376
|
*/
|
|
307
377
|
async delete(leadId: string) {
|
|
308
|
-
return this.deleteRequest(`/api/
|
|
378
|
+
return this.deleteRequest(`/api/crm/leads/${leadId}`);
|
|
309
379
|
}
|
|
310
380
|
|
|
311
381
|
/**
|
|
@@ -314,6 +384,6 @@ export class Leads extends APIResource {
|
|
|
314
384
|
* @param ids - Array of lead IDs to archive.
|
|
315
385
|
*/
|
|
316
386
|
async bulkDelete(ids: string[]) {
|
|
317
|
-
return this.deleteRequest("/api/
|
|
387
|
+
return this.deleteRequest("/api/crm/leads", { data: { ids } });
|
|
318
388
|
}
|
|
319
389
|
}
|
|
@@ -14,45 +14,45 @@ export interface PipelineStageParams {
|
|
|
14
14
|
|
|
15
15
|
export class Pipelines extends APIResource {
|
|
16
16
|
/**
|
|
17
|
-
* List all pipelines
|
|
17
|
+
* List all pipelines and their stages.
|
|
18
18
|
*/
|
|
19
|
-
async list<T = any>(
|
|
20
|
-
return this.get<T>("/api/
|
|
19
|
+
async list<T = any>() {
|
|
20
|
+
return this.get<T>("/api/crm/pipelines");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create a new pipeline.
|
|
25
25
|
*/
|
|
26
|
-
async create<T = any>(
|
|
27
|
-
return this.post<T>("/api/
|
|
26
|
+
async create<T = any>(payload: { name: string; stages: string[] }) {
|
|
27
|
+
return this.post<T>("/api/crm/pipelines", payload);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Retrieve a single pipeline.
|
|
31
|
+
* Retrieve a single pipeline by ID.
|
|
32
32
|
*/
|
|
33
33
|
async retrieve<T = any>(pipelineId: string) {
|
|
34
|
-
return this.get<T>(`/api/
|
|
34
|
+
return this.get<T>(`/api/crm/pipelines/${pipelineId}`);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Update
|
|
38
|
+
* Update an existing pipeline.
|
|
39
39
|
*/
|
|
40
|
-
async update<T = any>(pipelineId: string,
|
|
41
|
-
return this.patch<T>(`/api/
|
|
40
|
+
async update<T = any>(pipelineId: string, payload: Partial<{ name: string; stages: string[] }>) {
|
|
41
|
+
return this.patch<T>(`/api/crm/pipelines/${pipelineId}`, payload as any);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Set pipeline as the tenant's default.
|
|
46
46
|
*/
|
|
47
47
|
async setDefault<T = any>(pipelineId: string) {
|
|
48
|
-
return this.post<T>(`/api/
|
|
48
|
+
return this.post<T>(`/api/crm/pipelines/${pipelineId}/default`, {});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Duplicate a pipeline with a new name.
|
|
53
53
|
*/
|
|
54
54
|
async duplicate<T = any>(pipelineId: string, newName: string) {
|
|
55
|
-
return this.post<T>(`/api/
|
|
55
|
+
return this.post<T>(`/api/crm/pipelines/${pipelineId}/duplicate`, { newName });
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|