meta-cloud-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.
Files changed (205) hide show
  1. package/dist/{common-CvPVD1o6.d.ts → api/flow/types/common.d.ts} +2 -2
  2. package/dist/{common-CvPVD1o6.d.ts.map → api/flow/types/common.d.ts.map} +1 -1
  3. package/dist/api/flow/types/common.js +51 -0
  4. package/dist/{common-C6FXBDm7.js.map → api/flow/types/common.js.map} +1 -1
  5. package/dist/api/flow/types/index.d.ts +1 -0
  6. package/dist/api/flow/types/index.js +1 -0
  7. package/dist/api/media/types/common.d.ts +32 -0
  8. package/dist/api/media/types/common.d.ts.map +1 -0
  9. package/dist/api/media/types/index.d.ts +1 -0
  10. package/dist/api/messages/types/common.d.ts +99 -0
  11. package/dist/api/messages/types/common.d.ts.map +1 -0
  12. package/dist/api/messages/types/contact.d.ts +54 -0
  13. package/dist/api/messages/types/contact.d.ts.map +1 -0
  14. package/dist/api/messages/types/index.d.ts +8 -0
  15. package/dist/api/messages/types/interactive.d.ts +182 -0
  16. package/dist/api/messages/types/interactive.d.ts.map +1 -0
  17. package/dist/api/messages/types/location.d.ts +16 -0
  18. package/dist/api/messages/types/location.d.ts.map +1 -0
  19. package/dist/api/messages/types/media.d.ts +55 -0
  20. package/dist/api/messages/types/media.d.ts.map +1 -0
  21. package/dist/api/messages/types/reaction.d.ts +17 -0
  22. package/dist/api/messages/types/reaction.d.ts.map +1 -0
  23. package/dist/api/messages/types/template.d.ts +72 -0
  24. package/dist/api/messages/types/template.d.ts.map +1 -0
  25. package/dist/api/messages/types/text.d.ts +17 -0
  26. package/dist/api/messages/types/text.d.ts.map +1 -0
  27. package/dist/api/phone/types/common.d.ts +83 -0
  28. package/dist/api/phone/types/common.d.ts.map +1 -0
  29. package/dist/api/phone/types/index.d.ts +1 -0
  30. package/dist/api/profile/types/common.d.ts +149 -0
  31. package/dist/api/profile/types/common.d.ts.map +1 -0
  32. package/dist/api/profile/types/index.d.ts +2 -0
  33. package/dist/api/profile/types/upload.d.ts +73 -0
  34. package/dist/api/profile/types/upload.d.ts.map +1 -0
  35. package/dist/api/qrCode/types/common.d.ts +28 -0
  36. package/dist/api/qrCode/types/common.d.ts.map +1 -0
  37. package/dist/api/qrCode/types/index.d.ts +1 -0
  38. package/dist/api/template/types/common.d.ts +155 -0
  39. package/dist/api/template/types/common.d.ts.map +1 -0
  40. package/dist/api/template/types/factory.d.ts +202 -0
  41. package/dist/api/template/types/factory.d.ts.map +1 -0
  42. package/dist/api/template/types/index.d.ts +2 -0
  43. package/dist/{index-CeTmbIXi.d.ts → api/waba/types/common.d.ts} +3 -61
  44. package/dist/api/waba/types/common.d.ts.map +1 -0
  45. package/dist/api/waba/types/common.js +44 -0
  46. package/dist/api/waba/types/common.js.map +1 -0
  47. package/dist/api/waba/types/index.d.ts +1 -0
  48. package/dist/api/waba/types/index.js +1 -0
  49. package/dist/chunk-PECeCxCb.js +15 -0
  50. package/dist/client.d.ts +25 -0
  51. package/dist/client.js +6 -0
  52. package/dist/{WebhookProcessor-Dq2Pa2cY.d.ts → core/webhook/types.d.ts} +74 -55
  53. package/dist/core/webhook/types.d.ts.map +1 -0
  54. package/dist/{base-CfDkvT1x.d.ts → enums.d.ts} +3 -142
  55. package/dist/enums.d.ts.map +1 -0
  56. package/dist/enums.js +681 -0
  57. package/dist/enums.js.map +1 -0
  58. package/dist/index.d.ts +4386 -21
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +3436 -1
  61. package/dist/index.js.map +1 -1
  62. package/dist/types/base.d.ts +19 -0
  63. package/dist/types/base.d.ts.map +1 -0
  64. package/dist/types/config.d.ts +80 -0
  65. package/dist/types/config.d.ts.map +1 -0
  66. package/dist/types/enums.d.ts +668 -0
  67. package/dist/types/enums.d.ts.map +1 -0
  68. package/dist/types/enums.js +681 -0
  69. package/dist/types/enums.js.map +1 -0
  70. package/dist/{index-DQkgkiB6.d.ts → types/httpsClient.d.ts} +3 -12
  71. package/dist/types/httpsClient.d.ts.map +1 -0
  72. package/dist/types/index.d.ts +24 -3
  73. package/dist/types/index.js +5 -1
  74. package/dist/types/logger.d.ts +11 -0
  75. package/dist/types/logger.d.ts.map +1 -0
  76. package/dist/types/request.d.ts +52 -0
  77. package/dist/types/request.d.ts.map +1 -0
  78. package/dist/utils/isMetaError.d.ts +23 -0
  79. package/dist/utils/isMetaError.d.ts.map +1 -0
  80. package/package.json +19 -22
  81. package/dist/WebhookProcessor-BUZFeZD_.js +0 -3
  82. package/dist/WebhookProcessor-BUZFeZD_.js.map +0 -1
  83. package/dist/WebhookProcessor-Dq2Pa2cY.d.ts.map +0 -1
  84. package/dist/api/encryption/index.d.ts +0 -3
  85. package/dist/api/encryption/index.js +0 -1
  86. package/dist/api/flow/index.d.ts +0 -5
  87. package/dist/api/flow/index.js +0 -1
  88. package/dist/api/index.d.ts +0 -17
  89. package/dist/api/index.js +0 -1
  90. package/dist/api/media/index.d.ts +0 -3
  91. package/dist/api/media/index.js +0 -1
  92. package/dist/api/messages/builders/index.d.ts +0 -539
  93. package/dist/api/messages/builders/index.d.ts.map +0 -1
  94. package/dist/api/messages/builders/index.js +0 -2
  95. package/dist/api/messages/builders/index.js.map +0 -1
  96. package/dist/api/messages/index.d.ts +0 -4
  97. package/dist/api/messages/index.js +0 -1
  98. package/dist/api/phone/index.d.ts +0 -3
  99. package/dist/api/phone/index.js +0 -1
  100. package/dist/api/profile/index.d.ts +0 -3
  101. package/dist/api/profile/index.js +0 -1
  102. package/dist/api/qrCode/index.d.ts +0 -3
  103. package/dist/api/qrCode/index.js +0 -1
  104. package/dist/api/registration/index.d.ts +0 -3
  105. package/dist/api/registration/index.js +0 -1
  106. package/dist/api/template/index.d.ts +0 -3
  107. package/dist/api/template/index.js +0 -1
  108. package/dist/api/twoStepVerification/index.d.ts +0 -3
  109. package/dist/api/twoStepVerification/index.js +0 -1
  110. package/dist/api/waba/index.d.ts +0 -3
  111. package/dist/api/waba/index.js +0 -1
  112. package/dist/api-8hRAOyaL.js +0 -1
  113. package/dist/base-CfDkvT1x.d.ts.map +0 -1
  114. package/dist/base-D-cXu_lA.js +0 -2
  115. package/dist/base-D-cXu_lA.js.map +0 -1
  116. package/dist/buildFieldsQueryString-Cr-jz3p0.js +0 -2
  117. package/dist/buildFieldsQueryString-Cr-jz3p0.js.map +0 -1
  118. package/dist/chunk-CTAAG5j7.js +0 -1
  119. package/dist/common-C6FXBDm7.js +0 -2
  120. package/dist/common-CVbsmD26.d.ts +0 -426
  121. package/dist/common-CVbsmD26.d.ts.map +0 -1
  122. package/dist/core/webhook/frameworks/express.d.ts +0 -20
  123. package/dist/core/webhook/frameworks/express.js +0 -1
  124. package/dist/core/webhook/frameworks/nextjs-app.d.ts +0 -45
  125. package/dist/core/webhook/frameworks/nextjs-app.d.ts.map +0 -1
  126. package/dist/core/webhook/frameworks/nextjs-app.js +0 -2
  127. package/dist/core/webhook/frameworks/nextjs-app.js.map +0 -1
  128. package/dist/core/webhook/frameworks/nextjs.d.ts +0 -20
  129. package/dist/core/webhook/frameworks/nextjs.js +0 -1
  130. package/dist/core/webhook/index.d.ts +0 -20
  131. package/dist/core/webhook/index.js +0 -1
  132. package/dist/core/whatsapp/index.d.ts +0 -18
  133. package/dist/core/whatsapp/index.js +0 -1
  134. package/dist/encryption-Cwc0xcVL.js +0 -2
  135. package/dist/encryption-Cwc0xcVL.js.map +0 -1
  136. package/dist/enums-CSUpFXb8.js +0 -2
  137. package/dist/enums-CSUpFXb8.js.map +0 -1
  138. package/dist/express-B6fQdflY.d.ts +0 -78
  139. package/dist/express-B6fQdflY.d.ts.map +0 -1
  140. package/dist/express-CrfNLYMM.js +0 -2
  141. package/dist/express-CrfNLYMM.js.map +0 -1
  142. package/dist/flow-CVes0Qus.js +0 -2
  143. package/dist/flow-CVes0Qus.js.map +0 -1
  144. package/dist/flowTypeGuards-Gn3-slCW.js +0 -2
  145. package/dist/flowTypeGuards-Gn3-slCW.js.map +0 -1
  146. package/dist/handler-BGqjZ0xg.js +0 -2
  147. package/dist/handler-BGqjZ0xg.js.map +0 -1
  148. package/dist/index-3KglHVAg.d.ts +0 -354
  149. package/dist/index-3KglHVAg.d.ts.map +0 -1
  150. package/dist/index-BNeg6hHx.d.ts +0 -99
  151. package/dist/index-BNeg6hHx.d.ts.map +0 -1
  152. package/dist/index-BiTq23oi.d.ts +0 -34
  153. package/dist/index-BiTq23oi.d.ts.map +0 -1
  154. package/dist/index-BmfnREgM.d.ts +0 -47
  155. package/dist/index-BmfnREgM.d.ts.map +0 -1
  156. package/dist/index-CaGffSja.d.ts +0 -24
  157. package/dist/index-CaGffSja.d.ts.map +0 -1
  158. package/dist/index-CeTmbIXi.d.ts.map +0 -1
  159. package/dist/index-CoyByMuM.d.ts +0 -137
  160. package/dist/index-CoyByMuM.d.ts.map +0 -1
  161. package/dist/index-CwujtcvH.d.ts +0 -370
  162. package/dist/index-CwujtcvH.d.ts.map +0 -1
  163. package/dist/index-DQ7z58xp.d.ts +0 -104
  164. package/dist/index-DQ7z58xp.d.ts.map +0 -1
  165. package/dist/index-DQkgkiB6.d.ts.map +0 -1
  166. package/dist/index-LKrIp3Oo.d.ts +0 -1
  167. package/dist/index-_-06JPan.d.ts +0 -143
  168. package/dist/index-_-06JPan.d.ts.map +0 -1
  169. package/dist/index-a_YS40Iv.d.ts +0 -91
  170. package/dist/index-a_YS40Iv.d.ts.map +0 -1
  171. package/dist/index-d7TLqtYh.d.ts +0 -171
  172. package/dist/index-d7TLqtYh.d.ts.map +0 -1
  173. package/dist/isMetaError-B3AglYeY.d.ts +0 -66
  174. package/dist/isMetaError-B3AglYeY.d.ts.map +0 -1
  175. package/dist/media-Dw5OGzDD.js +0 -2
  176. package/dist/media-Dw5OGzDD.js.map +0 -1
  177. package/dist/messages-h5-NW8QO.js +0 -2
  178. package/dist/messages-h5-NW8QO.js.map +0 -1
  179. package/dist/nextjs-DxRCL4t3.js +0 -2
  180. package/dist/nextjs-DxRCL4t3.js.map +0 -1
  181. package/dist/objectToQueryString-CAHI0qTs.js +0 -2
  182. package/dist/objectToQueryString-CAHI0qTs.js.map +0 -1
  183. package/dist/phone-CZyWLyWB.js +0 -2
  184. package/dist/phone-CZyWLyWB.js.map +0 -1
  185. package/dist/profile-Bb7GDP0n.js +0 -2
  186. package/dist/profile-Bb7GDP0n.js.map +0 -1
  187. package/dist/qrCode-CeZEtX9J.js +0 -2
  188. package/dist/qrCode-CeZEtX9J.js.map +0 -1
  189. package/dist/registration-BkjhC3xw.js +0 -2
  190. package/dist/registration-BkjhC3xw.js.map +0 -1
  191. package/dist/template-Bgy-BCXJ.js +0 -2
  192. package/dist/template-Bgy-BCXJ.js.map +0 -1
  193. package/dist/twoStepVerification-DYlYF_P5.js +0 -2
  194. package/dist/twoStepVerification-DYlYF_P5.js.map +0 -1
  195. package/dist/utils/index.d.ts +0 -43
  196. package/dist/utils/index.d.ts.map +0 -1
  197. package/dist/utils/index.js +0 -1
  198. package/dist/version-BUuqrHc6.js +0 -3
  199. package/dist/version-BUuqrHc6.js.map +0 -1
  200. package/dist/waba-SF2W3z2U.js +0 -2
  201. package/dist/waba-SF2W3z2U.js.map +0 -1
  202. package/dist/webhook-D4DQ01Xq.js +0 -2
  203. package/dist/webhook-D4DQ01Xq.js.map +0 -1
  204. package/dist/whatsapp-B85mxH5f.js +0 -10
  205. package/dist/whatsapp-B85mxH5f.js.map +0 -1
