@ecodrix/erix-api 1.2.7 → 1.2.9
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/package.json +16 -19
- package/schema/openapi.yaml +0 -199
- package/src/cli.ts +0 -305
- package/src/core.ts +0 -359
- package/src/error.ts +0 -72
- package/src/index.ts +0 -34
- package/src/resource.ts +0 -93
- package/src/resources/crm/activities.ts +0 -122
- package/src/resources/crm/analytics.ts +0 -148
- package/src/resources/crm/automationDashboard.ts +0 -42
- package/src/resources/crm/automations.ts +0 -170
- package/src/resources/crm/index.ts +0 -34
- package/src/resources/crm/leads.ts +0 -458
- package/src/resources/crm/payments.ts +0 -27
- package/src/resources/crm/pipelines.ts +0 -197
- package/src/resources/crm/scoring.ts +0 -46
- package/src/resources/crm/sequences.ts +0 -51
- package/src/resources/email.ts +0 -142
- package/src/resources/events.ts +0 -189
- package/src/resources/health.ts +0 -84
- package/src/resources/logs.ts +0 -97
- package/src/resources/marketing.ts +0 -179
- package/src/resources/media.ts +0 -184
- package/src/resources/meet.ts +0 -163
- package/src/resources/notifications.ts +0 -178
- package/src/resources/queue.ts +0 -64
- package/src/resources/storage.ts +0 -101
- package/src/resources/webhooks.ts +0 -80
- package/src/resources/whatsapp/broadcasts.ts +0 -94
- package/src/resources/whatsapp/conversations.ts +0 -128
- package/src/resources/whatsapp/index.ts +0 -67
- package/src/resources/whatsapp/messages.ts +0 -239
- package/src/resources/whatsapp/templates.ts +0 -218
- package/src/types/metadata.ts +0 -71
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from "axios";
|
|
2
|
-
import { Activities } from "./activities";
|
|
3
|
-
import { Analytics } from "./analytics";
|
|
4
|
-
import { AutomationDashboard } from "./automationDashboard";
|
|
5
|
-
import { Automations } from "./automations";
|
|
6
|
-
import { Leads } from "./leads";
|
|
7
|
-
import { Payments } from "./payments";
|
|
8
|
-
import { Pipelines } from "./pipelines";
|
|
9
|
-
import { Scoring } from "./scoring";
|
|
10
|
-
import { Sequences } from "./sequences";
|
|
11
|
-
|
|
12
|
-
export class CRM {
|
|
13
|
-
public leads: Leads;
|
|
14
|
-
public pipelines: Pipelines;
|
|
15
|
-
public activities: Activities;
|
|
16
|
-
public analytics: Analytics;
|
|
17
|
-
public automations: Automations;
|
|
18
|
-
public sequences: Sequences;
|
|
19
|
-
public scoring: Scoring;
|
|
20
|
-
public payments: Payments;
|
|
21
|
-
public automationDashboard: AutomationDashboard;
|
|
22
|
-
|
|
23
|
-
constructor(client: AxiosInstance) {
|
|
24
|
-
this.leads = new Leads(client);
|
|
25
|
-
this.pipelines = new Pipelines(client);
|
|
26
|
-
this.activities = new Activities(client);
|
|
27
|
-
this.analytics = new Analytics(client);
|
|
28
|
-
this.automations = new Automations(client);
|
|
29
|
-
this.sequences = new Sequences(client);
|
|
30
|
-
this.scoring = new Scoring(client);
|
|
31
|
-
this.payments = new Payments(client);
|
|
32
|
-
this.automationDashboard = new AutomationDashboard(client);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
import type { ResourceManifest } from "../../types/metadata";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Valid statuses for a CRM Lead.
|
|
6
|
-
*/
|
|
7
|
-
export type LeadStatus = "new" | "contacted" | "qualified" | "won" | "lost" | "archived";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Common lead acquisition sources. Additional string values are allowed.
|
|
11
|
-
*/
|
|
12
|
-
export type LeadSource = "website" | "whatsapp" | "direct" | "referral" | string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Parameters for creating a new CRM Lead.
|
|
16
|
-
*/
|
|
17
|
-
export interface CreateLeadParams {
|
|
18
|
-
/** Lead's first name. Required. */
|
|
19
|
-
firstName: string;
|
|
20
|
-
/** Lead's last name. */
|
|
21
|
-
lastName?: string;
|
|
22
|
-
/** Lead's email address. */
|
|
23
|
-
email?: string;
|
|
24
|
-
/** Lead's phone number in E.164 format (e.g. "+919876543210"). */
|
|
25
|
-
phone?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Acquisition channel.
|
|
28
|
-
*/
|
|
29
|
-
source?: LeadSource;
|
|
30
|
-
/** Arbitrary key-value metadata (UTM params, order IDs, etc.). */
|
|
31
|
-
metadata?: Record<string, any>;
|
|
32
|
-
/** Pipeline ID to assign the lead */
|
|
33
|
-
pipelineId?: string;
|
|
34
|
-
/** Stage ID to assign the lead */
|
|
35
|
-
stageId?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Options for listing leads.
|
|
40
|
-
*/
|
|
41
|
-
export interface ListLeadsParams {
|
|
42
|
-
status?: LeadStatus;
|
|
43
|
-
pipelineId?: string;
|
|
44
|
-
stageId?: string;
|
|
45
|
-
source?: LeadSource;
|
|
46
|
-
assignedTo?: string;
|
|
47
|
-
tags?: string[] | string;
|
|
48
|
-
minScore?: number;
|
|
49
|
-
search?: string;
|
|
50
|
-
startDate?: string;
|
|
51
|
-
endDate?: string;
|
|
52
|
-
appointmentId?: string;
|
|
53
|
-
bookingId?: string;
|
|
54
|
-
orderId?: string;
|
|
55
|
-
meetingId?: string;
|
|
56
|
-
page?: number;
|
|
57
|
-
limit?: number;
|
|
58
|
-
sortBy?: string;
|
|
59
|
-
sortDir?: "asc" | "desc";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Options for upserting a lead.
|
|
64
|
-
*/
|
|
65
|
-
export interface UpsertLeadParams {
|
|
66
|
-
leadData: Partial<CreateLeadParams> & { phone: string; name?: string };
|
|
67
|
-
moduleInfo?: any;
|
|
68
|
-
trigger?: string;
|
|
69
|
-
pipelineId?: string;
|
|
70
|
-
stageId?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* CRM Lead resource — full lifecycle management.
|
|
75
|
-
*
|
|
76
|
-
* Access via `ecod.crm.leads`.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const { data: lead } = await ecod.crm.leads.create({
|
|
81
|
-
* firstName: "Alice",
|
|
82
|
-
* phone: "+919876543210",
|
|
83
|
-
* source: "website",
|
|
84
|
-
* });
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
export class Leads extends APIResource {
|
|
88
|
-
/**
|
|
89
|
-
* Create a new lead in the CRM pipeline.
|
|
90
|
-
*
|
|
91
|
-
* @param params - Lead creation parameters. `firstName` is required.
|
|
92
|
-
* @returns The newly created Lead document.
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const lead = await erixClient.crm.leads.create({
|
|
96
|
-
* firstName: "Alice",
|
|
97
|
-
* phone: "+919876543210",
|
|
98
|
-
* source: "website"
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
async create<T = any>(params: CreateLeadParams) {
|
|
103
|
-
return this.post<T>("/api/crm/leads", params);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Introspect the Leads resource and provide a "Blueprint" for UI generation.
|
|
108
|
-
*
|
|
109
|
-
* This method returns a list of all fields (standard + custom), their types,
|
|
110
|
-
* labels, and suggested UI controls. Erix React uses this to render SmartForms
|
|
111
|
-
* and tables dynamically.
|
|
112
|
-
*/
|
|
113
|
-
async describe(): Promise<ResourceManifest> {
|
|
114
|
-
// 1. Fetch custom fields from the tenant configuration
|
|
115
|
-
const customFieldsRes: any = await this.fields();
|
|
116
|
-
const customFields = Array.isArray(customFieldsRes.data) ? customFieldsRes.data : [];
|
|
117
|
-
|
|
118
|
-
// 2. Define the core system fields
|
|
119
|
-
const systemFields: any[] = [
|
|
120
|
-
{
|
|
121
|
-
key: "firstName",
|
|
122
|
-
label: "First Name",
|
|
123
|
-
type: "string",
|
|
124
|
-
required: true,
|
|
125
|
-
group: "Basic Info",
|
|
126
|
-
},
|
|
127
|
-
{ key: "lastName", label: "Last Name", type: "string", required: false, group: "Basic Info" },
|
|
128
|
-
{ key: "phone", label: "Phone Number", type: "phone", required: true, group: "Contact" },
|
|
129
|
-
{ key: "email", label: "Email Address", type: "email", required: false, group: "Contact" },
|
|
130
|
-
{
|
|
131
|
-
key: "status",
|
|
132
|
-
label: "Status",
|
|
133
|
-
type: "select",
|
|
134
|
-
required: true,
|
|
135
|
-
options: [
|
|
136
|
-
{ label: "New", value: "new" },
|
|
137
|
-
{ label: "Contacted", value: "contacted" },
|
|
138
|
-
{ label: "Qualified", value: "qualified" },
|
|
139
|
-
{ label: "Won", value: "won" },
|
|
140
|
-
{ label: "Lost", value: "lost" },
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{ key: "value", label: "Lead Value", type: "currency", required: false },
|
|
144
|
-
{ key: "source", label: "Source", type: "string", required: false },
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
// 3. Map custom fields to FieldManifest shape
|
|
148
|
-
const mappedCustom = customFields.map((f: any) => ({
|
|
149
|
-
key: `metadata.extra.${f.name}`,
|
|
150
|
-
label: f.label || f.name,
|
|
151
|
-
type: f.type || "string",
|
|
152
|
-
required: !!f.required,
|
|
153
|
-
options: f.options,
|
|
154
|
-
group: "Custom Fields",
|
|
155
|
-
}));
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
name: "Lead",
|
|
159
|
-
fields: [...systemFields, ...mappedCustom],
|
|
160
|
-
uiHints: {
|
|
161
|
-
icon: "User",
|
|
162
|
-
primaryColor: "#3b82f6",
|
|
163
|
-
defaultSort: { field: "createdAt", direction: "desc" },
|
|
164
|
-
summaryFields: ["firstName", "lastName", "phone", "status"],
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Upsert a lead by phone number. If a lead with the same phone exists,
|
|
171
|
-
* it will be updated; otherwise, a new lead is created.
|
|
172
|
-
*
|
|
173
|
-
* @param params - Upsert parameters containing leadData with a phone number.
|
|
174
|
-
* @returns The newly created or updated Lead document.
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* await erixClient.crm.leads.upsert({
|
|
178
|
-
* leadData: { phone: "+919876543210", firstName: "Alice" }
|
|
179
|
-
* });
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
async upsert<T = any>(params: UpsertLeadParams) {
|
|
183
|
-
return this.post<T>("/api/crm/leads/upsert", params);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Bulk ingest leads efficiently in parallel using automatic chunking.
|
|
188
|
-
* Prevents rate limit exhaustion by executing `chunkSize` requests at a time.
|
|
189
|
-
*
|
|
190
|
-
* @param leads - Array of leads to create.
|
|
191
|
-
* @param chunkSize - Number of leads to send concurrently (default: 50)
|
|
192
|
-
* @returns Array of created lead results.
|
|
193
|
-
*/
|
|
194
|
-
async createMany(leads: CreateLeadParams[], chunkSize = 50): Promise<any[]> {
|
|
195
|
-
const results: any[] = [];
|
|
196
|
-
|
|
197
|
-
for (let i = 0; i < leads.length; i += chunkSize) {
|
|
198
|
-
const chunk = leads.slice(i, i + chunkSize);
|
|
199
|
-
|
|
200
|
-
const chunkPromises = chunk.map((lead) => this.create(lead));
|
|
201
|
-
const chunkResults = await Promise.allSettled(chunkPromises);
|
|
202
|
-
|
|
203
|
-
for (const res of chunkResults) {
|
|
204
|
-
if (res.status === "fulfilled") {
|
|
205
|
-
results.push(res.value);
|
|
206
|
-
} else {
|
|
207
|
-
throw res.reason;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return results;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Bulk upsert (import) leads.
|
|
217
|
-
*
|
|
218
|
-
* @param leads - Array of leads to import.
|
|
219
|
-
*/
|
|
220
|
-
async import<T = any>(leads: Partial<CreateLeadParams>[]) {
|
|
221
|
-
return this.post<T>("/api/crm/leads/import", { leads });
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* List CRM leads with optional filtering and pagination.
|
|
226
|
-
*
|
|
227
|
-
* @param params - Filter options (status, source, pipelineId, page, limit, etc.)
|
|
228
|
-
* @returns Paginated list of Lead documents.
|
|
229
|
-
* @example
|
|
230
|
-
* ```typescript
|
|
231
|
-
* const leads = await erixClient.crm.leads.list({
|
|
232
|
-
* status: "new",
|
|
233
|
-
* source: "website",
|
|
234
|
-
* limit: 20
|
|
235
|
-
* });
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
238
|
-
async list<T = any>(params?: ListLeadsParams) {
|
|
239
|
-
const queryParams = { ...params } as any;
|
|
240
|
-
if (Array.isArray(queryParams.tags)) {
|
|
241
|
-
queryParams.tags = queryParams.tags.join(",");
|
|
242
|
-
}
|
|
243
|
-
return this.get<T>("/api/crm/leads", { params: queryParams } as any);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Auto-paginating iterator for leads.
|
|
248
|
-
* Seamlessly fetches leads page by page as you iterate.
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```typescript
|
|
252
|
-
* for await (const lead of ecod.crm.leads.listAutoPaging<Lead>()) {
|
|
253
|
-
* console.log(lead.firstName);
|
|
254
|
-
* }
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
257
|
-
async *listAutoPaging<T = any>(params?: ListLeadsParams): AsyncGenerator<T, void, unknown> {
|
|
258
|
-
let currentPage = params?.page || 1;
|
|
259
|
-
let hasMore = true;
|
|
260
|
-
|
|
261
|
-
while (hasMore) {
|
|
262
|
-
const response: any = await this.list<any>({
|
|
263
|
-
...params,
|
|
264
|
-
page: currentPage,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const items = Array.isArray(response.data) ? response.data : response || [];
|
|
268
|
-
|
|
269
|
-
if (items.length === 0) {
|
|
270
|
-
hasMore = false;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
for (const item of items) {
|
|
275
|
-
yield item as T;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (response.pagination && currentPage < response.pagination.pages) {
|
|
279
|
-
currentPage++;
|
|
280
|
-
} else if (!response.pagination && items.length > 0) {
|
|
281
|
-
// Fallback: If no explicit pagination struct, assume simple array and just keep pulling until empty
|
|
282
|
-
currentPage++;
|
|
283
|
-
} else {
|
|
284
|
-
hasMore = false;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Retrieve a single lead by its unique ID.
|
|
291
|
-
*
|
|
292
|
-
* @param leadId - The MongoDB ObjectId of the lead.
|
|
293
|
-
* @returns The Lead document, or a 404 error if not found.
|
|
294
|
-
* @example
|
|
295
|
-
* ```typescript
|
|
296
|
-
* const lead = await erixClient.crm.leads.retrieve("64abc...");
|
|
297
|
-
* ```
|
|
298
|
-
*/
|
|
299
|
-
async retrieve<T = any>(leadId: string) {
|
|
300
|
-
return this.get<T>(`/api/crm/leads/${leadId}`);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Retrieve a single lead by its phone number.
|
|
305
|
-
*
|
|
306
|
-
* @param phone - Lead's phone number.
|
|
307
|
-
*/
|
|
308
|
-
async retrieveByPhone<T = any>(phone: string) {
|
|
309
|
-
// URL-encode the phone to handle '+' safe
|
|
310
|
-
return this.get<T>(`/api/crm/leads/phone/${encodeURIComponent(phone)}`);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Retrieve a single lead by a reference key and value.
|
|
315
|
-
*
|
|
316
|
-
* @param refKey - Reference key metadata.
|
|
317
|
-
* @param refValue - Reference value.
|
|
318
|
-
*/
|
|
319
|
-
async retrieveByRef<T = any>(refKey: string, refValue: string) {
|
|
320
|
-
return this.get<T>(
|
|
321
|
-
`/api/crm/leads/ref/${encodeURIComponent(refKey)}/${encodeURIComponent(refValue)}`,
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Update the fields of an existing lead.
|
|
327
|
-
*
|
|
328
|
-
* @param leadId - The ID of the lead to update.
|
|
329
|
-
* @param params - Partial lead fields to update.
|
|
330
|
-
* @returns The updated Lead document.
|
|
331
|
-
* @example
|
|
332
|
-
* ```typescript
|
|
333
|
-
* await erixClient.crm.leads.update("64abc...", {
|
|
334
|
-
* lastName: "Smith",
|
|
335
|
-
* status: "qualified"
|
|
336
|
-
* });
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
async update<T = any>(leadId: string, params: Partial<CreateLeadParams>) {
|
|
340
|
-
return this.patch<T>(`/api/crm/leads/${leadId}`, params);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Move a lead to a new stage in a pipeline.
|
|
345
|
-
*
|
|
346
|
-
* @param leadId - ID of the lead.
|
|
347
|
-
* @param stageId - Target stage ID.
|
|
348
|
-
*/
|
|
349
|
-
async move<T = any>(leadId: string, stageId: string) {
|
|
350
|
-
return this.patch<T>(`/api/crm/leads/${leadId}/move`, { stageId });
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Convert a lead (mark as won or lost with reason).
|
|
355
|
-
*
|
|
356
|
-
* @param leadId - ID of the lead.
|
|
357
|
-
* @param outcome - "won" | "lost"
|
|
358
|
-
* @param reason - Reason for the outcome.
|
|
359
|
-
*/
|
|
360
|
-
async convert<T = any>(leadId: string, outcome: "won" | "lost", reason?: string) {
|
|
361
|
-
return this.post<T>(`/api/crm/leads/${leadId}/convert`, {
|
|
362
|
-
outcome,
|
|
363
|
-
reason,
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Update the tags of a lead.
|
|
369
|
-
*
|
|
370
|
-
* @param leadId - ID of the lead.
|
|
371
|
-
* @param options - Tags to add or remove.
|
|
372
|
-
*/
|
|
373
|
-
async tags<T = any>(leadId: string, options: { add?: string[]; remove?: string[] }) {
|
|
374
|
-
return this.patch<T>(`/api/crm/leads/${leadId}/tags`, options);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Recalculate lead score based on activities and interactions.
|
|
379
|
-
*
|
|
380
|
-
* @param leadId - ID of the lead.
|
|
381
|
-
*/
|
|
382
|
-
async recalculateScore<T = any>(leadId: string) {
|
|
383
|
-
return this.post<T>(`/api/crm/leads/${leadId}/score`, {});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Update embedded metadata/references of a lead without touching core fields.
|
|
388
|
-
*
|
|
389
|
-
* @param leadId - ID of the lead.
|
|
390
|
-
* @param metadata - Metadata object indicating { refs, extra }
|
|
391
|
-
*/
|
|
392
|
-
async updateMetadata<T = any>(
|
|
393
|
-
leadId: string,
|
|
394
|
-
metadata: { refs?: Record<string, any>; extra?: Record<string, any> },
|
|
395
|
-
) {
|
|
396
|
-
return this.patch<T>(`/api/crm/leads/${leadId}/metadata`, metadata);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Introspect available custom fields configured by the tenant limit.
|
|
401
|
-
*/
|
|
402
|
-
async fields<T = any>() {
|
|
403
|
-
return this.get<T>("/api/crm/leads/fields");
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* List all notes for a specific lead.
|
|
408
|
-
*/
|
|
409
|
-
async notes<T = any>(leadId: string) {
|
|
410
|
-
return this.get<T>(`/api/crm/leads/${leadId}/notes`);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Retrieve the complete chronological timeline for a lead.
|
|
415
|
-
*/
|
|
416
|
-
async activities<T = any>(leadId: string, params?: { page?: number; limit?: number }) {
|
|
417
|
-
return this.get<T>(`/api/crm/leads/${leadId}/timeline`, { params } as any);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Add a note to a lead.
|
|
422
|
-
*/
|
|
423
|
-
async createNote<T = any>(leadId: string, params: { content: string }) {
|
|
424
|
-
return this.post<T>(`/api/crm/leads/${leadId}/notes`, params);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Update an existing note.
|
|
429
|
-
*/
|
|
430
|
-
async updateNote<T = any>(leadId: string, noteId: string, params: { content: string }) {
|
|
431
|
-
return this.patch<T>(`/api/crm/notes/${noteId}`, params);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Delete a note.
|
|
436
|
-
*/
|
|
437
|
-
async deleteNote<T = any>(leadId: string, noteId: string) {
|
|
438
|
-
return this.deleteRequest(`/api/crm/notes/${noteId}`);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Archive (soft-delete) a single lead.
|
|
443
|
-
*
|
|
444
|
-
* @param leadId - The ID of the lead to archive.
|
|
445
|
-
*/
|
|
446
|
-
async delete(leadId: string) {
|
|
447
|
-
return this.deleteRequest(`/api/crm/leads/${leadId}`);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Bulk archive multiple leads.
|
|
452
|
-
*
|
|
453
|
-
* @param ids - Array of lead IDs to archive.
|
|
454
|
-
*/
|
|
455
|
-
async bulkDelete(ids: string[]) {
|
|
456
|
-
return this.deleteRequest("/api/crm/leads", { data: { ids } });
|
|
457
|
-
}
|
|
458
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
|
|
3
|
-
export class Payments extends APIResource {
|
|
4
|
-
/**
|
|
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
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
async capture<T = any>(payload: {
|
|
19
|
-
leadId: string;
|
|
20
|
-
amount: number;
|
|
21
|
-
currency?: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
appointmentId?: string;
|
|
24
|
-
}) {
|
|
25
|
-
return this.post<T>("/api/crm/payments/capture", payload);
|
|
26
|
-
}
|
|
27
|
-
}
|