@ecodrix/erix-api 1.0.9 → 1.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodrix/erix-api",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
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.",
@@ -71,6 +71,7 @@
71
71
  "format": "biome format --write .",
72
72
  "check": "biome check --write .",
73
73
  "publish:latest": "pnpm build:final && pnpm publish --access public --no-git-checks --tag latest",
74
- "publish:beta": "pnpm build:final && pnpm publish --access public --no-git-checks --tag beta"
74
+ "publish:beta": "pnpm build:final && pnpm publish --access public --no-git-checks --tag beta",
75
+ "publish:patch": "pnpm build:final && pnpm publish --access public --no-git-checks --tag patch"
75
76
  }
76
77
  }
@@ -171,4 +171,32 @@ export class Messages extends APIResource {
171
171
  async markRead(conversationId: string) {
172
172
  return this.post(`/api/saas/chat/conversations/${conversationId}/read`);
173
173
  }
174
+
175
+ /**
176
+ * Upload a media file for WhatsApp chat.
177
+ *
178
+ * This is the recommended way to upload media for WhatsApp chatting as it
179
+ * allows the backend to perform WhatsApp-specific optimizations (resizing,
180
+ * format conversion, and thumbnail generation).
181
+ *
182
+ * @param file - The file to upload (File, Blob, or Buffer).
183
+ * @returns The uploaded media details `{ url, type }`.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const file = input.files[0];
188
+ * const { data } = await ecod.whatsapp.messages.upload(file);
189
+ * console.log(data.url); // -> https://cdn.ecodrix.com/tenants/ABC/chat/chat_123.jpg
190
+ * ```
191
+ */
192
+ async upload<T = { url: string; type: string }>(file: any): Promise<{ success: boolean; data: T }> {
193
+ const formData = new FormData();
194
+ formData.append("file", file);
195
+
196
+ return this.post<{ success: boolean; data: T }>("/api/saas/chat/upload", formData, {
197
+ headers: {
198
+ "Content-Type": "multipart/form-data",
199
+ },
200
+ });
201
+ }
174
202
  }