@rempays/shared-core 1.0.2-beta.17 → 1.0.2-beta.19

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.
@@ -23,11 +23,7 @@ export declare class FacebookApi {
23
23
  static listTemplates(wabaId: string): Promise<any>;
24
24
  static createTemplate(params: CreateTemplateParams): Promise<any>;
25
25
  static deleteTemplate(wabaId: string, name: string): Promise<any>;
26
- /**
27
- * Updates the business profile picture using a direct URL.
28
- * @param url Public URL of the image
29
- */
30
- static updateProfilePicture(url: string): Promise<any>;
26
+ static updateBusinessProfile(params: BusinessProfileParams): Promise<any>;
31
27
  /**
32
28
  * Uploads media for chat (messages).
33
29
  * @param buffer Media binary data
@@ -39,7 +35,6 @@ export declare class FacebookApi {
39
35
  static getBusinessProfile(): Promise<{
40
36
  data: BusinessProfileResponse[];
41
37
  }>;
42
- static updateBusinessProfile(params: BusinessProfileParams): Promise<any>;
43
38
  static updateDisplayName(params: UpdateDisplayNameParams): Promise<any>;
44
39
  static getDisplayNameStatus(): Promise<DisplayNameStatusResponse>;
45
40
  }
@@ -36,6 +36,10 @@ class FacebookApi {
36
36
  await this.init();
37
37
  const url = `https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/${path}`;
38
38
  try {
39
+ console.log("[layer-core/facebook-api] Sending message", {
40
+ url,
41
+ payload,
42
+ });
39
43
  const http = (0, http_1.getHttpClient)(this.token);
40
44
  const { data } = await http.post(url, payload);
41
45
  return data;
@@ -48,8 +52,8 @@ class FacebookApi {
48
52
  }
49
53
  }
50
54
  /*
51
- TEXT
52
- */
55
+ TEXT
56
+ */
53
57
  static async sendText(params) {
54
58
  const payload = {
55
59
  messaging_product: "whatsapp",
@@ -64,8 +68,8 @@ class FacebookApi {
64
68
  return await this.post("messages", payload);
65
69
  }
66
70
  /*
67
- TEMPLATE
68
- */
71
+ TEMPLATE
72
+ */
69
73
  static async sendTemplate(params) {
70
74
  const payload = {
71
75
  messaging_product: "whatsapp",
@@ -80,8 +84,8 @@ class FacebookApi {
80
84
  return await this.post("messages", payload);
81
85
  }
82
86
  /*
83
- BUTTONS
84
- */
87
+ BUTTONS
88
+ */
85
89
  static async sendInteractiveButtons(params) {
86
90
  const payload = {
87
91
  messaging_product: "whatsapp",
@@ -103,8 +107,8 @@ class FacebookApi {
103
107
  return await this.post("messages", payload);
104
108
  }
105
109
  /*
106
- LIST
107
- */
110
+ LIST
111
+ */
108
112
  static async sendInteractiveList(params) {
109
113
  const payload = {
110
114
  messaging_product: "whatsapp",
@@ -135,8 +139,8 @@ class FacebookApi {
135
139
  return await this.post("messages", payload);
136
140
  }
137
141
  /*
138
- IMAGE
139
- */
142
+ IMAGE
143
+ */
140
144
  static async sendImage(params) {
141
145
  const payload = {
142
146
  messaging_product: "whatsapp",
@@ -145,14 +149,14 @@ class FacebookApi {
145
149
  image: {
146
150
  link: params.link,
147
151
  id: params.id,
148
- caption: params.caption
152
+ caption: params.caption,
149
153
  },
150
154
  };
151
155
  return await this.post("messages", payload);
152
156
  }
153
157
  /*
154
- DOCUMENT
155
- */
158
+ DOCUMENT
159
+ */
156
160
  static async sendDocument(params) {
157
161
  const payload = {
158
162
  messaging_product: "whatsapp",
@@ -168,8 +172,8 @@ class FacebookApi {
168
172
  return await this.post("messages", payload);
169
173
  }
170
174
  /*
171
- AUDIO (NEW)
172
- */
175
+ AUDIO (NEW)
176
+ */
173
177
  static async sendAudio(params) {
174
178
  const payload = {
175
179
  messaging_product: "whatsapp",
@@ -183,8 +187,8 @@ class FacebookApi {
183
187
  return await this.post("messages", payload);
184
188
  }
185
189
  /*
186
- VIDEO (NEW)
187
- */
190
+ VIDEO (NEW)
191
+ */
188
192
  static async sendVideo(params) {
189
193
  const payload = {
190
194
  messaging_product: "whatsapp",
@@ -199,8 +203,8 @@ class FacebookApi {
199
203
  return await this.post("messages", payload);
200
204
  }
201
205
  /*
202
- LOCATION
203
- */
206
+ LOCATION
207
+ */
204
208
  static async sendLocation(params) {
205
209
  const payload = {
206
210
  messaging_product: "whatsapp",
@@ -216,8 +220,8 @@ class FacebookApi {
216
220
  return await this.post("messages", payload);
217
221
  }
218
222
  /*
219
- TYPING
220
- */
223
+ TYPING
224
+ */
221
225
  static async setTyping(params) {
222
226
  const payload = {
223
227
  messaging_product: "whatsapp",
@@ -228,8 +232,8 @@ class FacebookApi {
228
232
  return await this.post("messages", payload);
229
233
  }
230
234
  /*
231
- READ
232
- */
235
+ READ
236
+ */
233
237
  static async markAsRead(params) {
234
238
  const payload = {
235
239
  messaging_product: "whatsapp",
@@ -239,8 +243,8 @@ class FacebookApi {
239
243
  return await this.post("messages", payload);
240
244
  }
241
245
  /*
242
- MEDIA INFO (NEW)
243
- */
246
+ MEDIA INFO (NEW)
247
+ */
244
248
  static async getMediaInfo(mediaId) {
245
249
  await this.init();
246
250
  const http = (0, http_1.getHttpClient)(this.token);
@@ -249,8 +253,8 @@ class FacebookApi {
249
253
  return data;
250
254
  }
251
255
  /*
252
- DOWNLOAD MEDIA (NEW)
253
- */
256
+ DOWNLOAD MEDIA (NEW)
257
+ */
254
258
  static async downloadMedia(mediaId) {
255
259
  await this.init();
256
260
  const media = await this.getMediaInfo(mediaId);
@@ -261,8 +265,8 @@ class FacebookApi {
261
265
  return data;
262
266
  }
263
267
  /*
264
- GOOGLE MAP URL (NEW)
265
- */
268
+ GOOGLE MAP URL (NEW)
269
+ */
266
270
  static buildGoogleMapsUrl(latitude, longitude) {
267
271
  return `https://www.google.com/maps?q=${latitude},${longitude}`;
268
272
  }
@@ -284,9 +288,9 @@ class FacebookApi {
284
288
  components: [
285
289
  {
286
290
  type: "BODY",
287
- text: params.bodyText
288
- }
289
- ]
291
+ text: params.bodyText,
292
+ },
293
+ ],
290
294
  };
291
295
  const { data } = await http.post(url, payload);
292
296
  return data;
@@ -296,25 +300,20 @@ class FacebookApi {
296
300
  const http = (0, http_1.getHttpClient)(this.token);
297
301
  const url = `https://graph.facebook.com/${this.apiVersion}/${wabaId}/message_templates`;
298
302
  const { data } = await http.delete(url, {
299
- params: { name }
303
+ params: { name },
300
304
  });
301
305
  return data;
302
306
  }
303
- /*
304
- PROFILE PICTURE UPLOAD (TWO-STEP)
305
- */
306
- /**
307
- * Updates the business profile picture using a direct URL.
308
- * @param url Public URL of the image
309
- */
310
- static async updateProfilePicture(url) {
311
- return await this.updateBusinessProfile({
312
- profile_picture_url: url
313
- });
307
+ static async updateBusinessProfile(params) {
308
+ const payload = {
309
+ messaging_product: "whatsapp",
310
+ ...params,
311
+ };
312
+ return await this.post("whatsapp_business_profile", payload);
314
313
  }
315
314
  /*
316
- CHAT MEDIA UPLOAD
317
- */
315
+ CHAT MEDIA UPLOAD
316
+ */
318
317
  /**
319
318
  * Uploads media for chat (messages).
320
319
  * @param buffer Media binary data
@@ -326,19 +325,19 @@ class FacebookApi {
326
325
  const url = `https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/media`;
327
326
  const formData = new FormData();
328
327
  const blob = new Blob([buffer], { type: mimeType });
329
- formData.append('file', blob, 'media');
330
- formData.append('type', mimeType);
331
- formData.append('messaging_product', 'whatsapp');
328
+ formData.append("file", blob, "media");
329
+ formData.append("type", mimeType);
330
+ formData.append("messaging_product", "whatsapp");
332
331
  const { data } = await http.post(url, formData, {
333
332
  headers: {
334
- 'Content-Type': 'multipart/form-data'
335
- }
333
+ "Content-Type": "multipart/form-data",
334
+ },
336
335
  });
337
336
  return data; // Returns { id: "media_id" }
338
337
  }
339
338
  /*
340
- BUSINESS PROFILE
341
- */
339
+ BUSINESS PROFILE
340
+ */
342
341
  static async getBusinessProfile() {
343
342
  await this.init();
344
343
  const http = (0, http_1.getHttpClient)(this.token);
@@ -349,16 +348,9 @@ class FacebookApi {
349
348
  // Returning the full structure { data: [ ... ] } as requested
350
349
  return data;
351
350
  }
352
- static async updateBusinessProfile(params) {
353
- const payload = {
354
- messaging_product: "whatsapp",
355
- ...params
356
- };
357
- return await this.post("whatsapp_business_profile", payload);
358
- }
359
351
  /*
360
- DISPLAY NAME
361
- */
352
+ DISPLAY NAME
353
+ */
362
354
  static async updateDisplayName(params) {
363
355
  await this.init();
364
356
  const http = (0, http_1.getHttpClient)(this.token);
@@ -366,8 +358,8 @@ class FacebookApi {
366
358
  const url = `https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}`;
367
359
  const { data } = await http.post(url, null, {
368
360
  params: {
369
- new_display_name: params.new_display_name
370
- }
361
+ new_display_name: params.new_display_name,
362
+ },
371
363
  });
372
364
  return data;
373
365
  }
@@ -378,8 +370,8 @@ class FacebookApi {
378
370
  const url = `https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}`;
379
371
  const { data } = await http.get(url, {
380
372
  params: {
381
- fields: "verified_name,name_status,new_display_name,new_name_status"
382
- }
373
+ fields: "verified_name,name_status,new_display_name,new_name_status",
374
+ },
383
375
  });
384
376
  return data;
385
377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rempays/shared-core",
3
- "version": "1.0.2-beta.17",
3
+ "version": "1.0.2-beta.19",
4
4
  "description": "Core utilities layer for RemPays platform with AWS services integration (Cognito, S3, Secrets Manager, Textract, Facebook API, DynamoDB)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",