@ecodrix/erix-api 1.1.3 → 1.1.5
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 +1 -1
- package/dist/index.d.ts +664 -85
- package/dist/ts/browser/index.global.js +1 -1
- 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 +664 -85
- package/dist/ts/esm/index.d.ts +664 -85
- 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 +40 -4
- package/src/resources/crm/analytics.ts +27 -4
- package/src/resources/crm/automationDashboard.ts +21 -3
- package/src/resources/crm/automations.ts +28 -3
- package/src/resources/crm/leads.ts +36 -2
- package/src/resources/crm/payments.ts +12 -1
- package/src/resources/crm/pipelines.ts +46 -4
- package/src/resources/crm/scoring.ts +15 -2
- package/src/resources/crm/sequences.ts +26 -4
- package/src/resources/email.ts +17 -3
- package/src/resources/events.ts +24 -4
- package/src/resources/health.ts +23 -3
- package/src/resources/marketing.ts +79 -8
- package/src/resources/notifications.ts +27 -7
- package/src/resources/queue.ts +28 -3
- package/src/resources/storage.ts +36 -4
- package/src/resources/whatsapp/broadcasts.ts +65 -2
- package/src/resources/whatsapp/conversations.ts +80 -12
- package/src/resources/whatsapp/messages.ts +18 -18
- package/src/resources/whatsapp/templates.ts +92 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecodrix/erix-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
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.",
|
|
@@ -17,13 +17,28 @@ export interface LogCallParams {
|
|
|
17
17
|
export class Notes extends APIResource {
|
|
18
18
|
/**
|
|
19
19
|
* List all notes for a specific lead.
|
|
20
|
+
*
|
|
21
|
+
* @param leadId - The unique ID of the lead.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const notes = await erixClient.crm.activities.notes.list("lead_123");
|
|
25
|
+
* ```
|
|
20
26
|
*/
|
|
21
27
|
async list<T = any>(leadId: string) {
|
|
22
28
|
return this.get<T>(`/api/crm/leads/${leadId}/notes`);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
|
-
* Add a note to a lead.
|
|
32
|
+
* Add a new descriptive note to a lead's profile.
|
|
33
|
+
*
|
|
34
|
+
* @param leadId - The unique ID of the lead.
|
|
35
|
+
* @param params - The note content.
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* await erixClient.crm.activities.notes.create("lead_123", {
|
|
39
|
+
* content: "Customer is interested in the enterprise plan."
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
27
42
|
*/
|
|
28
43
|
async create<T = any>(leadId: string, params: { content: string }) {
|
|
29
44
|
return this.post<T>(`/api/crm/leads/${leadId}/notes`, params);
|
|
@@ -60,9 +75,19 @@ export class Activities extends APIResource {
|
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
/**
|
|
63
|
-
* Retrieve the complete chronological timeline for a lead.
|
|
78
|
+
* Retrieve the complete chronological timeline of all activities for a lead.
|
|
79
|
+
*
|
|
80
|
+
* @param leadId - The unique ID of the lead.
|
|
81
|
+
* @param params - Optional pagination parameters.
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const timeline = await erixClient.crm.activities.timeline("lead_123", { limit: 10 });
|
|
85
|
+
* ```
|
|
64
86
|
*/
|
|
65
|
-
async timeline<T = any>(
|
|
87
|
+
async timeline<T = any>(
|
|
88
|
+
leadId: string,
|
|
89
|
+
params?: { page?: number; limit?: number },
|
|
90
|
+
) {
|
|
66
91
|
return this.get<T>(`/api/crm/leads/${leadId}/timeline`, { params } as any);
|
|
67
92
|
}
|
|
68
93
|
|
|
@@ -74,7 +99,18 @@ export class Activities extends APIResource {
|
|
|
74
99
|
}
|
|
75
100
|
|
|
76
101
|
/**
|
|
77
|
-
* Generic method to log a business activity/event.
|
|
102
|
+
* Generic method to log a business activity/event (e.g., system events, manual tasks).
|
|
103
|
+
*
|
|
104
|
+
* @param params - Activity details (leadId, type, title, body).
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* await erixClient.crm.activities.log({
|
|
108
|
+
* leadId: "lead_123",
|
|
109
|
+
* type: "system",
|
|
110
|
+
* title: "Meeting Scheduled",
|
|
111
|
+
* body: "Initial consultation booked for Friday."
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
78
114
|
*/
|
|
79
115
|
async log<T = any>(params: LogActivityParams) {
|
|
80
116
|
return this.post<T>(`/api/crm/leads/${params.leadId}/activities`, params);
|
|
@@ -11,17 +11,34 @@ export interface AnalyticsParams {
|
|
|
11
11
|
|
|
12
12
|
export class Analytics extends APIResource {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Retrieve high-level CRM performance KPIs.
|
|
15
|
+
* Includes total leads, pipeline value, won revenue, and conversion rates.
|
|
16
|
+
*
|
|
17
|
+
* @param params - Optional filters (time range, pipelineId).
|
|
18
|
+
* @returns KPI summary object.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const stats = await erixClient.crm.analytics.overview({ range: "30d" });
|
|
22
|
+
* ```
|
|
15
23
|
*/
|
|
16
24
|
async overview<T = any>(params?: AnalyticsParams) {
|
|
17
25
|
return this.get<T>("/api/crm/analytics/overview", { params } as any);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
/**
|
|
21
|
-
*
|
|
29
|
+
* Get stage-by-stage lead counts and conversion percentages for a pipeline.
|
|
30
|
+
* Useful for identifying funnel bottlenecks.
|
|
31
|
+
*
|
|
32
|
+
* @param pipelineId - The unique ID of the pipeline to analyze.
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const funnel = await erixClient.crm.analytics.funnel("pipe_123");
|
|
36
|
+
* ```
|
|
22
37
|
*/
|
|
23
38
|
async funnel<T = any>(pipelineId: string) {
|
|
24
|
-
return this.get<T>("/api/crm/analytics/funnel", {
|
|
39
|
+
return this.get<T>("/api/crm/analytics/funnel", {
|
|
40
|
+
params: { pipelineId },
|
|
41
|
+
} as any);
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
/**
|
|
@@ -81,7 +98,13 @@ export class Analytics extends APIResource {
|
|
|
81
98
|
}
|
|
82
99
|
|
|
83
100
|
/**
|
|
84
|
-
* WhatsApp volume and delivery analytics.
|
|
101
|
+
* Retrieve WhatsApp messaging volume and delivery performance analytics.
|
|
102
|
+
*
|
|
103
|
+
* @param params - Optional filters (time range).
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const waStats = await erixClient.crm.analytics.whatsapp({ range: "7d" });
|
|
107
|
+
* ```
|
|
85
108
|
*/
|
|
86
109
|
async whatsapp<T = any>(params?: AnalyticsParams) {
|
|
87
110
|
return this.get<T>("/api/crm/analytics/whatsapp", { params } as any);
|
|
@@ -2,21 +2,39 @@ import { APIResource } from "../../resource";
|
|
|
2
2
|
|
|
3
3
|
export class AutomationDashboard extends APIResource {
|
|
4
4
|
/**
|
|
5
|
-
* Retrieve summary statistics for automation health.
|
|
5
|
+
* Retrieve summary statistics for automation health (total, success, failed).
|
|
6
|
+
*
|
|
7
|
+
* @returns Stats object.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const stats = await erixClient.crm.automationDashboard.stats();
|
|
11
|
+
* ```
|
|
6
12
|
*/
|
|
7
13
|
async stats<T = any>() {
|
|
8
14
|
return this.get<T>("/api/crm/automation/stats");
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
|
-
* List recent EventLog entries
|
|
18
|
+
* List recent EventLog entries representing automation executions.
|
|
19
|
+
*
|
|
20
|
+
* @param params - Optional filters (limit, status).
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const logs = await erixClient.crm.automationDashboard.logs({ status: "failed" });
|
|
24
|
+
* ```
|
|
13
25
|
*/
|
|
14
26
|
async logs<T = any>(params?: { limit?: number; status?: string }) {
|
|
15
27
|
return this.get<T>("/api/crm/automation/logs", { params } as any);
|
|
16
28
|
}
|
|
17
29
|
|
|
18
30
|
/**
|
|
19
|
-
* Re-emit a failed event log to
|
|
31
|
+
* Re-emit a failed event log to re-trigger its associated automation rules.
|
|
32
|
+
*
|
|
33
|
+
* @param logId - The unique ID of the failed event log.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* await erixClient.crm.automationDashboard.retryFailedEvent("log_123");
|
|
37
|
+
* ```
|
|
20
38
|
*/
|
|
21
39
|
async retryFailedEvent<T = any>(logId: string) {
|
|
22
40
|
return this.post<T>(`/api/crm/automation/logs/${logId}/retry`, {});
|
|
@@ -10,14 +10,32 @@ export interface AutomationRulePayload {
|
|
|
10
10
|
|
|
11
11
|
export class Automations extends APIResource {
|
|
12
12
|
/**
|
|
13
|
-
* List all automation rules for the tenant.
|
|
13
|
+
* List all automation rules (workflows) configured for the tenant.
|
|
14
|
+
*
|
|
15
|
+
* @returns Array of automation rule objects.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const rules = await erixClient.crm.automations.list();
|
|
19
|
+
* ```
|
|
14
20
|
*/
|
|
15
21
|
async list<T = any>() {
|
|
16
22
|
return this.get<T>("/api/crm/automations");
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
|
-
* Create a new automation rule.
|
|
26
|
+
* Create a new automation rule with triggers and workflow nodes.
|
|
27
|
+
*
|
|
28
|
+
* @param payload - The automation rule definition (trigger, nodes, edges).
|
|
29
|
+
* @returns The created automation rule.
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* await erixClient.crm.automations.create({
|
|
33
|
+
* name: "Welcome Email Workflow",
|
|
34
|
+
* trigger: "contact_created",
|
|
35
|
+
* nodes: [...],
|
|
36
|
+
* edges: [...]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
21
39
|
*/
|
|
22
40
|
async create<T = any>(payload: AutomationRulePayload) {
|
|
23
41
|
return this.post<T>("/api/crm/automations", payload);
|
|
@@ -53,7 +71,14 @@ export class Automations extends APIResource {
|
|
|
53
71
|
}
|
|
54
72
|
|
|
55
73
|
/**
|
|
56
|
-
* Dry-run test an automation rule against a specific lead.
|
|
74
|
+
* Dry-run test an automation rule against a specific lead to verify logic.
|
|
75
|
+
*
|
|
76
|
+
* @param ruleId - The ID of the rule to test.
|
|
77
|
+
* @param leadId - The ID of the lead to run the test against.
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* await erixClient.crm.automations.test("rule_123", "lead_456");
|
|
81
|
+
* ```
|
|
57
82
|
*/
|
|
58
83
|
async test<T = any>(ruleId: string, leadId: string) {
|
|
59
84
|
return this.post<T>(`/api/crm/automations/${ruleId}/test`, { leadId });
|
|
@@ -100,16 +100,31 @@ export class Leads extends APIResource {
|
|
|
100
100
|
*
|
|
101
101
|
* @param params - Lead creation parameters. `firstName` is required.
|
|
102
102
|
* @returns The newly created Lead document.
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const lead = await erixClient.crm.leads.create({
|
|
106
|
+
* firstName: "Alice",
|
|
107
|
+
* phone: "+919876543210",
|
|
108
|
+
* source: "website"
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
103
111
|
*/
|
|
104
112
|
async create<T = any>(params: CreateLeadParams) {
|
|
105
113
|
return this.post<T>("/api/crm/leads", params);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
/**
|
|
109
|
-
* Upsert a lead by phone number.
|
|
117
|
+
* Upsert a lead by phone number. If a lead with the same phone exists,
|
|
118
|
+
* it will be updated; otherwise, a new lead is created.
|
|
110
119
|
*
|
|
111
120
|
* @param params - Upsert parameters containing leadData with a phone number.
|
|
112
121
|
* @returns The newly created or updated Lead document.
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* await erixClient.crm.leads.upsert({
|
|
125
|
+
* leadData: { phone: "+919876543210", firstName: "Alice" }
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
113
128
|
*/
|
|
114
129
|
async upsert<T = any>(params: UpsertLeadParams) {
|
|
115
130
|
return this.post<T>("/api/crm/leads/upsert", params);
|
|
@@ -154,10 +169,18 @@ export class Leads extends APIResource {
|
|
|
154
169
|
}
|
|
155
170
|
|
|
156
171
|
/**
|
|
157
|
-
* List leads with optional filtering and pagination.
|
|
172
|
+
* List CRM leads with optional filtering and pagination.
|
|
158
173
|
*
|
|
159
174
|
* @param params - Filter options (status, source, pipelineId, page, limit, etc.)
|
|
160
175
|
* @returns Paginated list of Lead documents.
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const leads = await erixClient.crm.leads.list({
|
|
179
|
+
* status: "new",
|
|
180
|
+
* source: "website",
|
|
181
|
+
* limit: 20
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
161
184
|
*/
|
|
162
185
|
async list<T = any>(params?: ListLeadsParams) {
|
|
163
186
|
const queryParams = { ...params } as any;
|
|
@@ -219,6 +242,10 @@ export class Leads extends APIResource {
|
|
|
219
242
|
*
|
|
220
243
|
* @param leadId - The MongoDB ObjectId of the lead.
|
|
221
244
|
* @returns The Lead document, or a 404 error if not found.
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const lead = await erixClient.crm.leads.retrieve("64abc...");
|
|
248
|
+
* ```
|
|
222
249
|
*/
|
|
223
250
|
async retrieve<T = any>(leadId: string) {
|
|
224
251
|
return this.get<T>(`/api/crm/leads/${leadId}`);
|
|
@@ -252,6 +279,13 @@ export class Leads extends APIResource {
|
|
|
252
279
|
* @param leadId - The ID of the lead to update.
|
|
253
280
|
* @param params - Partial lead fields to update.
|
|
254
281
|
* @returns The updated Lead document.
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* await erixClient.crm.leads.update("64abc...", {
|
|
285
|
+
* lastName: "Smith",
|
|
286
|
+
* status: "qualified"
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
255
289
|
*/
|
|
256
290
|
async update<T = any>(leadId: string, params: Partial<CreateLeadParams>) {
|
|
257
291
|
return this.patch<T>(`/api/crm/leads/${leadId}`, params);
|
|
@@ -2,7 +2,18 @@ import { APIResource } from "../../resource";
|
|
|
2
2
|
|
|
3
3
|
export class Payments extends APIResource {
|
|
4
4
|
/**
|
|
5
|
-
* Record an inbound payment against a lead or appointment.
|
|
5
|
+
* Record an inbound payment/transaction against a lead or specific appointment.
|
|
6
|
+
*
|
|
7
|
+
* @param payload - Payment details (leadId, amount, currency, description).
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await erixClient.crm.payments.capture({
|
|
11
|
+
* leadId: "lead_123",
|
|
12
|
+
* amount: 5000,
|
|
13
|
+
* currency: "INR",
|
|
14
|
+
* description: "Consultation Fee"
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
18
|
async capture<T = any>(payload: {
|
|
8
19
|
leadId: string;
|
|
@@ -14,21 +14,43 @@ export interface PipelineStageParams {
|
|
|
14
14
|
|
|
15
15
|
export class Pipelines extends APIResource {
|
|
16
16
|
/**
|
|
17
|
-
* List all pipelines and their stages.
|
|
17
|
+
* List all CRM pipelines and their configured stages.
|
|
18
|
+
*
|
|
19
|
+
* @returns Array of pipeline objects with nested stages.
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const pipelines = await erixClient.crm.pipelines.list();
|
|
23
|
+
* ```
|
|
18
24
|
*/
|
|
19
25
|
async list<T = any>() {
|
|
20
26
|
return this.get<T>("/api/crm/pipelines");
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
|
-
* Create a new pipeline.
|
|
30
|
+
* Create a new CRM sales or support pipeline.
|
|
31
|
+
*
|
|
32
|
+
* @param payload - Pipeline details (name and array of stage names).
|
|
33
|
+
* @returns The created pipeline record.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* await erixClient.crm.pipelines.create({
|
|
37
|
+
* name: "Sales Pipeline",
|
|
38
|
+
* stages: ["Lead", "Contacted", "Proposal", "Negotiation", "Closed"]
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
25
41
|
*/
|
|
26
42
|
async create<T = any>(payload: { name: string; stages: string[] }) {
|
|
27
43
|
return this.post<T>("/api/crm/pipelines", payload);
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
/**
|
|
31
|
-
* Retrieve a single pipeline by ID.
|
|
47
|
+
* Retrieve a single pipeline configuration by ID.
|
|
48
|
+
*
|
|
49
|
+
* @param pipelineId - The unique ID of the pipeline.
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const pipeline = await erixClient.crm.pipelines.retrieve("pipe_123");
|
|
53
|
+
* ```
|
|
32
54
|
*/
|
|
33
55
|
async retrieve<T = any>(pipelineId: string) {
|
|
34
56
|
return this.get<T>(`/api/crm/pipelines/${pipelineId}`);
|
|
@@ -71,6 +93,12 @@ export class Pipelines extends APIResource {
|
|
|
71
93
|
|
|
72
94
|
/**
|
|
73
95
|
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
96
|
+
*
|
|
97
|
+
* @param pipelineId - The unique ID of the pipeline.
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const board = await erixClient.crm.pipelines.board("pipe_123");
|
|
101
|
+
* ```
|
|
74
102
|
*/
|
|
75
103
|
async board<T = any>(pipelineId: string) {
|
|
76
104
|
return this.get<T>(`/api/crm/pipelines/${pipelineId}/board`);
|
|
@@ -87,6 +115,17 @@ export class Pipelines extends APIResource {
|
|
|
87
115
|
|
|
88
116
|
/**
|
|
89
117
|
* Add a new stage to the pipeline.
|
|
118
|
+
*
|
|
119
|
+
* @param pipelineId - The unique ID of the pipeline.
|
|
120
|
+
* @param params - Stage details (name, color, probability).
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* await erixClient.crm.pipelines.addStage("pipe_123", {
|
|
124
|
+
* name: "Decision Maker Bought In",
|
|
125
|
+
* color: "#FF5733",
|
|
126
|
+
* probability: 80
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
90
129
|
*/
|
|
91
130
|
async addStage<T = any>(pipelineId: string, params: PipelineStageParams) {
|
|
92
131
|
return this.post<T>(`/api/crm/pipelines/${pipelineId}/stages`, params);
|
|
@@ -109,7 +148,10 @@ export class Pipelines extends APIResource {
|
|
|
109
148
|
}
|
|
110
149
|
|
|
111
150
|
/**
|
|
112
|
-
* Delete a stage
|
|
151
|
+
* Delete a stage permanently.
|
|
152
|
+
*
|
|
153
|
+
* @param stageId - The unique ID of the stage to delete.
|
|
154
|
+
* @param moveLeadsToStageId - Optional fallback stageId to move active leads to before deletion.
|
|
113
155
|
*/
|
|
114
156
|
async deleteStage(stageId: string, moveLeadsToStageId?: string) {
|
|
115
157
|
return this.deleteRequest(`/api/crm/stages/${stageId}`, {
|
|
@@ -11,7 +11,13 @@ export interface ScoringConfig {
|
|
|
11
11
|
|
|
12
12
|
export class Scoring extends APIResource {
|
|
13
13
|
/**
|
|
14
|
-
* Retrieve the tenant's global lead scoring configuration.
|
|
14
|
+
* Retrieve the tenant's global lead scoring configuration (rules, decay, thresholds).
|
|
15
|
+
*
|
|
16
|
+
* @returns The scoring configuration object.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const config = await erixClient.crm.scoring.getConfig();
|
|
20
|
+
* ```
|
|
15
21
|
*/
|
|
16
22
|
async getConfig<T = any>() {
|
|
17
23
|
return this.get<T>("/api/crm/scoring");
|
|
@@ -25,7 +31,14 @@ export class Scoring extends APIResource {
|
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
|
-
* Force
|
|
34
|
+
* Force an immediate score recalculation for a specific lead.
|
|
35
|
+
* Useful when profile data changes significantly.
|
|
36
|
+
*
|
|
37
|
+
* @param leadId - The unique ID of the lead.
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* await erixClient.crm.scoring.recalculate("lead_123");
|
|
41
|
+
* ```
|
|
29
42
|
*/
|
|
30
43
|
async recalculate<T = any>(leadId: string) {
|
|
31
44
|
return this.post<T>(`/api/crm/scoring/${leadId}/recalculate`, {});
|
|
@@ -2,7 +2,17 @@ import { APIResource } from "../../resource";
|
|
|
2
2
|
|
|
3
3
|
export class Sequences extends APIResource {
|
|
4
4
|
/**
|
|
5
|
-
* Manually enroll a lead
|
|
5
|
+
* Manually enroll a lead into a specific automation drip sequence (Workflow).
|
|
6
|
+
*
|
|
7
|
+
* @param payload - Enrollment details (leadId, ruleId, and custom variables).
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await erixClient.crm.sequences.enroll({
|
|
11
|
+
* leadId: "lead_123",
|
|
12
|
+
* ruleId: "rule_456",
|
|
13
|
+
* variables: { start_date: "2026-05-01" }
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
async enroll<T = any>(payload: {
|
|
8
18
|
leadId: string;
|
|
@@ -13,17 +23,29 @@ export class Sequences extends APIResource {
|
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
|
-
* Unenroll a lead from a running sequence.
|
|
26
|
+
* Unenroll a lead from a currently running automation sequence.
|
|
27
|
+
*
|
|
28
|
+
* @param enrollmentId - The unique ID of the sequence enrollment.
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* await erixClient.crm.sequences.unenroll("enroll_123");
|
|
32
|
+
* ```
|
|
17
33
|
*/
|
|
18
34
|
async unenroll<T = any>(enrollmentId: string) {
|
|
19
35
|
return this.deleteRequest(`/api/crm/sequences/unenroll/${enrollmentId}`);
|
|
20
36
|
}
|
|
21
37
|
|
|
22
38
|
/**
|
|
23
|
-
* List active sequence enrollments for a specific lead.
|
|
39
|
+
* List all active and completed sequence enrollments for a specific lead.
|
|
40
|
+
*
|
|
41
|
+
* @param leadId - The unique ID of the lead.
|
|
42
|
+
* @returns Array of enrollment records.
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const enrollments = await erixClient.crm.sequences.listForLead("lead_123");
|
|
46
|
+
* ```
|
|
24
47
|
*/
|
|
25
48
|
async listForLead<T = any>(leadId: string) {
|
|
26
49
|
return this.get<T>(`/api/crm/sequences/lead/${leadId}`);
|
|
27
50
|
}
|
|
28
|
-
|
|
29
51
|
}
|
package/src/resources/email.ts
CHANGED
|
@@ -28,17 +28,31 @@ export class EmailResource extends APIResource {
|
|
|
28
28
|
* Send an HTML email campaign to a list of recipients.
|
|
29
29
|
*
|
|
30
30
|
* @param payload - The campaign details (recipients, subject, html).
|
|
31
|
-
* @returns The dispatch result.
|
|
31
|
+
* @returns The dispatch result indicating success or failure.
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* await erixClient.email.sendEmailCampaign({
|
|
35
|
+
* recipients: ["user1@example.com", "user2@example.com"],
|
|
36
|
+
* subject: "Monthly Newsletter",
|
|
37
|
+
* html: "<h1>Hello!</h1><p>Check out our latest updates...</p>"
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
32
40
|
*/
|
|
33
|
-
async sendEmailCampaign(
|
|
41
|
+
async sendEmailCampaign(
|
|
42
|
+
payload: SendCampaignPayload,
|
|
43
|
+
): Promise<CampaignResult> {
|
|
34
44
|
return this.post<CampaignResult>("/api/saas/emails/campaign", payload);
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
/**
|
|
38
|
-
* Send a system
|
|
48
|
+
* Send a system test email to validate your current SMTP configuration.
|
|
39
49
|
*
|
|
40
50
|
* @param to - The recipient's email address.
|
|
41
51
|
* @returns The dispatch result.
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* await erixClient.email.sendTestEmail("admin@company.com");
|
|
55
|
+
* ```
|
|
42
56
|
*/
|
|
43
57
|
async sendTestEmail(to: string): Promise<CampaignResult> {
|
|
44
58
|
return this.post<CampaignResult>("/api/saas/emails/test", { to });
|
package/src/resources/events.ts
CHANGED
|
@@ -94,10 +94,18 @@ export interface TriggerResponse {
|
|
|
94
94
|
|
|
95
95
|
export class EventsResource extends APIResource {
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* List all available event definitions (both system and custom) that can trigger automations.
|
|
98
|
+
*
|
|
99
|
+
* @returns Array of event definitions.
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const events = await erixClient.events.list();
|
|
103
|
+
* ```
|
|
98
104
|
*/
|
|
99
105
|
async list(): Promise<{ success: boolean; data: EventDefinition[] }> {
|
|
100
|
-
return this.get<{ success: boolean; data: EventDefinition[] }>(
|
|
106
|
+
return this.get<{ success: boolean; data: EventDefinition[] }>(
|
|
107
|
+
"/api/saas/events",
|
|
108
|
+
);
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
/**
|
|
@@ -128,8 +136,20 @@ export class EventsResource extends APIResource {
|
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
/**
|
|
131
|
-
* Programmatically
|
|
132
|
-
*
|
|
139
|
+
* Programmatically trigger an automation workflow by firing a specific event.
|
|
140
|
+
* This matches the event against active Automation Rules and executes linked actions.
|
|
141
|
+
*
|
|
142
|
+
* @param payload - The trigger details (event name, lead phone/email, variables).
|
|
143
|
+
* @returns Trigger response with diagnostic info (eventLogId, matched rules).
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* await erixClient.events.trigger({
|
|
147
|
+
* trigger: "webinar_joined",
|
|
148
|
+
* phone: "+919876543210",
|
|
149
|
+
* variables: { webinar_name: "AI Masterclass" },
|
|
150
|
+
* createLeadIfMissing: true
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
133
153
|
*/
|
|
134
154
|
async trigger(payload: TriggerPayload): Promise<TriggerResponse> {
|
|
135
155
|
return this.post<TriggerResponse>("/api/saas/workflows/trigger", payload);
|
package/src/resources/health.ts
CHANGED
|
@@ -36,7 +36,15 @@ export interface JobStatus {
|
|
|
36
36
|
|
|
37
37
|
export class Health extends APIResource {
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Perform a global platform health check.
|
|
40
|
+
* Verify that the API, database, and background workers are operational.
|
|
41
|
+
*
|
|
42
|
+
* @returns System health summary (status, version, uptime).
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const health = await erixClient.health.system();
|
|
46
|
+
* console.log(`API Status: ${health.status}`);
|
|
47
|
+
* ```
|
|
40
48
|
*/
|
|
41
49
|
async system(): Promise<SystemHealth> {
|
|
42
50
|
const res = await this.get<{ data: SystemHealth }>("/api/saas/health", {
|
|
@@ -54,10 +62,22 @@ export class Health extends APIResource {
|
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
/**
|
|
57
|
-
*
|
|
65
|
+
* Lookup the execution status of a background job.
|
|
66
|
+
*
|
|
67
|
+
* @param jobId - The unique ID of the background job.
|
|
68
|
+
* @returns Job status report (attempts, error trace, completion time).
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const status = await erixClient.health.jobStatus("job_123");
|
|
72
|
+
* if (status.status === "completed") {
|
|
73
|
+
* console.log("Job finished successfully!");
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
58
76
|
*/
|
|
59
77
|
async jobStatus(jobId: string): Promise<JobStatus> {
|
|
60
|
-
const res = await this.get<{ data: JobStatus }>(
|
|
78
|
+
const res = await this.get<{ data: JobStatus }>(
|
|
79
|
+
`/api/saas/jobs/status/${jobId}`,
|
|
80
|
+
);
|
|
61
81
|
return res.data;
|
|
62
82
|
}
|
|
63
83
|
}
|