@@ -1,91 +0,0 @@
1
- import { BaseAPI, RequesterClass, ResponseSuccess, WabaConfigType } from "./base-CfDkvT1x.js";
2
-
3
- //#region src/api/media/types/common.d.ts
4
- type MediaResponse = {
5
- id: string;
6
- url: string;
7
- mime_type: string;
8
- sha256: string;
9
- file_size: number;
10
- messaging_product: 'whatsapp';
11
- };
12
- type MediasResponse = {
13
- data: MediaResponse[];
14
- paging: {
15
- cursors: {
16
- before: string;
17
- after: string;
18
- };
19
- };
20
- };
21
- type UploadMediaResponse = {
22
- id: string;
23
- };
24
- interface MediaClass {
25
- getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
26
- uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
27
- deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
28
- downloadMedia(mediaUrl: string): Promise<Blob>;
29
- }
30
- //#endregion
31
- //#region src/api/media/MediaApi.d.ts
32
- /**
33
- * API for managing WhatsApp Media.
34
- *
35
- * This API allows you to:
36
- * - Get media information by ID
37
- * - Upload media files
38
- * - Delete media files
39
- * - Download media files from URLs
40
- */
41
- declare class MediaApi extends BaseAPI implements MediaClass {
42
- private readonly endpoint;
43
- constructor(config: WabaConfigType, client: RequesterClass);
44
- /**
45
- * Retrieve media information by media ID.
46
- *
47
- * @param mediaId The media ID to retrieve information for
48
- * @param phone_number_id Optional phone number ID (defaults to configured one)
49
- * @returns Media information including URL, mime type, file size, etc.
50
- *
51
- * @example
52
- * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');
53
- */
54
- getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
55
- /**
56
- * Upload a media file to WhatsApp.
57
- *
58
- * @param file The file to upload
59
- * @param messagingProduct The messaging product (default: 'whatsapp')
60
- * @returns Upload response containing the media ID
61
- *
62
- * @example
63
- * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
64
- * const result = await whatsappClient.media.uploadMedia(file);
65
- */
66
- uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
67
- /**
68
- * Delete a media file.
69
- *
70
- * @param mediaId The media ID to delete
71
- * @param phone_number_id Optional phone number ID (defaults to configured one)
72
- * @returns Response indicating success or failure
73
- *
74
- * @example
75
- * await whatsappClient.media.deleteMedia('media_id_123');
76
- */
77
- deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
78
- /**
79
- * Download media from a URL.
80
- *
81
- * @param mediaUrl The URL to download media from
82
- * @returns Blob containing the media data
83
- *
84
- * @example
85
- * const blob = await whatsappClient.media.downloadMedia('https://...');
86
- */
87
- downloadMedia(mediaUrl: string): Promise<Blob>;
88
- }
89
- //#endregion
90
- export { MediaApi, type MediaClass, type MediaResponse, type MediasResponse, type UploadMediaResponse };
91
- //# sourceMappingURL=index-a_YS40Iv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-a_YS40Iv.d.ts","names":[],"sources":["../src/api/media/types/common.ts","../src/api/media/MediaApi.ts"],"sourcesContent":[],"mappings":";;;KAEY,aAAA;;EAAA,GAAA,EAAA,MAAA;EASA,SAAA,EAAA,MAAc;EAUd,MAAA,EAAA,MAAA;EAIK,SAAA,EAAA,MAAU;EAAA,iBAAA,EAAA,UAAA;;AACkC,KAfjD,cAAA,GAeiD;MACvC,EAfZ,aAeY,EAAA;QAA0C,EAAA;IAAR,OAAA,EAAA;MACY,MAAA,EAAA,MAAA;MAAR,KAAA,EAAA,MAAA;IACf,CAAA;;CAAD;KARhC,mBAAA;;;ACLS,UDSJ,UAAA,CCTa;EAAA,YAAA,CAAA,OAAA,EAAA,MAAA,EAAA,eAAA,CAAA,EAAA,MAAA,CAAA,EDU+B,OCV/B,CDUuC,aCVvC,CAAA;aAGN,CAAA,IAAA,EDQF,ICRE,EAAA,gBAAA,CAAA,EAAA,MAAA,CAAA,EDQgC,OCRhC,CDQwC,mBCRxC,CAAA;aAAwB,CAAA,OAAA,EAAA,MAAA,EAAA,eAAA,CAAA,EAAA,MAAA,CAAA,EDSY,OCTZ,CDSoB,eCTpB,CAAA;eAc2B,CAAA,QAAA,EAAA,MAAA,CAAA,EDJtC,OCIsC,CDJ9B,ICI8B,CAAA;;;;ADtB3E;AAUA;AAIA;;;;;;;AAGoE,cCZ/C,QAAA,SAAiB,OAAA,YAAmB,UDYW,CAAA;mBAAR,QAAA;aACf,CAAA,MAAA,ECVrB,cDUqB,EAAA,MAAA,ECVG,cDUH;;;;;;ACxBP;;;;;cA4B6B,CAAA,OAAA,EAAA,MAAA,EAAA,eAAA,CAAA,EAAA,MAAA,CAAA,EAAA,OAAA,CAAQ,aAAR,CAAA;;;;;;;;;;;;oBAevC,kCAA8C,QAAQ;;;;;;;;;;;0DAwBhB,QAAQ;;;;;;;;;;mCAa/B,QAAQ"}
@@ -1,171 +0,0 @@
1
- import { BaseAPI, ComponentTypesEnum, InteractiveTypesEnum, MessageTypesEnum, RequesterClass, WabaConfigType } from "./base-CfDkvT1x.js";
2
- import { AudioMediaObject, ContactObject, DocumentMediaObject, ImageMediaObject, InteractiveObject, LocationObject, MessageRequestBody, MessageRequestParams, MessageTemplateObject, MessagesClass, MessagesResponse, ReactionParams, StatusParams, StickerMediaObject, TextMessageParams, TextObject, VideoMediaObject } from "./common-CVbsmD26.js";
3
-
4
- //#region src/api/messages/MessageApi.d.ts
5
-
6
- /**
7
- * Maps each message type to its appropriate payload type
8
- */
9
- type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
10
- message_id: string;
11
- emoji: string;
12
- } : never;
13
- declare class MessagesApi extends BaseAPI implements MessagesClass {
14
- private readonly commonMethod;
15
- private readonly commonEndpoint;
16
- constructor(config: WabaConfigType, client: RequesterClass);
17
- /**
18
- * Builds the request body for WhatsApp API messages
19
- * @param type The type of message to send
20
- * @param payload The message payload object
21
- * @param to The recipient's phone number
22
- * @param replyMessageId Optional message ID to reply to
23
- * @returns The formatted request body
24
- */
25
- bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
26
- /**
27
- * Sends a request to the WhatsApp API
28
- * @param body The request body to send
29
- * @returns Promise with the API response
30
- */
31
- private send;
32
- /**
33
- * Sends an audio message via WhatsApp
34
- * @param params The audio message parameter object
35
- * @returns Promise with the message response
36
- */
37
- audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
38
- /**
39
- * Sends a contact card via WhatsApp
40
- * @param params The contact message parameter object
41
- * @returns Promise with the message response
42
- */
43
- contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
44
- /**
45
- * Sends a document via WhatsApp
46
- * @param params The document message parameter object
47
- * @returns Promise with the message response
48
- */
49
- document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
50
- /**
51
- * Sends an image via WhatsApp
52
- * @param params The image message parameter object
53
- * @returns Promise with the message response
54
- */
55
- image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
56
- /**
57
- * Sends an interactive message via WhatsApp
58
- * @param params The interactive message parameter object
59
- * @returns Promise with the message response
60
- */
61
- interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
62
- /**
63
- * Sends a location via WhatsApp
64
- * @param params The location message parameter object
65
- * @returns Promise with the message response
66
- */
67
- location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
68
- /**
69
- * Sends a sticker via WhatsApp
70
- * @param params The sticker message parameter object
71
- * @returns Promise with the message response
72
- */
73
- sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
74
- /**
75
- * Sends a template message via WhatsApp
76
- * @param params The template message parameter object
77
- * @returns Promise with the message response
78
- */
79
- template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
80
- /**
81
- * Sends a text message via WhatsApp
82
- * @param params The text message parameter object
83
- * @returns Promise with the message response
84
- */
85
- text(params: TextMessageParams): Promise<MessagesResponse>;
86
- /**
87
- * Sends a video message via WhatsApp
88
- * @param params The video message parameter object
89
- * @returns Promise with the message response
90
- */
91
- video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
92
- /**
93
- * Updates message status (mark as read, etc.)
94
- * @param params The status update parameters
95
- * @returns Promise with the API response
96
- */
97
- status(params: StatusParams): Promise<MessagesResponse>;
98
- /**
99
- * Marks a message as read
100
- * @param params Object containing messageId
101
- * @returns Promise with the API response
102
- */
103
- markAsRead(params: {
104
- messageId: string;
105
- }): Promise<MessagesResponse>;
106
- /**
107
- * Shows typing indicator
108
- * @param params Object containing messageId
109
- * @returns Promise with the API response
110
- */
111
- showTypingIndicator(params: {
112
- messageId: string;
113
- }): Promise<MessagesResponse>;
114
- /**
115
- * Sends a list interactive message
116
- * @param params The list interactive message parameters
117
- * @returns Promise with the message response
118
- */
119
- interactiveList(params: MessageRequestParams<InteractiveObject & {
120
- type: InteractiveTypesEnum.List;
121
- }>): Promise<MessagesResponse>;
122
- /**
123
- * Sends a CTA URL interactive message
124
- * @param params The CTA URL interactive message parameters
125
- * @returns Promise with the message response
126
- */
127
- interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
128
- type: InteractiveTypesEnum.CtaUrl;
129
- }>): Promise<MessagesResponse>;
130
- /**
131
- * Sends a location request interactive message
132
- * @param params The location request interactive message parameters
133
- * @returns Promise with the message response
134
- */
135
- interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
136
- type: InteractiveTypesEnum.LocationRequest;
137
- }>): Promise<MessagesResponse>;
138
- /**
139
- * Sends an address message interactive message
140
- * @param params The address message interactive message parameters
141
- * @returns Promise with the message response
142
- */
143
- interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
144
- type: InteractiveTypesEnum.AddressMessage;
145
- }>): Promise<MessagesResponse>;
146
- /**
147
- * Sends a reply buttons interactive message
148
- * @param params The reply buttons interactive message parameters
149
- * @returns Promise with the message response
150
- */
151
- interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
152
- type: InteractiveTypesEnum.Button;
153
- }>): Promise<MessagesResponse>;
154
- /**
155
- * Sends a flow interactive message
156
- * @param params The flow interactive message parameters
157
- * @returns Promise with the message response
158
- */
159
- interactiveFlow(params: MessageRequestParams<InteractiveObject & {
160
- type: InteractiveTypesEnum.Flow;
161
- }>): Promise<MessagesResponse>;
162
- /**
163
- * Sends a reaction to a message
164
- * @param params The reaction parameters
165
- * @returns Promise with the message response
166
- */
167
- reaction(params: ReactionParams): Promise<MessagesResponse>;
168
- }
169
- //#endregion
170
- export { MessagesApi };
171
- //# sourceMappingURL=index-d7TLqtYh.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-d7TLqtYh.d.ts","names":[],"sources":["../src/api/messages/MessageApi.ts"],"sourcesContent":[],"mappings":"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"}
@@ -1,66 +0,0 @@
1
- import { FlowActionEnum, FlowDataExchangeRequest, FlowEndpointRequest, FlowErrorNotificationRequest, FlowHealthCheckRequest } from "./common-CvPVD1o6.js";
2
-
3
- //#region src/utils/flowTypeGuards.d.ts
4
- declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
5
- declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
6
- /**
7
- * Type guard to check if a request is a Data Exchange request
8
- * Validates the request structure according to the Flow API specifications
9
- *
10
- * @param request The Flow endpoint request to check
11
- * @returns True if the request is a valid Data Exchange request, false otherwise
12
- */
13
- declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
14
- action: (typeof DATA_EXCHANGE_ACTIONS)[number];
15
- screen?: string;
16
- flow_token: string;
17
- data?: Record<string, any>;
18
- };
19
- /**
20
- * Type guard to check if a request is an Error Notification request
21
- * Validates the request structure according to the Flow API error specifications
22
- *
23
- * @param request The Flow endpoint request to check
24
- * @returns True if the request is a valid Error Notification request, false otherwise
25
- */
26
- declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
27
- action: (typeof ERROR_ACTIONS)[number];
28
- screen: string;
29
- flow_token: string;
30
- data: {
31
- error: string;
32
- error_message: string;
33
- };
34
- };
35
- /**
36
- * Type guard to check if a request is a Ping (health check) request
37
- * Simple validation for health check endpoints in the Flow API
38
- *
39
- * @param request The Flow endpoint request to check
40
- * @returns True if the request is a Ping request, false otherwise
41
- */
42
- declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
43
- //#endregion
44
- //#region src/utils/isMetaError.d.ts
45
- interface MetaError extends Error {
46
- error: {
47
- message: string;
48
- type: string;
49
- code: number;
50
- error_data?: {
51
- messaging_product: 'whatsapp';
52
- details: string;
53
- };
54
- error_subcode?: number;
55
- fbtrace_id: string;
56
- };
57
- }
58
- /**
59
- * Determines if the error is a Meta API error response
60
- * @param error Any error object to check
61
- * @returns Type guard indicating if error is a Meta API error
62
- */
63
- declare function isMetaError(error: any): error is MetaError;
64
- //#endregion
65
- export { MetaError, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError };
66
- //# sourceMappingURL=isMetaError-B3AglYeY.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isMetaError-B3AglYeY.d.ts","names":[],"sources":["../src/utils/flowTypeGuards.ts","../src/utils/isMetaError.ts"],"sourcesContent":[],"mappings":";;;cA2BM,iCAAqB,cAAA,CAAA,eAAA,cAAA,CAAA,MAAA,cAAA,CAAA;cAGrB,yBAAa,cAAA,CAAA,eAAA,cAAA,CAAA;AAxBQ;;;;;;AAqBA;AAGuD,iBASlE,yBAAA,CATkE,OAAA,EAS/B,mBAT+B,CAAA,EAAA,OAAA,IASE,uBATF,GAAA;QAA/D,EAAA,CAAA,OAUC,qBAVD,CAAA,CAAA,MAAA,CAAA;QAAA,CAAA,EAAA,MAAA;EAAA,UAAA,EAAA,MAAA;EASH,IAAA,CAAA,EAIL,MAJK,CAAA,MAAA,EAAA,GAAA,CAAA;CAAyB;;;;;;AAoCzC;;AAA4C,iBAA5B,kBAAA,CAA4B,OAAA,EAAA,mBAAA,CAAA,EAAA,OAAA,IAAiC,4BAAjC,GAAA;QAAiC,EAAA,CAAA,OACzD,aADyD,CAAA,CAAA,MAAA,CAAA;QACzD,EAAA,MAAA;EAAa,UAAA,EAAA,MAAA;EAwCjB,IAAA,EAAA;IAAiB,KAAA,EAAA,MAAA;IAAU,aAAA,EAAA,MAAA;;CAAuD;;;;ACpHlG;AAmBA;;;iBDiGgB,iBAAA,UAA2B,iCAAiC;;;UCpH3D,SAAA,SAAkB;;;ID2B7B,IAAA,EAAA,MAAA;IAAyG,IAAA,EAAA,MAAA;IAApF,UAAA,CAAA,EAAA;MAAA,iBAAA,EAAA,UAAA;MAAA,OAAA,EAAA,MAAA;IAAA,CAAA;IAGrB,aAA4E,CAAA,EAAA,MAAA;IAAA,UAAA,EAAA,MAAA;;;;AASlF;;;;AACoB,iBCrBJ,WAAA,CDqBI,KAAA,EAAA,GAAA,CAAA,EAAA,KAAA,ICrB8B,SDqB9B"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{endpoint=`media`;constructor(e,t){super(e,t)}async getMediaById(n,r){return this.sendJson(e.Get,`${n}`,this.config[t.RequestTimeout],null)}async uploadMedia(n,r=`whatsapp`){let i=new FormData;return i.append(`file`,n),i.append(`messaging_product`,r),i.append(`type`,n.type),this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],i)}async deleteMedia(n,r){return this.sendJson(e.Delete,`${n}`,this.config[t.RequestTimeout],null)}async downloadMedia(n){return this.sendJson(e.Get,n,this.config[t.RequestTimeout],null)}},i=r;export{r as MediaApi,i as media_default};
2
- //# sourceMappingURL=media-Dw5OGzDD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"media-Dw5OGzDD.js","names":[],"sources":["../src/api/media/MediaApi.ts","../src/api/media/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as media from './types';\n\n/**\n * API for managing WhatsApp Media.\n *\n * This API allows you to:\n * - Get media information by ID\n * - Upload media files\n * - Delete media files\n * - Download media files from URLs\n */\nexport default class MediaApi extends BaseAPI implements media.MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Retrieve media information by media ID.\n *\n * @param mediaId The media ID to retrieve information for\n * @param phone_number_id Optional phone number ID (defaults to configured one)\n * @returns Media information including URL, mime type, file size, etc.\n *\n * @example\n * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');\n */\n async getMediaById(mediaId: string, phone_number_id?: string): Promise<media.MediaResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * Upload a media file to WhatsApp.\n *\n * @param file The file to upload\n * @param messagingProduct The messaging product (default: 'whatsapp')\n * @returns Upload response containing the media ID\n *\n * @example\n * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });\n * const result = await whatsappClient.media.uploadMedia(file);\n */\n async uploadMedia(file: File, messagingProduct: string = 'whatsapp'): Promise<media.UploadMediaResponse> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Delete a media file.\n *\n * @param mediaId The media ID to delete\n * @param phone_number_id Optional phone number ID (defaults to configured one)\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.media.deleteMedia('media_id_123');\n */\n async deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * Download media from a URL.\n *\n * @param mediaUrl The URL to download media from\n * @returns Blob containing the media data\n *\n * @example\n * const blob = await whatsappClient.media.downloadMedia('https://...');\n */\n async downloadMedia(mediaUrl: string): Promise<Blob> {\n return this.sendJson(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import MediaApi from './MediaApi';\n\nexport default MediaApi;\n\nexport { MediaApi };\n\nexport type { MediaClass, MediaResponse, MediasResponse, UploadMediaResponse } from './types';\n"],"mappings":"uHAgBA,IAAqB,EAArB,cAAsC,CAAoC,CACtE,SAA4B,QAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,aAAa,EAAiB,EAAwD,CACxF,OAAO,KAAK,SAAS,EAAgB,IAAK,GAAG,IAAW,KAAK,OAAO,EAAe,gBAAiB,KAAK,CAc7G,MAAM,YAAY,EAAY,EAA2B,WAAgD,CACrG,IAAM,EAAW,IAAI,SAKrB,OAJA,EAAS,OAAO,OAAQ,EAAK,CAC7B,EAAS,OAAO,oBAAqB,EAAiB,CACtD,EAAS,OAAO,OAAQ,EAAK,KAAK,CAE3B,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,EACH,CAaL,MAAM,YAAY,EAAiB,EAAoD,CACnF,OAAO,KAAK,SAAS,EAAgB,OAAQ,GAAG,IAAW,KAAK,OAAO,EAAe,gBAAiB,KAAK,CAYhH,MAAM,cAAc,EAAiC,CACjD,OAAO,KAAK,SAAS,EAAgB,IAAK,EAAU,KAAK,OAAO,EAAe,gBAAiB,KAAK,GCpF7G,EAAe"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,MessageTypesEnum as t,WabaConfigEnum as n}from"./enums-CSUpFXb8.js";import{BaseAPI as r}from"./base-D-cXu_lA.js";var i=class extends r{commonMethod=e.Post;commonEndpoint=`messages`;constructor(e,t){super(e,t)}bodyBuilder(e,t,n,r){let i={messaging_product:`whatsapp`,recipient_type:`individual`,to:n,type:e,[e]:t};return r&&(i.context={message_id:r}),i}send(e){return this.sendJson(this.commonMethod,`${this.config[n.PhoneNumberId]}/${this.commonEndpoint}`,this.config[n.RequestTimeout],e)}async audio(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Audio,n,r,i)))}async contacts(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Contacts,n,r,i)))}async document(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Document,n,r,i)))}async image(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Image,n,r,i)))}async interactive(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Interactive,n,r,i)))}async location(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Location,n,r,i)))}async sticker(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Sticker,n,r,i)))}async template(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Template,n,r,i)))}async text(e){let{body:n,to:r,replyMessageId:i,previewUrl:a}=e,o=typeof n==`string`?{body:n,preview_url:a??!0}:{...n,preview_url:a??n.preview_url??!0};return this.send(JSON.stringify(this.bodyBuilder(t.Text,o,r,i)))}async video(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Video,n,r,i)))}async status(e){let t={messaging_product:`whatsapp`,status:e.status,message_id:e.messageId,...e.typingIndicator&&{typing_indicator:e.typingIndicator}};return this.send(JSON.stringify(t))}async markAsRead(e){return this.status({status:`read`,messageId:e.messageId})}async showTypingIndicator(e){return this.status({status:`read`,messageId:e.messageId,typingIndicator:{type:`text`}})}async interactiveList(e){return this.interactive(e)}async interactiveCtaUrl(e){return this.interactive(e)}async interactiveLocationRequest(e){return this.interactive(e)}async interactiveAddressMessage(e){return this.interactive(e)}async interactiveReplyButtons(e){return this.interactive(e)}async interactiveFlow(e){return this.interactive(e)}async reaction(e){let n={message_id:e.messageId,emoji:e.emoji};return this.send(JSON.stringify(this.bodyBuilder(t.Reaction,n,e.to)))}},a=i;export{i as MessagesApi,a as messages_default};
2
- //# sourceMappingURL=messages-h5-NW8QO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages-h5-NW8QO.js","names":["body: m.MessageRequestBody<T>","textPayload: m.TextObject","MessageApi"],"sources":["../src/api/messages/MessageApi.ts","../src/api/messages/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport {\n type ComponentTypesEnum,\n HttpMethodsEnum,\n type InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../../types/enums';\nimport type { RequesterClass } from '../../types/request';\n\nimport type * as m from './types';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param to The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<m.MessagesResponse> {\n return this.sendJson(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n async audio(params: m.MessageRequestParams<m.AudioMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n async contacts(params: m.MessageRequestParams<[m.ContactObject]>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n async document(params: m.MessageRequestParams<m.DocumentMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n async image(params: m.MessageRequestParams<m.ImageMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n async interactive(params: m.MessageRequestParams<m.InteractiveObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n async location(params: m.MessageRequestParams<m.LocationObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n async sticker(params: m.MessageRequestParams<m.StickerMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n async template(\n params: m.MessageRequestParams<m.MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n async text(params: m.TextMessageParams): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId, previewUrl } = params;\n\n // Handle both string and TextObject types\n const textPayload: m.TextObject =\n typeof body === 'string'\n ? { body, preview_url: previewUrl ?? true }\n : { ...body, preview_url: previewUrl ?? body.preview_url ?? true };\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, textPayload, to, replyMessageId)));\n }\n\n /**\n * Sends a video message via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n async video(params: m.MessageRequestParams<m.VideoMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (mark as read, etc.)\n * @param params The status update parameters\n * @returns Promise with the API response\n */\n async status(params: m.StatusParams): Promise<m.MessagesResponse> {\n const body = {\n messaging_product: 'whatsapp',\n status: params.status,\n message_id: params.messageId,\n ...(params.typingIndicator && { typing_indicator: params.typingIndicator }),\n };\n\n return this.send(JSON.stringify(body));\n }\n\n /**\n * Marks a message as read\n * @param params Object containing messageId\n * @returns Promise with the API response\n */\n async markAsRead(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n });\n }\n\n /**\n * Shows typing indicator\n * @param params Object containing messageId\n * @returns Promise with the API response\n */\n async showTypingIndicator(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n typingIndicator: { type: 'text' },\n });\n }\n\n /**\n * Sends a list interactive message\n * @param params The list interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveList(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a CTA URL interactive message\n * @param params The CTA URL interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveCtaUrl(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a location request interactive message\n * @param params The location request interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveLocationRequest(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends an address message interactive message\n * @param params The address message interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveAddressMessage(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a reply buttons interactive message\n * @param params The reply buttons interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveReplyButtons(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a flow interactive message\n * @param params The flow interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveFlow(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a reaction to a message\n * @param params The reaction parameters\n * @returns Promise with the message response\n */\n async reaction(params: m.ReactionParams): Promise<m.MessagesResponse> {\n const reactionPayload = {\n message_id: params.messageId,\n emoji: params.emoji,\n };\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Reaction, reactionPayload, params.to)));\n }\n}\n","import MessageApi from './MessageApi';\n\nexport default MessageApi;\n\nexport { MessageApi };\n\nexport type {\n AudioMediaObject,\n ContactObject,\n DocumentMediaObject,\n ImageMediaObject,\n InteractiveObject,\n LocationObject,\n MessageRequestParams,\n MessageTemplateObject,\n MessagesResponse,\n ReactionParams,\n StatusParams,\n StickerMediaObject,\n TextMessageParams,\n TextObject,\n VideoMediaObject,\n} from './types';\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import{BaseWebhookHandler as e}from"./handler-BGqjZ0xg.js";var t=class extends e{constructor(e){super(e)}async parseRequestBody(e){if(e.method===`POST`&&!e.body){let t=[];if(typeof e[Symbol.asyncIterator]==`function`){for await(let n of e)t.push(n);let n=Buffer.concat(t).toString();if(n.trim())try{e.body=JSON.parse(n)}catch{throw Error(`Invalid JSON in request body`)}else e.body={}}}}async handleGet(e,t){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body)}catch(e){return console.error(`Webhook verification error:`,e),t.status(500).json({error:`Internal Server Error`})}}async handlePost(e,t){try{await this.parseRequestBody(e)}catch(e){return console.error(`Webhook processing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?t.status(400).json({error:`Invalid JSON`}):t.status(500).json({error:`Internal Server Error`})}try{let n=this.constructFullUrl(e.headers,e.url),r=new Request(n,{method:`POST`,headers:e.headers,body:JSON.stringify(e.body)}),i=await this.processWebhook(r);return this.applyHeaders(i,t),t.status(i.status).send(i.body)}catch(e){return console.error(`Webhook processing error:`,e),t.status(500).json({error:`Internal Server Error`})}}async handleFlow(e,t){try{let n=this.constructFullUrl(e.headers,e.url),r=new Request(n,{method:e.method,headers:e.headers,body:e.method===`POST`?JSON.stringify(e.body):void 0}),i=await this.processFlow(r);return this.applyHeaders(i,t),t.status(i.status).send(i.body)}catch(e){return console.error(`Flow error:`,e),t.status(500).json({error:`Internal Server Error`})}}getHandlers(){return{GET:(e,t)=>this.handleGet(e,t),POST:(e,t)=>this.handlePost(e,t),webhook:(e,t)=>this.autoRoute(e,t),flow:(e,t)=>this.handleFlow(e,t),processor:this.webhookProcessor}}};function n(e){return new t(e).getHandlers()}export{n as webhookHandler};
2
- //# sourceMappingURL=nextjs-DxRCL4t3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nextjs-DxRCL4t3.js","names":["chunks: Buffer[]"],"sources":["../src/core/webhook/frameworks/nextjs.ts"],"sourcesContent":["import { BaseRequest, BaseResponse, BaseWebhookConfig, BaseWebhookHandler } from './handler';\n\n// Next.js specific interfaces\nexport interface BaseApiRequest extends BaseRequest {\n method?: string;\n url?: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Partial<Record<string, string | string[]>>;\n rawBody?: any;\n}\n\nexport interface BaseApiResponse extends BaseResponse {\n status(code: number): any;\n json(data: any): void | any;\n send(data?: any): void | any;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextJsWebhookConfig extends BaseWebhookConfig {\n // Next.js specific config can be added here\n}\n\n/**\n * Next.js Page Router webhook handler extending the base handler\n */\nclass NextJsWebhookHandler<\n TRequest extends BaseApiRequest,\n TResponse extends BaseApiResponse,\n> extends BaseWebhookHandler<TRequest, TResponse> {\n constructor(config: NextJsWebhookConfig) {\n super(config);\n }\n\n // Helper function to parse request body for POST requests\n private async parseRequestBody(req: TRequest): Promise<void> {\n if (req.method === 'POST' && !req.body) {\n const chunks: Buffer[] = [];\n\n // Check if req is a stream (has Symbol.asyncIterator)\n if (typeof (req as any)[Symbol.asyncIterator] === 'function') {\n for await (const chunk of req as any) {\n chunks.push(chunk);\n }\n\n const body = Buffer.concat(chunks).toString();\n\n // Only attempt to parse if there's actual content\n if (body.trim()) {\n try {\n req.body = JSON.parse(body);\n } catch (error) {\n throw new Error('Invalid JSON in request body');\n }\n } else {\n req.body = {};\n }\n }\n }\n }\n\n protected async handleGet(req: TRequest, res: TResponse): Promise<any> {\n try {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await this.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Webhook verification error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n protected async handlePost(req: TRequest, res: TResponse): Promise<any> {\n try {\n // Auto-parse body if needed\n await this.parseRequestBody(req);\n } catch (error) {\n console.error('Webhook processing error:', error);\n\n // Handle JSON parsing errors specifically\n if (error instanceof Error && error.message === 'Invalid JSON in request body') {\n return res.status(400).json({ error: 'Invalid JSON' });\n }\n\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: 'POST',\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await this.processWebhook(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Webhook processing error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n protected async handleFlow(req: TRequest, res: TResponse): Promise<any> {\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await this.processFlow(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Flow error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n getHandlers() {\n return {\n // Method handlers for clean destructuring\n GET: (req: TRequest, res: TResponse) => this.handleGet(req, res),\n POST: (req: TRequest, res: TResponse) => this.handlePost(req, res),\n\n // Auto-routing webhook handler\n webhook: (req: TRequest, res: TResponse) => this.autoRoute(req, res),\n\n // Flow handler\n flow: (req: TRequest, res: TResponse) => this.handleFlow(req, res),\n\n // Expose processor for handler registration\n processor: this.webhookProcessor,\n };\n }\n}\n\n// Generic webhook handler that accepts any compatible request/response types\nexport function webhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(\n config: NextJsWebhookConfig,\n) {\n const handler = new NextJsWebhookHandler<TRequest, TResponse>(config);\n return handler.getHandlers();\n}\n"],"mappings":"2DA0BA,IAAM,EAAN,cAGU,CAAwC,CAC9C,YAAY,EAA6B,CACrC,MAAM,EAAO,CAIjB,MAAc,iBAAiB,EAA8B,CACzD,GAAI,EAAI,SAAW,QAAU,CAAC,EAAI,KAAM,CACpC,IAAMA,EAAmB,EAAE,CAG3B,GAAI,OAAQ,EAAY,OAAO,gBAAmB,WAAY,CAC1D,UAAW,IAAM,KAAS,EACtB,EAAO,KAAK,EAAM,CAGtB,IAAM,EAAO,OAAO,OAAO,EAAO,CAAC,UAAU,CAG7C,GAAI,EAAK,MAAM,CACX,GAAI,CACA,EAAI,KAAO,KAAK,MAAM,EAAK,MACf,CACZ,MAAU,MAAM,+BAA+B,MAGnD,EAAI,KAAO,EAAE,GAM7B,MAAgB,UAAU,EAAe,EAA8B,CACnE,GAAI,CACA,GAAM,CAAE,WAAY,EAAM,mBAAoB,EAAO,gBAAiB,GAAc,EAAI,MAElF,EAAS,MAAM,KAAK,oBACrB,GAAmB,KACnB,GAAoB,KACpB,GAAwB,KAC5B,CAGD,OADA,KAAK,aAAa,EAAQ,EAAI,CACvB,EAAI,OAAO,EAAO,OAAO,CAAC,KAAK,EAAO,KAAK,OAC7C,EAAO,CAEZ,OADA,QAAQ,MAAM,8BAA+B,EAAM,CAC5C,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,EAIvE,MAAgB,WAAW,EAAe,EAA8B,CACpE,GAAI,CAEA,MAAM,KAAK,iBAAiB,EAAI,OAC3B,EAAO,CAQZ,OAPA,QAAQ,MAAM,4BAA6B,EAAM,CAG7C,aAAiB,OAAS,EAAM,UAAY,+BACrC,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,eAAgB,CAAC,CAGnD,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,CAGnE,GAAI,CACA,IAAM,EAAU,KAAK,iBAAiB,EAAI,QAAS,EAAI,IAAI,CAErD,EAAa,IAAI,QAAQ,EAAS,CACpC,OAAQ,OACR,QAAS,EAAI,QACb,KAAM,KAAK,UAAU,EAAI,KAAK,CACjC,CAAC,CAEI,EAAS,MAAM,KAAK,eAAe,EAAW,CAEpD,OADA,KAAK,aAAa,EAAQ,EAAI,CACvB,EAAI,OAAO,EAAO,OAAO,CAAC,KAAK,EAAO,KAAK,OAC7C,EAAO,CAEZ,OADA,QAAQ,MAAM,4BAA6B,EAAM,CAC1C,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,EAIvE,MAAgB,WAAW,EAAe,EAA8B,CACpE,GAAI,CACA,IAAM,EAAU,KAAK,iBAAiB,EAAI,QAAS,EAAI,IAAI,CAErD,EAAa,IAAI,QAAQ,EAAS,CACpC,OAAQ,EAAI,OACZ,QAAS,EAAI,QACb,KAAM,EAAI,SAAW,OAAS,KAAK,UAAU,EAAI,KAAK,CAAG,IAAA,GAC5D,CAAC,CAEI,EAAS,MAAM,KAAK,YAAY,EAAW,CAEjD,OADA,KAAK,aAAa,EAAQ,EAAI,CACvB,EAAI,OAAO,EAAO,OAAO,CAAC,KAAK,EAAO,KAAK,OAC7C,EAAO,CAEZ,OADA,QAAQ,MAAM,cAAe,EAAM,CAC5B,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,EAIvE,aAAc,CACV,MAAO,CAEH,KAAM,EAAe,IAAmB,KAAK,UAAU,EAAK,EAAI,CAChE,MAAO,EAAe,IAAmB,KAAK,WAAW,EAAK,EAAI,CAGlE,SAAU,EAAe,IAAmB,KAAK,UAAU,EAAK,EAAI,CAGpE,MAAO,EAAe,IAAmB,KAAK,WAAW,EAAK,EAAI,CAGlE,UAAW,KAAK,iBACnB,GAKT,SAAgB,EACZ,EACF,CAEE,OADgB,IAAI,EAA0C,EAAO,CACtD,aAAa"}
@@ -1,2 +0,0 @@
1
- const e=e=>{if(!e||Object.keys(e).length===0)return``;let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0){let e=encodeURIComponent(n),i=encodeURIComponent(String(r));t.push(`${e}=${i}`)}return t.length>0?`?${t.join(`&`)}`:``};export{e as objectToQueryString};
2
- //# sourceMappingURL=objectToQueryString-CAHI0qTs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectToQueryString-CAHI0qTs.js","names":["queryParts: string[]"],"sources":["../src/utils/objectToQueryString.ts"],"sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const queryParts: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n const encodedKey = encodeURIComponent(key);\n const encodedValue = encodeURIComponent(String(value));\n queryParts.push(`${encodedKey}=${encodedValue}`);\n }\n }\n\n return queryParts.length > 0 ? `?${queryParts.join('&')}` : '';\n};\n"],"mappings":"AAAA,MAAa,EAAuB,GAAwC,CACxE,GAAI,CAAC,GAAU,OAAO,KAAK,EAAO,CAAC,SAAW,EAC1C,MAAO,GAGX,IAAMA,EAAuB,EAAE,CAE/B,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAO,CAC7C,GAAI,IAAU,IAAA,GAAW,CACrB,IAAM,EAAa,mBAAmB,EAAI,CACpC,EAAe,mBAAmB,OAAO,EAAM,CAAC,CACtD,EAAW,KAAK,GAAG,EAAW,GAAG,IAAe,CAIxD,OAAO,EAAW,OAAS,EAAI,IAAI,EAAW,KAAK,IAAI,GAAK"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";import{objectToQueryString as r}from"./objectToQueryString-CAHI0qTs.js";var i=class extends n{endpoint=`phone_numbers`;constructor(e,t){super(e,t)}async getPhoneNumberById(n){let i=n?r({fields:n}):``;return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}${i}`,this.config[t.RequestTimeout],null)}async getPhoneNumbers(){return this.sendJson(e.Get,`${this.config[t.BusinessAcctId]}/${this.endpoint}`,this.config[t.RequestTimeout],null)}async requestVerificationCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/request_code`,this.config[t.RequestTimeout],JSON.stringify(n))}async verifyCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/verify_code`,this.config[t.RequestTimeout],JSON.stringify(n))}},a=i;export{i as PhoneNumberApi,a as phone_default};
2
- //# sourceMappingURL=phone-CZyWLyWB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phone-CZyWLyWB.js","names":[],"sources":["../src/api/phone/PhoneNumberApi.ts","../src/api/phone/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\n\nimport type * as phoneNumber from './types';\n\n/**\n * API for managing WhatsApp Phone Numb ers.\n *\n * This API allows you to:\n * - Get phone number information by ID\n * - Get all phone numbers for a business account\n * - Request verification codes for phone numbers\n * - Verify phone numbers with codes\n */\nexport default class PhoneNumberApi extends BaseAPI implements phoneNumber.PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get phone number information by ID.\n *\n * @param fields Optional comma-separated list of fields to include in the response\n * @returns Phone number information including verification status, quality rating, etc.\n *\n * @example\n * const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById();\n * const phoneNumberWithFields = await whatsappClient.phoneNumber.getPhoneNumberById('display_phone_number,verified_name');\n */\n async getPhoneNumberById(fields?: string): Promise<phoneNumber.PhoneNumberResponse> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get all phone numbers for the business account.\n *\n * @returns List of phone numbers associated with the business account\n *\n * @example\n * const phoneNumbers = await whatsappClient.phoneNumber.getPhoneNumbers();\n */\n async getPhoneNumbers(): Promise<phoneNumber.PhoneNumbersResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Request a verification code for the phone number.\n *\n * @param request Verification code request containing method and language\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.phoneNumber.requestVerificationCode({\n * code_method: 'SMS',\n * language: 'en_US'\n * });\n */\n async requestVerificationCode(request: phoneNumber.RequestVerificationCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Verify the phone number with the received code.\n *\n * @param request Verification request containing the code\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.phoneNumber.verifyCode({\n * code: '123456'\n * });\n */\n async verifyCode(request: phoneNumber.VerifyCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n}\n","import PhoneNumberApi from './PhoneNumberApi';\n\nexport default PhoneNumberApi;\n\nexport { PhoneNumberApi };\n\nexport type {\n AccountMode,\n CodeVerificationStatus,\n Cursors,\n HealthStatus,\n HealthStatusEntity,\n MessagingLimitTier,\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n PlatformType,\n QualityRating,\n QualityScore,\n RequestVerificationCodeRequest,\n Throughput,\n ThroughputLevel,\n TwoStepVerificationParams,\n VerifyCodeRequest,\n} from './types';\n"],"mappings":"+LAiBA,IAAqB,EAArB,cAA4C,CAAgD,CACxF,SAA4B,gBAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,mBAAmB,EAA2D,CAChF,IAAM,EAAc,EAAS,EAAoB,CAAE,SAAQ,CAAC,CAAG,GAC/D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,iBAAiB,IAC/C,KAAK,OAAO,EAAe,gBAC3B,KACH,CAWL,MAAM,iBAA6D,CAC/D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,GAAG,KAAK,WACtD,KAAK,OAAO,EAAe,gBAC3B,KACH,CAeL,MAAM,wBAAwB,EAA+E,CACzG,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,eAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAcL,MAAM,WAAW,EAAkE,CAC/E,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,cAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,GCjGT,EAAe"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";import{objectToQueryString as r}from"./objectToQueryString-CAHI0qTs.js";import{buildFieldsQueryString as i}from"./buildFieldsQueryString-Cr-jz3p0.js";var a=class extends n{endpoint=`whatsapp_business_profile`;constructor(e,t){super(e,t)}async getBusinessProfile(n){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}${i(n)}`,this.config[t.RequestTimeout],null)}async updateBusinessProfile(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async createUploadSession(n,i,a){let o=r({file_length:n,file_type:i,file_name:a});return this.sendJson(e.Post,`app/uploads/${o}`,this.config[t.RequestTimeout],null)}async uploadMedia(n,r){return this.sendJson(e.Post,`${n}`,this.config[t.RequestTimeout],r)}async getUploadHandle(n){return this.sendJson(e.Get,`${n}`,this.config[t.RequestTimeout],null)}},o=a;export{a as BusinessProfileApi,o as profile_default};
2
- //# sourceMappingURL=profile-Bb7GDP0n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile-Bb7GDP0n.js","names":[],"sources":["../src/api/profile/BusinessProfileApi.ts","../src/api/profile/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { buildFieldsQueryString } from '../../utils/buildFieldsQueryString';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\n\nimport type * as bp from './types';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileApi extends BaseAPI implements bp.BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n *\n * // Using the BusinessProfileFieldsParam type\n * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);\n */\n async getBusinessProfile(fields?: bp.BusinessProfileFieldsParam): Promise<bp.BusinessProfileResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${buildFieldsQueryString(fields)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(updateRequest: bp.UpdateBusinessProfileRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<bp.UploadSessionResponse> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(uploadId: string, file: Buffer): Promise<bp.UploadBusinessProfileResponse> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<bp.UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import BusinessProfileApi from './BusinessProfileApi';\n\nexport default BusinessProfileApi;\n\nexport { BusinessProfileApi };\n\nexport type {\n BusinessProfileClass,\n BusinessProfileData,\n BusinessProfileField,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n CreateUploadSessionParams,\n GetUploadHandleParams,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadMediaParams,\n UploadSession,\n UploadSessionResponse,\n} from './types';\n"],"mappings":"6QAoBA,IAAqB,EAArB,cAAgD,CAA2C,CACvF,SAA4B,4BAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAuBzB,MAAM,mBAAmB,EAA6E,CAClG,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WAAW,EAAuB,EAAO,GAC9F,KAAK,OAAO,EAAe,gBAC3B,KACH,CA6BL,MAAM,sBAAsB,EAA0E,CAClG,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAc,CAChC,CAsBL,MAAM,oBACF,EACA,EACA,EACiC,CACjC,IAAM,EAAc,EAAoB,CACpC,YAAa,EACb,UAAW,EACX,UAAW,EACd,CAAC,CAEF,OAAO,KAAK,SACR,EAAgB,KAChB,eAAe,IACf,KAAK,OAAO,EAAe,gBAC3B,KACH,CAoBL,MAAM,YAAY,EAAkB,EAAyD,CACzF,OAAO,KAAK,SAAS,EAAgB,KAAM,GAAG,IAAY,KAAK,OAAO,EAAe,gBAAiB,EAAK,CAqC/G,MAAM,gBAAgB,EAA4C,CAC9D,OAAO,KAAK,SAAS,EAAgB,IAAK,GAAG,IAAY,KAAK,OAAO,EAAe,gBAAiB,KAAK,GCvLlH,EAAe"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{endpoint=`message_qrdls`;constructor(e,t){super(e,t)}async createQrCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async getQrCodes(){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],null)}async getQrCode(n){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}/${n}`,this.config[t.RequestTimeout],null)}async updateQrCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async deleteQrCode(n){return this.sendJson(e.Delete,`${this.config[t.PhoneNumberId]}/${this.endpoint}/${n}`,this.config[t.RequestTimeout],null)}},i=r;export{r as QrCodeApi,i as qrCode_default};
2
- //# sourceMappingURL=qrCode-CeZEtX9J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"qrCode-CeZEtX9J.js","names":[],"sources":["../src/api/qrCode/QrCodeApi.ts","../src/api/qrCode/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as qrCode from './types';\n\n/**\n * API for managing WhatsApp QR Codes.\n *\n * This API allows you to:\n * - Create QR codes with prefilled messages\n * - Get all QR codes\n * - Get specific QR code details\n * - Update QR code messages\n * - Delete QR codes\n */\nexport default class QrCodeApi extends BaseAPI implements qrCode.QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Create a new QR code with a prefilled message.\n *\n * @param request The QR code creation request\n * @returns QR code information including code, deep link URL, and optional image URL\n *\n * @example\n * const qrCode = await whatsappClient.qrCode.createQrCode({\n * prefilled_message: 'Hello from WhatsApp!',\n * generate_qr_image: 'PNG'\n * });\n */\n async createQrCode(request: qrCode.CreateQrCodeRequest): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Get all QR codes for the current phone number.\n *\n * @returns List of all QR codes\n *\n * @example\n * const qrCodes = await whatsappClient.qrCode.getQrCodes();\n */\n async getQrCodes(): Promise<qrCode.QrCodesResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get a specific QR code by ID.\n *\n * @param qrCodeId The QR code ID to retrieve\n * @returns QR code information\n *\n * @example\n * const qrCode = await whatsappClient.qrCode.getQrCode('qr_code_123');\n */\n async getQrCode(qrCodeId: string): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update an existing QR code's prefilled message.\n *\n * @param request The QR code update request containing code and new message\n * @returns Updated QR code information\n *\n * @example\n * const updatedQrCode = await whatsappClient.qrCode.updateQrCode({\n * code: 'existing_qr_code',\n * prefilled_message: 'Updated message!'\n * });\n */\n async updateQrCode(request: qrCode.UpdateQrCodeRequest): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Delete a QR code.\n *\n * @param qrCodeId The QR code ID to delete\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.qrCode.deleteQrCode('qr_code_123');\n */\n async deleteQrCode(qrCodeId: string): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import QrCodeApi from './QrCodeApi';\n\nexport default QrCodeApi;\n\nexport { QrCodeApi };\n\nexport type { CreateQrCodeRequest, QrCodeClass, QrCodeResponse, QrCodesResponse, UpdateQrCodeRequest } from './types';\n"],"mappings":"uHAiBA,IAAqB,EAArB,cAAuC,CAAsC,CACzE,SAA4B,gBAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAezB,MAAM,aAAa,EAAqE,CACpF,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAWL,MAAM,YAA8C,CAChD,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KACH,CAYL,MAAM,UAAU,EAAkD,CAC9D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,SAAS,GAAG,IACjE,KAAK,OAAO,EAAe,gBAC3B,KACH,CAeL,MAAM,aAAa,EAAqE,CACpF,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAYL,MAAM,aAAa,EAA4C,CAC3D,OAAO,KAAK,SACR,EAAgB,OAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,SAAS,GAAG,IACjE,KAAK,OAAO,EAAe,gBAC3B,KACH,GClHT,EAAe"}
@@ -1,2 +0,0 @@
1
- import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{constructor(e,t){super(e,t)}async register(n,r){let i={messaging_product:`whatsapp`,pin:n,...r&&{data_localization_region:r}};return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/register`,this.config[t.RequestTimeout],JSON.stringify(i))}async deregister(){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/deregister`,this.config[t.RequestTimeout],null)}},i=r;export{r as RegistrationApi,i as registration_default};
2
- //# sourceMappingURL=registration-BkjhC3xw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registration-BkjhC3xw.js","names":["body: registration.RegistrationRequest"],"sources":["../src/api/registration/RegistrationApi.ts","../src/api/registration/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { DataLocalizationRegionEnum, HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as registration from './types';\n\n/**\n * API for managing WhatsApp Business Account registration.\n *\n * This API allows you to:\n * - Register a WhatsApp Business Account with a PIN\n * - Deregister a WhatsApp Business Account\n */\nexport default class RegistrationApi extends BaseAPI implements registration.RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Register a WhatsApp Business Account using a PIN.\n *\n * @param pin The registration PIN received via SMS or voice call\n * @param dataLocalizationRegion Optional data localization region\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.register('123456', DataLocalizationRegionEnum.Asia);\n */\n async register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess> {\n const body: registration.RegistrationRequest = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n /**\n * Deregister a WhatsApp Business Account.\n *\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.deregister();\n */\n async deregister(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import RegistrationApi from './RegistrationApi';\n\nexport default RegistrationApi;\n\nexport { RegistrationApi };\n\nexport type { RegistrationClass, RegistrationRequest } from './types';\n"],"mappings":"uHAcA,IAAqB,EAArB,cAA6C,CAAkD,CAC3F,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,SAAS,EAAa,EAA+E,CACvG,IAAMA,EAAyC,CAC3C,kBAAmB,WACnB,MACA,GAAI,GAA0B,CAAE,yBAA0B,EAAwB,CACrF,CAED,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,WAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAK,CACvB,CAWL,MAAM,YAAuC,CACzC,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,aAC7C,KAAK,OAAO,EAAe,gBAC3B,KACH,GCxDT,EAAe"}
@@ -1,2 +0,0 @@
1
- import{CategoryEnum as e,HttpMethodsEnum as t,WabaConfigEnum as n}from"./enums-CSUpFXb8.js";import{BaseAPI as r}from"./base-D-cXu_lA.js";import{objectToQueryString as i}from"./objectToQueryString-CAHI0qTs.js";var a=class extends r{endpoint=`message_templates`;constructor(e,t){super(e,t)}async getTemplate(e){return this.sendJson(t.Get,`${e}`,this.config[n.RequestTimeout],null)}async updateTemplate(e,r){return this.sendJson(t.Post,`${e}`,this.config[n.RequestTimeout],JSON.stringify(r))}async getTemplates(e){return this.sendJson(t.Get,`${this.config[n.BusinessAcctId]}/${this.endpoint}${i(e??{})}`,this.config[n.RequestTimeout],null)}async createTemplate(e){return this.sendJson(t.Post,`${this.config[n.BusinessAcctId]}/${this.endpoint}`,this.config[n.RequestTimeout],JSON.stringify(e))}async deleteTemplate(e){return this.sendJson(t.Delete,`${this.config[n.BusinessAcctId]}/${this.endpoint}${i(e)}`,this.config[n.RequestTimeout],null)}};function o(e){let t={type:`HEADER`,format:e.format};return e.text&&(t.text=e.text),e.example&&(t.example=e.example),t}function s(e){let t={type:`BODY`,text:e.text};return e.example&&(t.example=e.example),t}function c(e){return{type:`FOOTER`,text:e.text}}function l(e){let t=[];if(e.phone_number&&t.push({type:`PHONE_NUMBER`,text:e.phone_number.text,phone_number:e.phone_number.phone_number}),e.url){let n={type:`URL`,text:e.url.text,url:e.url.url};e.url.example&&(n.example=[e.url.example]),t.push(n)}if(e.quick_reply&&e.quick_reply.forEach(e=>{t.push({type:`QUICK_REPLY`,text:e.text})}),e.copy_code&&t.push({type:`COPY_CODE`,example:e.copy_code.example}),e.flow){let n={type:`FLOW`,text:e.flow.text};e.flow.flow_id&&(n.flow_id=e.flow.flow_id),e.flow.flow_name&&(n.flow_name=e.flow.flow_name),e.flow.flow_json&&(n.flow_json=e.flow.flow_json),e.flow.flow_action&&(n.flow_action=e.flow.flow_action),e.flow.navigate_screen&&(n.navigate_screen=e.flow.navigate_screen),t.push(n)}return e.mpm&&t.push({type:`MPM`}),e.otp&&t.push({type:`OTP`}),e.spm&&t.push({type:`SPM`}),t.length>0?[{type:`BUTTONS`,buttons:t}]:[]}function u(e){return e.map(e=>{switch(e.type){case`text`:return e.value;case`currency`:return e.fallback_value;case`date_time`:return e.fallback_value;case`image`:case`video`:case`document`:return e.handle||e.link||``;case`location`:return e.name||``;case`product`:return e.product_retailer_id;default:return``}})}function d(e){let t=[];if(e.header&&t.push(o(e.header)),e.body&&t.push(s(e.body)),e.footer&&t.push(c(e.footer)),e.buttons&&t.push(...l(e.buttons)),e.carousel){let n=[];e.carousel.cards.forEach((e,t)=>{if(e.image||e.video||e.product){let t=e.image?`IMAGE`:e.video?`VIDEO`:`DOCUMENT`,r=e.image||e.video||e.product||``;n.push({type:`HEADER`,format:t,example:{header_handle:[r]}})}e.body&&n.push({type:`BODY`,text:e.body,example:e.bodyParameters?{body_text:[u(e.bodyParameters)]}:void 0}),e.buttons&&n.push(...l(e.buttons))}),t.push(...n)}return e.limitedTimeOffer&&t.push({type:`LIMITED_TIME_OFFER`,limited_time_offer:{expiration_time_ms:e.limitedTimeOffer.expiration_time_ms}}),{name:e.name,language:e.language,category:e.category,components:t.length>0?t:void 0}}function f(t){let n=[],r=`*{{1}}* is your verification code.`;return t.add_security_recommendation&&(r+=` For your security, do not share this code.`),t.code_expiration_minutes&&(r+=` This code expires in ${t.code_expiration_minutes} minutes.`),n.push({type:`BODY`,text:r,example:{body_text:[[`123456`]]}}),n.push({type:`BUTTONS`,buttons:[{type:`OTP`}]}),{name:t.name,language:t.language,category:e.Authentication,components:n}}function p(t){let n=[],r=`Your security code is *{{1}}*.`;return t.add_security_recommendation&&(r+=` Do not share this code with anyone.`),t.code_expiration_minutes&&(r+=` This code expires in ${t.code_expiration_minutes} minutes.`),n.push({type:`BODY`,text:r,example:{body_text:[[`ABCD1234`]]}}),t.copy_code_button&&n.push({type:`BUTTONS`,buttons:[{type:`COPY_CODE`,example:`ABCD1234`}]}),{name:t.name,language:t.language,category:e.Authentication,components:n}}function m(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`CATALOG`,action:{thumbnail_product_retailer_id:t.thumbnail_product_retailer_id}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function h(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`COPY_CODE`,example:t.coupon_code}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function g(t){let n=[];return n.push({type:`LIMITED_TIME_OFFER`,limited_time_offer:{expiration_time_ms:t.expiration_time_ms}}),t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),{name:t.name,language:t.language,category:e.Marketing,components:n}}function _(t){let n=[],r=[];return t.cards.forEach((e,t)=>{let n=[];n.push({type:`HEADER`,format:e.header.format,example:e.header.example}),n.push(s(e.body)),e.buttons&&n.push(...l(e.buttons)),r.push({card_index:t,components:n})}),n.push({type:`CAROUSEL`,cards:r}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function v(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`MPM`,action:{thumbnail_product_retailer_id:t.thumbnail_product_retailer_id,sections:t.sections}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function y(t){let n=[];t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer));let r=t.cards.map((e,t)=>({card_index:t,components:[{type:`HEADER`,format:`PRODUCT`,example:{header_handle:[e.product_retailer_id]}}]}));return n.push({type:`CAROUSEL`,cards:r}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function b(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`SPM`,action:{product_retailer_id:t.product_retailer_id}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}export{a as TemplateApi,p as createAuthenticationTemplate,m as createCatalogTemplate,h as createCouponTemplate,g as createLimitedTimeOfferTemplate,v as createMPMTemplate,_ as createMediaCardCarouselTemplate,f as createOTPTemplate,y as createProductCardCarouselTemplate,b as createSPMTemplate,d as createTemplate};
2
- //# sourceMappingURL=template-Bgy-BCXJ.js.map