@ecodrix/erix-api 1.0.3 → 1.0.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/README.md +540 -241
- package/dist/cli.js +3 -3
- package/dist/index.d.cts +1597 -1489
- package/dist/index.d.ts +760 -760
- package/dist/ts/browser/index.global.js +5 -5
- 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 +760 -760
- package/dist/ts/esm/index.d.ts +760 -760
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +12 -12
- package/src/cli.ts +18 -31
- package/src/core.ts +12 -16
- package/src/index.ts +18 -20
- package/src/resource.ts +6 -25
- package/src/resources/crm/activities.ts +1 -1
- package/src/resources/crm/automations.ts +9 -3
- package/src/resources/crm/index.ts +6 -6
- package/src/resources/crm/leads.ts +20 -15
- package/src/resources/crm/payments.ts +7 -1
- package/src/resources/crm/pipelines.ts +3 -1
- package/src/resources/crm/sequences.ts +5 -1
- package/src/resources/email.ts +2 -5
- package/src/resources/events.ts +12 -3
- package/src/resources/health.ts +3 -1
- package/src/resources/marketing.ts +8 -1
- package/src/resources/media.ts +1 -4
- package/src/resources/meet.ts +4 -1
- package/src/resources/webhooks.ts +3 -8
- package/src/resources/whatsapp/conversations.ts +8 -3
- package/src/resources/whatsapp/index.ts +4 -6
- package/src/resources/whatsapp/templates.ts +14 -4
|
@@ -32,7 +32,14 @@ export class Campaigns extends APIResource {
|
|
|
32
32
|
/**
|
|
33
33
|
* Create a new campaign.
|
|
34
34
|
*/
|
|
35
|
-
async create<T = any>(payload: {
|
|
35
|
+
async create<T = any>(payload: {
|
|
36
|
+
name: string;
|
|
37
|
+
type: string;
|
|
38
|
+
subject?: string;
|
|
39
|
+
html?: string;
|
|
40
|
+
templateId?: string;
|
|
41
|
+
recipients?: string[];
|
|
42
|
+
}) {
|
|
36
43
|
return this.post<T>("/api/saas/marketing/campaigns", payload);
|
|
37
44
|
}
|
|
38
45
|
|
package/src/resources/media.ts
CHANGED
|
@@ -155,10 +155,7 @@ export class MediaResource extends APIResource {
|
|
|
155
155
|
*/
|
|
156
156
|
async upload(file: any, options: UploadOptions): Promise<any> {
|
|
157
157
|
// Step 1: Get presigned URL
|
|
158
|
-
const { data: presignedData } = await this.client.post(
|
|
159
|
-
"/api/saas/storage/upload-url",
|
|
160
|
-
options,
|
|
161
|
-
);
|
|
158
|
+
const { data: presignedData } = await this.client.post("/api/saas/storage/upload-url", options);
|
|
162
159
|
const { uploadUrl, key } = presignedData;
|
|
163
160
|
|
|
164
161
|
// Step 2: Upload directly to R2 (bypasses the API server for performance)
|
package/src/resources/meet.ts
CHANGED
|
@@ -140,7 +140,10 @@ export class Meetings extends APIResource {
|
|
|
140
140
|
/**
|
|
141
141
|
* Reschedule an existing meeting. Provides explicit method for time modifications.
|
|
142
142
|
*/
|
|
143
|
-
async reschedule<T = any>(
|
|
143
|
+
async reschedule<T = any>(
|
|
144
|
+
meetingId: string,
|
|
145
|
+
params: { startTime: Date | string; endTime: Date | string; duration?: number },
|
|
146
|
+
) {
|
|
144
147
|
return this.patch<T>(`/api/saas/meet/${meetingId}`, params);
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -44,7 +44,7 @@ export class Webhooks {
|
|
|
44
44
|
public async constructEvent(
|
|
45
45
|
payload: string | Buffer,
|
|
46
46
|
signature: string | string[] | undefined,
|
|
47
|
-
secret: string
|
|
47
|
+
secret: string,
|
|
48
48
|
): Promise<any> {
|
|
49
49
|
if (!signature) {
|
|
50
50
|
throw new WebhookSignatureError("No webhook signature provided");
|
|
@@ -63,10 +63,7 @@ export class Webhooks {
|
|
|
63
63
|
const hmac = crypto.createHmac("sha256", secret);
|
|
64
64
|
const digest = hmac.update(payload).digest("hex");
|
|
65
65
|
|
|
66
|
-
const isValid = crypto.timingSafeEqual(
|
|
67
|
-
Buffer.from(digest),
|
|
68
|
-
Buffer.from(sig)
|
|
69
|
-
);
|
|
66
|
+
const isValid = crypto.timingSafeEqual(Buffer.from(digest), Buffer.from(sig));
|
|
70
67
|
|
|
71
68
|
if (!isValid) {
|
|
72
69
|
throw new WebhookSignatureError("Invalid webhook signature provided");
|
|
@@ -77,9 +74,7 @@ export class Webhooks {
|
|
|
77
74
|
if (error instanceof WebhookSignatureError) {
|
|
78
75
|
throw error;
|
|
79
76
|
}
|
|
80
|
-
throw new WebhookSignatureError(
|
|
81
|
-
`Webhook payload parsing failed: ${error.message}`
|
|
82
|
-
);
|
|
77
|
+
throw new WebhookSignatureError(`Webhook payload parsing failed: ${error.message}`);
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
80
|
}
|
|
@@ -17,7 +17,7 @@ export class Conversations extends APIResource {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new conversation explicitly.
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* @param params - Conversation details.
|
|
22
22
|
*/
|
|
23
23
|
async create<T = any>(params: { phone: string; name?: string }) {
|
|
@@ -35,14 +35,19 @@ export class Conversations extends APIResource {
|
|
|
35
35
|
* Get messages for a specific conversation.
|
|
36
36
|
*/
|
|
37
37
|
async messages<T = any>(conversationId: string, params?: ListParams) {
|
|
38
|
-
return this.get<T>(`/api/saas/chat/conversations/${conversationId}/messages`, {
|
|
38
|
+
return this.get<T>(`/api/saas/chat/conversations/${conversationId}/messages`, {
|
|
39
|
+
params,
|
|
40
|
+
} as any);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* Link a conversation to a lead.
|
|
43
45
|
*/
|
|
44
46
|
async linkLead<T = any>(conversationId: string, leadId: string, leadData?: any) {
|
|
45
|
-
return this.post<T>(`/api/saas/chat/conversations/${conversationId}/link-lead`, {
|
|
47
|
+
return this.post<T>(`/api/saas/chat/conversations/${conversationId}/link-lead`, {
|
|
48
|
+
leadId,
|
|
49
|
+
leadData,
|
|
50
|
+
});
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
1
2
|
import { APIResource } from "../../resource";
|
|
2
|
-
import { Messages } from "./messages";
|
|
3
|
-
import { Conversations } from "./conversations";
|
|
4
3
|
import { Broadcasts } from "./broadcasts";
|
|
4
|
+
import { Conversations } from "./conversations";
|
|
5
|
+
import { Messages } from "./messages";
|
|
5
6
|
import { Templates } from "./templates";
|
|
6
|
-
import type { AxiosInstance } from "axios";
|
|
7
7
|
|
|
8
8
|
export interface SendTemplatePayload {
|
|
9
9
|
/** Phone number in E.164 format. */
|
|
@@ -40,9 +40,7 @@ export class WhatsApp extends APIResource {
|
|
|
40
40
|
form.append("file", file, filename);
|
|
41
41
|
return this.post<T>("/api/saas/whatsapp/upload", form, {
|
|
42
42
|
headers:
|
|
43
|
-
typeof (form as any).getHeaders === "function"
|
|
44
|
-
? (form as any).getHeaders()
|
|
45
|
-
: undefined,
|
|
43
|
+
typeof (form as any).getHeaders === "function" ? (form as any).getHeaders() : undefined,
|
|
46
44
|
});
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -45,7 +45,9 @@ export class Templates extends APIResource {
|
|
|
45
45
|
* Delete a template.
|
|
46
46
|
*/
|
|
47
47
|
async deleteTemplate<T = any>(templateName: string, force?: boolean) {
|
|
48
|
-
return this.deleteRequest<T>(
|
|
48
|
+
return this.deleteRequest<T>(
|
|
49
|
+
`/api/saas/whatsapp/templates/${encodeURIComponent(templateName)}${force ? "?force=true" : ""}`,
|
|
50
|
+
);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -66,14 +68,19 @@ export class Templates extends APIResource {
|
|
|
66
68
|
* List CRM fields for a collection.
|
|
67
69
|
*/
|
|
68
70
|
async collectionFields<T = any>(collectionName: string) {
|
|
69
|
-
return this.get<T>(
|
|
71
|
+
return this.get<T>(
|
|
72
|
+
`/api/saas/whatsapp/templates/collections/${encodeURIComponent(collectionName)}/fields`,
|
|
73
|
+
);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
77
|
* Update variable mappings for a template.
|
|
74
78
|
*/
|
|
75
79
|
async updateMapping<T = any>(templateName: string, payload: TemplateMapping) {
|
|
76
|
-
return this.put<T>(
|
|
80
|
+
return this.put<T>(
|
|
81
|
+
`/api/saas/whatsapp/templates/${encodeURIComponent(templateName)}/mapping`,
|
|
82
|
+
payload,
|
|
83
|
+
);
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
/**
|
|
@@ -87,7 +94,10 @@ export class Templates extends APIResource {
|
|
|
87
94
|
* Preview a template resolution.
|
|
88
95
|
*/
|
|
89
96
|
async preview<T = any>(templateName: string, context: { lead?: any; vars?: any }) {
|
|
90
|
-
return this.post<T>(
|
|
97
|
+
return this.post<T>(
|
|
98
|
+
`/api/saas/whatsapp/templates/${encodeURIComponent(templateName)}/preview`,
|
|
99
|
+
{ context },
|
|
100
|
+
);
|
|
91
101
|
}
|
|
92
102
|
|
|
93
103
|
/**
|