@ecodrix/erix-api 1.1.4 → 1.1.6
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 +703 -92
- 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 +703 -92
- package/dist/ts/esm/index.d.ts +703 -92
- 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 +73 -15
- 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 +78 -10
- package/src/resources/whatsapp/messages.ts +18 -18
- package/src/resources/whatsapp/templates.ts +92 -18
|
@@ -7,42 +7,90 @@ export interface TemplateMapping {
|
|
|
7
7
|
|
|
8
8
|
export class Templates extends APIResource {
|
|
9
9
|
/**
|
|
10
|
-
* List all templates
|
|
10
|
+
* List all WhatsApp message templates in the tenant database.
|
|
11
|
+
*
|
|
12
|
+
* @param params - Optional filter parameters (status, mappingStatus, channel).
|
|
13
|
+
* @returns List of message templates.
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const templates = await erixClient.whatsapp.templates.list({ status: "APPROVED" });
|
|
17
|
+
* ```
|
|
11
18
|
*/
|
|
12
|
-
async list<T = any>(params?: {
|
|
19
|
+
async list<T = any>(params?: {
|
|
20
|
+
status?: string;
|
|
21
|
+
mappingStatus?: string;
|
|
22
|
+
channel?: string;
|
|
23
|
+
}) {
|
|
13
24
|
return this.get<T>("/api/saas/chat/templates", { params } as any);
|
|
14
25
|
}
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
|
-
* Synchronize templates from Meta API.
|
|
28
|
+
* Synchronize templates from the Meta WhatsApp Business API.
|
|
29
|
+
* This updates the local database with the latest template status and content from Meta.
|
|
30
|
+
*
|
|
31
|
+
* @returns Success status of the sync operation.
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* await erixClient.whatsapp.templates.sync();
|
|
35
|
+
* ```
|
|
18
36
|
*/
|
|
19
37
|
async sync<T = any>() {
|
|
20
38
|
return this.post<T>("/api/saas/chat/templates/sync", {});
|
|
21
39
|
}
|
|
22
40
|
|
|
23
41
|
/**
|
|
24
|
-
*
|
|
42
|
+
* Retrieve details of a specific WhatsApp template.
|
|
43
|
+
*
|
|
44
|
+
* @param templateIdentifier - The name or ID of the template.
|
|
45
|
+
* @returns Detailed template object including components and status.
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const template = await erixClient.whatsapp.templates.retrieve("welcome_message");
|
|
49
|
+
* ```
|
|
25
50
|
*/
|
|
26
51
|
async retrieve<T = any>(templateIdentifier: string) {
|
|
27
|
-
return this.get<T>(
|
|
52
|
+
return this.get<T>(
|
|
53
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateIdentifier)}`,
|
|
54
|
+
);
|
|
28
55
|
}
|
|
29
56
|
|
|
30
57
|
/**
|
|
31
|
-
* Create a new template manually.
|
|
58
|
+
* Create a new WhatsApp template manually (Draft).
|
|
59
|
+
*
|
|
60
|
+
* @param payload - Template configuration (name, category, language, components).
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* await erixClient.whatsapp.templates.create({
|
|
64
|
+
* name: "new_promotion",
|
|
65
|
+
* category: "MARKETING",
|
|
66
|
+
* language: "en_US",
|
|
67
|
+
* components: [...]
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
32
70
|
*/
|
|
33
71
|
async create<T = any>(payload: any) {
|
|
34
72
|
return this.post<T>("/api/saas/chat/templates", payload);
|
|
35
73
|
}
|
|
36
74
|
|
|
37
75
|
/**
|
|
38
|
-
* Update an existing template.
|
|
76
|
+
* Update an existing WhatsApp template.
|
|
77
|
+
*
|
|
78
|
+
* @param templateId - The unique ID of the template.
|
|
79
|
+
* @param payload - Updated template configuration.
|
|
39
80
|
*/
|
|
40
81
|
async update<T = any>(templateId: string, payload: any) {
|
|
41
82
|
return this.put<T>(`/api/saas/chat/templates/${templateId}`, payload);
|
|
42
83
|
}
|
|
43
84
|
|
|
44
85
|
/**
|
|
45
|
-
* Delete a template.
|
|
86
|
+
* Delete a WhatsApp template from both the local database and Meta (if specified).
|
|
87
|
+
*
|
|
88
|
+
* @param templateName - The name of the template to delete.
|
|
89
|
+
* @param force - If true, attempts to delete from Meta API as well.
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* await erixClient.whatsapp.templates.deleteTemplate("old_template", true);
|
|
93
|
+
* ```
|
|
46
94
|
*/
|
|
47
95
|
async deleteTemplate<T = any>(templateName: string, force?: boolean) {
|
|
48
96
|
return this.deleteRequest<T>(
|
|
@@ -51,21 +99,28 @@ export class Templates extends APIResource {
|
|
|
51
99
|
}
|
|
52
100
|
|
|
53
101
|
/**
|
|
54
|
-
* List
|
|
102
|
+
* List available configuration options for variable mapping.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const config = await erixClient.whatsapp.templates.mappingConfig();
|
|
107
|
+
* ```
|
|
55
108
|
*/
|
|
56
109
|
async mappingConfig<T = any>() {
|
|
57
110
|
return this.get<T>("/api/saas/chat/templates/mapping/config");
|
|
58
111
|
}
|
|
59
112
|
|
|
60
113
|
/**
|
|
61
|
-
* List CRM collections for variable mapping.
|
|
114
|
+
* List CRM collections available for variable mapping (Leads, Deals, etc.).
|
|
62
115
|
*/
|
|
63
116
|
async collections<T = any>() {
|
|
64
117
|
return this.get<T>("/api/saas/chat/templates/collections");
|
|
65
118
|
}
|
|
66
119
|
|
|
67
120
|
/**
|
|
68
|
-
* List
|
|
121
|
+
* List fields for a specific CRM collection to be used in mapping.
|
|
122
|
+
*
|
|
123
|
+
* @param collectionName - The name of the CRM collection.
|
|
69
124
|
*/
|
|
70
125
|
async collectionFields<T = any>(collectionName: string) {
|
|
71
126
|
return this.get<T>(
|
|
@@ -74,7 +129,10 @@ export class Templates extends APIResource {
|
|
|
74
129
|
}
|
|
75
130
|
|
|
76
131
|
/**
|
|
77
|
-
* Update variable mappings for a template.
|
|
132
|
+
* Update variable mappings for a template to automate personalization.
|
|
133
|
+
*
|
|
134
|
+
* @param templateName - Name of the template.
|
|
135
|
+
* @param payload - Mapping definitions.
|
|
78
136
|
*/
|
|
79
137
|
async updateMapping<T = any>(templateName: string, payload: TemplateMapping) {
|
|
80
138
|
return this.put<T>(
|
|
@@ -84,16 +142,30 @@ export class Templates extends APIResource {
|
|
|
84
142
|
}
|
|
85
143
|
|
|
86
144
|
/**
|
|
87
|
-
* Validate
|
|
145
|
+
* Validate if a template is ready for automated sending based on its mappings.
|
|
88
146
|
*/
|
|
89
147
|
async validate<T = any>(templateName: string) {
|
|
90
|
-
return this.get<T>(
|
|
148
|
+
return this.get<T>(
|
|
149
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateName)}/validate`,
|
|
150
|
+
);
|
|
91
151
|
}
|
|
92
152
|
|
|
93
153
|
/**
|
|
94
|
-
* Preview a template resolution.
|
|
154
|
+
* Preview a template resolution with sample data.
|
|
155
|
+
*
|
|
156
|
+
* @param templateName - Name of the template.
|
|
157
|
+
* @param context - Lead data or variable overrides for preview.
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const preview = await erixClient.whatsapp.templates.preview("welcome", {
|
|
161
|
+
* lead: { firstName: "Alice" }
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
95
164
|
*/
|
|
96
|
-
async preview<T = any>(
|
|
165
|
+
async preview<T = any>(
|
|
166
|
+
templateName: string,
|
|
167
|
+
context: { lead?: any; vars?: any },
|
|
168
|
+
) {
|
|
97
169
|
return this.post<T>(
|
|
98
170
|
`/api/saas/chat/templates/${encodeURIComponent(templateName)}/preview`,
|
|
99
171
|
{ context },
|
|
@@ -101,9 +173,11 @@ export class Templates extends APIResource {
|
|
|
101
173
|
}
|
|
102
174
|
|
|
103
175
|
/**
|
|
104
|
-
* Check
|
|
176
|
+
* Check which automations or sequences are currently using this template.
|
|
105
177
|
*/
|
|
106
178
|
async checkUsage<T = any>(templateName: string) {
|
|
107
|
-
return this.get<T>(
|
|
179
|
+
return this.get<T>(
|
|
180
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateName)}/usage`,
|
|
181
|
+
);
|
|
108
182
|
}
|
|
109
183
|
}
|