meta-cloud-api 0.0.4 → 0.0.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 (135) hide show
  1. package/dist/api/base.d.mts +1 -1
  2. package/dist/api/base.d.ts +1 -1
  3. package/dist/api/businessProfile.d.mts +142 -0
  4. package/dist/api/businessProfile.d.ts +142 -0
  5. package/dist/api/businessProfile.js +2 -0
  6. package/dist/api/businessProfile.js.map +1 -0
  7. package/dist/api/businessProfile.mjs +2 -0
  8. package/dist/api/businessProfile.mjs.map +1 -0
  9. package/dist/api/encryption.d.mts +1 -1
  10. package/dist/api/encryption.d.ts +1 -1
  11. package/dist/api/encryption.js +1 -1
  12. package/dist/api/encryption.mjs +1 -1
  13. package/dist/api/flow.d.mts +1 -1
  14. package/dist/api/flow.d.ts +1 -1
  15. package/dist/api/flow.js +1 -1
  16. package/dist/api/flow.mjs +1 -1
  17. package/dist/api/index.d.mts +16 -14
  18. package/dist/api/index.d.ts +16 -14
  19. package/dist/api/index.js +1 -1
  20. package/dist/api/index.js.map +1 -1
  21. package/dist/api/index.mjs +1 -1
  22. package/dist/api/index.mjs.map +1 -1
  23. package/dist/api/media.d.mts +1 -1
  24. package/dist/api/media.d.ts +1 -1
  25. package/dist/api/media.js +1 -1
  26. package/dist/api/media.mjs +1 -1
  27. package/dist/api/messages.d.mts +1 -1
  28. package/dist/api/messages.d.ts +1 -1
  29. package/dist/api/messages.js +1 -1
  30. package/dist/api/messages.mjs +1 -1
  31. package/dist/api/phoneNumber.d.mts +1 -1
  32. package/dist/api/phoneNumber.d.ts +1 -1
  33. package/dist/api/phoneNumber.js +1 -1
  34. package/dist/api/phoneNumber.mjs +1 -1
  35. package/dist/api/qrCode.d.mts +1 -1
  36. package/dist/api/qrCode.d.ts +1 -1
  37. package/dist/api/qrCode.js +1 -1
  38. package/dist/api/qrCode.mjs +1 -1
  39. package/dist/api/registration.d.mts +1 -1
  40. package/dist/api/registration.d.ts +1 -1
  41. package/dist/api/registration.js +1 -1
  42. package/dist/api/registration.mjs +1 -1
  43. package/dist/api/template.d.mts +1 -1
  44. package/dist/api/template.d.ts +1 -1
  45. package/dist/api/template.js +1 -1
  46. package/dist/api/template.mjs +1 -1
  47. package/dist/api/twoStepVerification.d.mts +1 -1
  48. package/dist/api/twoStepVerification.d.ts +1 -1
  49. package/dist/api/twoStepVerification.js +1 -1
  50. package/dist/api/twoStepVerification.mjs +1 -1
  51. package/dist/api/waba.d.mts +1 -1
  52. package/dist/api/waba.d.ts +1 -1
  53. package/dist/api/waba.js +1 -1
  54. package/dist/api/waba.mjs +1 -1
  55. package/dist/{enums-D6WRUWH9.d.mts → enums-Dn5Y1Nom.d.mts} +94 -2
  56. package/dist/{enums-D6WRUWH9.d.ts → enums-Dn5Y1Nom.d.ts} +94 -2
  57. package/dist/httpsClient.d.mts +1 -1
  58. package/dist/httpsClient.d.ts +1 -1
  59. package/dist/index.d.mts +20 -18
  60. package/dist/index.d.ts +20 -18
  61. package/dist/index.js +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +1 -1
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/request.d.mts +1 -1
  66. package/dist/request.d.ts +1 -1
  67. package/dist/types/base.d.mts +1 -1
  68. package/dist/types/base.d.ts +1 -1
  69. package/dist/types/businessProfile.d.mts +147 -0
  70. package/dist/types/businessProfile.d.ts +147 -0
  71. package/dist/types/businessProfile.js +2 -0
  72. package/dist/types/businessProfile.js.map +1 -0
  73. package/dist/types/businessProfile.mjs +1 -0
  74. package/dist/types/businessProfile.mjs.map +1 -0
  75. package/dist/types/config.d.mts +1 -1
  76. package/dist/types/config.d.ts +1 -1
  77. package/dist/types/encryption.d.mts +1 -1
  78. package/dist/types/encryption.d.ts +1 -1
  79. package/dist/types/enums.d.mts +1 -1
  80. package/dist/types/enums.d.ts +1 -1
  81. package/dist/types/enums.js +1 -1
  82. package/dist/types/enums.js.map +1 -1
  83. package/dist/types/enums.mjs +1 -1
  84. package/dist/types/enums.mjs.map +1 -1
  85. package/dist/types/flow.d.mts +1 -1
  86. package/dist/types/flow.d.ts +1 -1
  87. package/dist/types/httpsClient.d.mts +1 -1
  88. package/dist/types/httpsClient.d.ts +1 -1
  89. package/dist/types/index.d.mts +3 -1
  90. package/dist/types/index.d.ts +3 -1
  91. package/dist/types/index.js +1 -1
  92. package/dist/types/index.js.map +1 -1
  93. package/dist/types/index.mjs +1 -1
  94. package/dist/types/index.mjs.map +1 -1
  95. package/dist/types/media.d.mts +1 -1
  96. package/dist/types/media.d.ts +1 -1
  97. package/dist/types/messages.d.mts +1 -1
  98. package/dist/types/messages.d.ts +1 -1
  99. package/dist/types/phoneNumber.d.mts +1 -1
  100. package/dist/types/phoneNumber.d.ts +1 -1
  101. package/dist/types/qrCode.d.mts +1 -1
  102. package/dist/types/qrCode.d.ts +1 -1
  103. package/dist/types/registration.d.mts +1 -1
  104. package/dist/types/registration.d.ts +1 -1
  105. package/dist/types/request.d.mts +1 -1
  106. package/dist/types/request.d.ts +1 -1
  107. package/dist/types/template.d.mts +1 -1
  108. package/dist/types/template.d.ts +1 -1
  109. package/dist/types/twoStepVerification.d.mts +1 -1
  110. package/dist/types/twoStepVerification.d.ts +1 -1
  111. package/dist/types/waba.d.mts +1 -1
  112. package/dist/types/waba.d.ts +1 -1
  113. package/dist/types/whatsapp.d.mts +28 -0
  114. package/dist/types/whatsapp.d.ts +28 -0
  115. package/dist/types/whatsapp.js +1 -1
  116. package/dist/types/whatsapp.js.map +1 -1
  117. package/dist/utils/importConfig.d.mts +15 -2
  118. package/dist/utils/importConfig.d.ts +15 -2
  119. package/dist/utils/importConfig.js +1 -1
  120. package/dist/utils/importConfig.js.map +1 -1
  121. package/dist/utils/importConfig.mjs +1 -1
  122. package/dist/utils/importConfig.mjs.map +1 -1
  123. package/dist/utils/index.d.mts +15 -2
  124. package/dist/utils/index.d.ts +15 -2
  125. package/dist/utils/index.js +1 -1
  126. package/dist/utils/index.js.map +1 -1
  127. package/dist/utils/index.mjs +1 -1
  128. package/dist/utils/index.mjs.map +1 -1
  129. package/dist/whatsapp.d.mts +21 -18
  130. package/dist/whatsapp.d.ts +21 -18
  131. package/dist/whatsapp.js +1 -1
  132. package/dist/whatsapp.js.map +1 -1
  133. package/dist/whatsapp.mjs +1 -1
  134. package/dist/whatsapp.mjs.map +1 -1
  135. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { BaseClass } from '../types/base.mjs';
2
2
  import { WabaConfigType } from '../types/config.mjs';
3
3
  import { RequesterClass } from '../types/request.mjs';
4
- import '../enums-D6WRUWH9.mjs';
4
+ import '../enums-Dn5Y1Nom.mjs';
5
5
 
6
6
  declare class BaseAPI implements BaseClass {
7
7
  protected config: WabaConfigType;
@@ -1,7 +1,7 @@
1
1
  import { BaseClass } from '../types/base.js';
2
2
  import { WabaConfigType } from '../types/config.js';
3
3
  import { RequesterClass } from '../types/request.js';
4
- import '../enums-D6WRUWH9.js';
4
+ import '../enums-Dn5Y1Nom.js';
5
5
 
6
6
  declare class BaseAPI implements BaseClass {
7
7
  protected config: WabaConfigType;
@@ -0,0 +1,142 @@
1
+ import { BusinessProfileClass, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadHandle } from '../types/businessProfile.mjs';
2
+ import { WabaConfigType } from '../types/config.mjs';
3
+ import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
4
+ import BaseAPI from './base.mjs';
5
+ import '../enums-Dn5Y1Nom.mjs';
6
+ import '../types/base.mjs';
7
+
8
+ /**
9
+ * API for managing WhatsApp Business Profiles and profile pictures.
10
+ *
11
+ * This API allows you to:
12
+ * - Get business profile information
13
+ * - Update business profile details
14
+ * - Upload profile pictures using a three-step process:
15
+ * 1. Create an upload session
16
+ * 2. Upload the image binary data
17
+ * 3. Get the upload handle to use when updating the profile
18
+ */
19
+ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {
20
+ private readonly endpoint;
21
+ constructor(config: WabaConfigType, client: RequesterClass);
22
+ /**
23
+ * Get your business profile information.
24
+ *
25
+ * Use this method to retrieve details about your WhatsApp business profile, including
26
+ * about text, address, description, email, profile picture URL, websites, and vertical.
27
+ *
28
+ * @param fields Fields to be returned in the response. If not specified, all fields will be returned.
29
+ * Possible values: about, address, description, email, profile_picture_url, websites, vertical
30
+ * @returns The business profile information.
31
+ *
32
+ * @example
33
+ * // Get all business profile fields
34
+ * const profile = await whatsappClient.businessProfile.getBusinessProfile();
35
+ *
36
+ * // Get specific business profile fields
37
+ * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
38
+ */
39
+ getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>>;
40
+ /**
41
+ * Update your business profile.
42
+ *
43
+ * Use this method to update one or more fields of your WhatsApp business profile.
44
+ *
45
+ * @param updateRequest The request object containing the fields to update.
46
+ * - messaging_product: Required. Always set to "whatsapp".
47
+ * - about: Optional. Business's About text (1-139 characters).
48
+ * - address: Optional. Business address (max 256 characters).
49
+ * - description: Optional. Business description (max 512 characters).
50
+ * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
51
+ * - email: Optional. Contact email (valid format, max 128 characters).
52
+ * - websites: Optional. Up to 2 URLs (max 256 characters each).
53
+ * - profile_picture_handle: Optional. Handle from upload process.
54
+ * @returns Response indicating success or failure.
55
+ *
56
+ * @example
57
+ * // Update business profile with multiple fields including vertical using enum
58
+ * await whatsappClient.businessProfile.updateBusinessProfile({
59
+ * messaging_product: 'whatsapp',
60
+ * about: 'We provide excellent service',
61
+ * email: 'contact@example.com',
62
+ * websites: ['https://example.com'],
63
+ * vertical: BusinessVerticalEnum.RETAIL
64
+ * });
65
+ */
66
+ updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<RequesterResponseInterface<ResponseSuccess>>;
67
+ /**
68
+ * Create an upload session for a profile picture.
69
+ *
70
+ * This is the first step in the profile picture upload process.
71
+ *
72
+ * @param fileLength Length of the file to be uploaded in bytes.
73
+ * @param fileType MIME type of the file (e.g., 'image/jpeg').
74
+ * @param fileName Name of the file with extension.
75
+ * @returns Response containing the upload session ID needed for the next step.
76
+ *
77
+ * @example
78
+ * // Create upload session for profile picture
79
+ * const session = await whatsappClient.businessProfile.createUploadSession(
80
+ * fileBuffer.length,
81
+ * 'image/jpeg',
82
+ * 'profile.jpg'
83
+ * );
84
+ * const uploadSessionId = session.upload_session_id;
85
+ */
86
+ createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<RequesterResponseInterface<UploadSessionResponse>>;
87
+ /**
88
+ * Upload media file to the upload session.
89
+ *
90
+ * This is the second step in the profile picture upload process.
91
+ * Upload the binary content of the file to the previously created upload session.
92
+ *
93
+ * @param uploadId The upload session ID from createUploadSession response.
94
+ * @param file The binary data of the file (Buffer).
95
+ * @returns Response indicating success or failure.
96
+ *
97
+ * @example
98
+ * // Upload the actual file content
99
+ * await whatsappClient.businessProfile.uploadMedia(
100
+ * uploadSessionId,
101
+ * fileBuffer
102
+ * );
103
+ */
104
+ uploadMedia(uploadId: string, file: Buffer): Promise<RequesterResponseInterface<ResponseSuccess>>;
105
+ /**
106
+ * Get the upload handle information.
107
+ *
108
+ * This is the third step in the profile picture upload process.
109
+ * After uploading the file, get the handle to use when updating the profile.
110
+ *
111
+ * @param uploadId The upload session ID from createUploadSession response.
112
+ * @returns Response containing the upload handle information.
113
+ *
114
+ * @example
115
+ * // Complete profile picture update process
116
+ * // 1. Create upload session
117
+ * const session = await whatsappClient.businessProfile.createUploadSession(
118
+ * fileBuffer.length, 'image/jpeg', 'profile.jpg'
119
+ * );
120
+ *
121
+ * // 2. Upload the image data
122
+ * await whatsappClient.businessProfile.uploadMedia(
123
+ * session.upload_session_id, fileBuffer
124
+ * );
125
+ *
126
+ * // 3. Get the handle for the uploaded file
127
+ * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
128
+ * session.upload_session_id
129
+ * );
130
+ *
131
+ * // 4. Update profile with new picture and business information
132
+ * await whatsappClient.businessProfile.updateBusinessProfile({
133
+ * messaging_product: 'whatsapp',
134
+ * profile_picture_handle: handleInfo.handle,
135
+ * vertical: BusinessVerticalEnum.RESTAURANT,
136
+ * about: 'Delicious food served daily'
137
+ * });
138
+ */
139
+ getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>>;
140
+ }
141
+
142
+ export { BusinessProfileAPI as default };
@@ -0,0 +1,142 @@
1
+ import { BusinessProfileClass, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadHandle } from '../types/businessProfile.js';
2
+ import { WabaConfigType } from '../types/config.js';
3
+ import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
4
+ import BaseAPI from './base.js';
5
+ import '../enums-Dn5Y1Nom.js';
6
+ import '../types/base.js';
7
+
8
+ /**
9
+ * API for managing WhatsApp Business Profiles and profile pictures.
10
+ *
11
+ * This API allows you to:
12
+ * - Get business profile information
13
+ * - Update business profile details
14
+ * - Upload profile pictures using a three-step process:
15
+ * 1. Create an upload session
16
+ * 2. Upload the image binary data
17
+ * 3. Get the upload handle to use when updating the profile
18
+ */
19
+ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {
20
+ private readonly endpoint;
21
+ constructor(config: WabaConfigType, client: RequesterClass);
22
+ /**
23
+ * Get your business profile information.
24
+ *
25
+ * Use this method to retrieve details about your WhatsApp business profile, including
26
+ * about text, address, description, email, profile picture URL, websites, and vertical.
27
+ *
28
+ * @param fields Fields to be returned in the response. If not specified, all fields will be returned.
29
+ * Possible values: about, address, description, email, profile_picture_url, websites, vertical
30
+ * @returns The business profile information.
31
+ *
32
+ * @example
33
+ * // Get all business profile fields
34
+ * const profile = await whatsappClient.businessProfile.getBusinessProfile();
35
+ *
36
+ * // Get specific business profile fields
37
+ * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
38
+ */
39
+ getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>>;
40
+ /**
41
+ * Update your business profile.
42
+ *
43
+ * Use this method to update one or more fields of your WhatsApp business profile.
44
+ *
45
+ * @param updateRequest The request object containing the fields to update.
46
+ * - messaging_product: Required. Always set to "whatsapp".
47
+ * - about: Optional. Business's About text (1-139 characters).
48
+ * - address: Optional. Business address (max 256 characters).
49
+ * - description: Optional. Business description (max 512 characters).
50
+ * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
51
+ * - email: Optional. Contact email (valid format, max 128 characters).
52
+ * - websites: Optional. Up to 2 URLs (max 256 characters each).
53
+ * - profile_picture_handle: Optional. Handle from upload process.
54
+ * @returns Response indicating success or failure.
55
+ *
56
+ * @example
57
+ * // Update business profile with multiple fields including vertical using enum
58
+ * await whatsappClient.businessProfile.updateBusinessProfile({
59
+ * messaging_product: 'whatsapp',
60
+ * about: 'We provide excellent service',
61
+ * email: 'contact@example.com',
62
+ * websites: ['https://example.com'],
63
+ * vertical: BusinessVerticalEnum.RETAIL
64
+ * });
65
+ */
66
+ updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<RequesterResponseInterface<ResponseSuccess>>;
67
+ /**
68
+ * Create an upload session for a profile picture.
69
+ *
70
+ * This is the first step in the profile picture upload process.
71
+ *
72
+ * @param fileLength Length of the file to be uploaded in bytes.
73
+ * @param fileType MIME type of the file (e.g., 'image/jpeg').
74
+ * @param fileName Name of the file with extension.
75
+ * @returns Response containing the upload session ID needed for the next step.
76
+ *
77
+ * @example
78
+ * // Create upload session for profile picture
79
+ * const session = await whatsappClient.businessProfile.createUploadSession(
80
+ * fileBuffer.length,
81
+ * 'image/jpeg',
82
+ * 'profile.jpg'
83
+ * );
84
+ * const uploadSessionId = session.upload_session_id;
85
+ */
86
+ createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<RequesterResponseInterface<UploadSessionResponse>>;
87
+ /**
88
+ * Upload media file to the upload session.
89
+ *
90
+ * This is the second step in the profile picture upload process.
91
+ * Upload the binary content of the file to the previously created upload session.
92
+ *
93
+ * @param uploadId The upload session ID from createUploadSession response.
94
+ * @param file The binary data of the file (Buffer).
95
+ * @returns Response indicating success or failure.
96
+ *
97
+ * @example
98
+ * // Upload the actual file content
99
+ * await whatsappClient.businessProfile.uploadMedia(
100
+ * uploadSessionId,
101
+ * fileBuffer
102
+ * );
103
+ */
104
+ uploadMedia(uploadId: string, file: Buffer): Promise<RequesterResponseInterface<ResponseSuccess>>;
105
+ /**
106
+ * Get the upload handle information.
107
+ *
108
+ * This is the third step in the profile picture upload process.
109
+ * After uploading the file, get the handle to use when updating the profile.
110
+ *
111
+ * @param uploadId The upload session ID from createUploadSession response.
112
+ * @returns Response containing the upload handle information.
113
+ *
114
+ * @example
115
+ * // Complete profile picture update process
116
+ * // 1. Create upload session
117
+ * const session = await whatsappClient.businessProfile.createUploadSession(
118
+ * fileBuffer.length, 'image/jpeg', 'profile.jpg'
119
+ * );
120
+ *
121
+ * // 2. Upload the image data
122
+ * await whatsappClient.businessProfile.uploadMedia(
123
+ * session.upload_session_id, fileBuffer
124
+ * );
125
+ *
126
+ * // 3. Get the handle for the uploaded file
127
+ * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
128
+ * session.upload_session_id
129
+ * );
130
+ *
131
+ * // 4. Update profile with new picture and business information
132
+ * await whatsappClient.businessProfile.updateBusinessProfile({
133
+ * messaging_product: 'whatsapp',
134
+ * profile_picture_handle: handleInfo.handle,
135
+ * vertical: BusinessVerticalEnum.RESTAURANT,
136
+ * about: 'Delicious food served daily'
137
+ * });
138
+ */
139
+ getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>>;
140
+ }
141
+
142
+ export { BusinessProfileAPI as default };
@@ -0,0 +1,2 @@
1
+ "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var I=(A,t)=>{for(var R in t)U(A,R,{get:t[R],enumerable:!0})},l=(A,t,R,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of O(t))!p.call(A,S)&&S!==R&&U(A,S,{get:()=>t[S],enumerable:!(i=G(t,S))||i.enumerable});return A};var T=A=>l(U({},"__esModule",{value:!0}),A);var f={};I(f,{default:()=>N});module.exports=T(f);var B=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[i,S]of Object.entries(A))S!==void 0&&t.append(i,String(S));let R=t.toString();return R?`?${R}`:""};var P=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var K="BaseAPI",M=!1,_=new P(K,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,_.log("Initialized with HTTPSClient")}};var N=class extends D{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){let R=t?B({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${R}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,i){let S=B({file_length:t,file_type:R,file_name:i});return this.client.sendRequest("POST",`app/uploads/${S}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};
2
+ //# sourceMappingURL=businessProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/api/businessProfile.ts","../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\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 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 async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\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(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\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<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\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<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\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<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"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","names":["businessProfile_exports","__export","BusinessProfileAPI","__toCommonJS","objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
@@ -0,0 +1,2 @@
1
+ var N=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[D,P]of Object.entries(A))P!==void 0&&t.append(D,String(P));let R=t.toString();return R?`?${R}`:""};var S=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var B="BaseAPI",G=!1,O=new S(B,process.env.DEBUG==="true"||G),i=class{config;client;constructor(t,R){this.config=t,this.client=R,O.log("Initialized with HTTPSClient")}};var U=class extends i{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){let R=t?N({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${R}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,D){let P=N({file_length:t,file_type:R,file_name:D});return this.client.sendRequest("POST",`app/uploads/${P}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};export{U as default};
2
+ //# sourceMappingURL=businessProfile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/businessProfile.ts"],"sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\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 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 async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\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(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\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<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\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<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\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<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n"],"mappings":"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","names":["objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
3
3
  import BaseAPI from './base.mjs';
4
4
  import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
5
- import '../enums-D6WRUWH9.mjs';
5
+ import '../enums-Dn5Y1Nom.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.js';
2
2
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
3
3
  import BaseAPI from './base.js';
4
4
  import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
5
- import '../enums-D6WRUWH9.js';
5
+ import '../enums-Dn5Y1Nom.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
@@ -1,2 +1,2 @@
1
- "use strict";var B=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var K=(i,t)=>{for(var R in t)B(i,R,{get:t[R],enumerable:!0})},p=(i,t,R,N)=>{if(t&&typeof t=="object"||typeof t=="function")for(let D of G(t))!l.call(i,D)&&D!==R&&B(i,D,{get:()=>t[D],enumerable:!(N=U(t,D))||N.enumerable});return i};var I=i=>p(B({},"__esModule",{value:!0}),i);var F={};K(F,{default:()=>P});module.exports=I(F);var S=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var O="BaseAPI",M=!1,_=new S(O,process.env.DEBUG==="true"||M),A=class{config;client;constructor(t,R){this.config=t,this.client=R,_.log("Initialized with HTTPSClient")}};var P=class extends A{endpoint="whatsapp_business_encryption";constructor(t,R){super(t,R)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let R=new FormData;return R.append("business_public_key",t),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,R)}};
1
+ "use strict";var i=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(A,R)=>{for(var t in R)i(A,t,{get:R[t],enumerable:!0})},K=(A,R,t,G)=>{if(R&&typeof R=="object"||typeof R=="function")for(let S of B(R))!O.call(A,S)&&S!==t&&i(A,S,{get:()=>R[S],enumerable:!(G=U(R,S))||G.enumerable});return A};var p=A=>K(i({},"__esModule",{value:!0}),A);var _={};I(_,{default:()=>N});module.exports=p(_);var D=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var T="BaseAPI",M=!1,l=new D(T,process.env.DEBUG==="true"||M),P=class{config;client;constructor(R,t){this.config=R,this.client=t,l.log("Initialized with HTTPSClient")}};var N=class extends P{endpoint="whatsapp_business_encryption";constructor(R,t){super(R,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(R){let t=new FormData;return t.append("business_public_key",R),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};
2
2
  //# sourceMappingURL=encryption.js.map
@@ -1,2 +1,2 @@
1
- var i=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var P="BaseAPI",B=!1,N=new i(P,process.env.DEBUG==="true"||B),D=class{config;client;constructor(R,t){this.config=R,this.client=t,N.log("Initialized with HTTPSClient")}};var S=class extends D{endpoint="whatsapp_business_encryption";constructor(R,t){super(R,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(R){let t=new FormData;return t.append("business_public_key",R),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};export{S as default};
1
+ var A=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var N="BaseAPI",i=!1,G=new A(N,process.env.DEBUG==="true"||i),S=class{config;client;constructor(t,R){this.config=t,this.client=R,G.log("Initialized with HTTPSClient")}};var D=class extends S{endpoint="whatsapp_business_encryption";constructor(t,R){super(t,R)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let R=new FormData;return R.append("business_public_key",t),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,R)}};export{D as default};
2
2
  //# sourceMappingURL=encryption.mjs.map
@@ -3,7 +3,7 @@ import { WabaConfigType } from '../types/config.mjs';
3
3
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
4
4
  import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.mjs';
5
5
  import '../types/base.mjs';
6
- import '../enums-D6WRUWH9.mjs';
6
+ import '../enums-Dn5Y1Nom.mjs';
7
7
 
8
8
  declare class FlowAPI extends BaseAPI implements FlowClass {
9
9
  constructor(config: WabaConfigType, client: RequesterClass);
@@ -3,7 +3,7 @@ import { WabaConfigType } from '../types/config.js';
3
3
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
4
4
  import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.js';
5
5
  import '../types/base.js';
6
- import '../enums-D6WRUWH9.js';
6
+ import '../enums-Dn5Y1Nom.js';
7
7
 
8
8
  declare class FlowAPI extends BaseAPI implements FlowClass {
9
9
  constructor(config: WabaConfigType, client: RequesterClass);
package/dist/api/flow.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var P=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var G=(l,i)=>{for(var t in i)P(l,t,{get:i[t],enumerable:!0})},U=(l,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let S of _(i))!f.call(l,S)&&S!==t&&P(l,S,{get:()=>i[S],enumerable:!(R=N(i,S))||R.enumerable});return l};var F=l=>U(P({},"__esModule",{value:!0}),l);var T={};G(T,{default:()=>A});module.exports=F(T);var p=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var I="BaseAPI",K=!1,O=new p(I,process.env.DEBUG==="true"||K),D=class{config;client;constructor(i,t){this.config=i,this.client=t,O.log("Initialized with HTTPSClient")}};var M="FlowAPI",w=!1,h=new p(M,process.env.DEBUG==="true"||w),A=class extends D{constructor(i,t){super(i,t),h.log("FlowAPI initialized")}async listFlows(i){return this.client.sendRequest("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let S=new URLSearchParams;t&&S.append("fields",t),R&&S.append("date_format",R);let B=S.toString()?`?${S.toString()}`:"";return this.client.sendRequest("GET",`/${i}${B}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.client.sendRequest("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.client.sendRequest("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.client.sendRequest("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.client.sendRequest("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.client.sendRequest("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.client.sendRequest("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};
1
+ "use strict";var p=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var O=(A,i)=>{for(var t in i)p(A,t,{get:i[t],enumerable:!0})},B=(A,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let S of _(i))!U.call(A,S)&&S!==t&&p(A,S,{get:()=>i[S],enumerable:!(R=G(i,S))||R.enumerable});return A};var I=A=>B(p({},"__esModule",{value:!0}),A);var h={};O(h,{default:()=>D});module.exports=I(h);var l=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var f="BaseAPI",F=!1,T=new l(f,process.env.DEBUG==="true"||F),P=class{config;client;constructor(i,t){this.config=i,this.client=t,T.log("Initialized with HTTPSClient")}};var K="FlowAPI",M=!1,w=new l(K,process.env.DEBUG==="true"||M),D=class extends P{constructor(i,t){super(i,t),w.log("FlowAPI initialized")}async listFlows(i){return this.client.sendRequest("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let S=new URLSearchParams;t&&S.append("fields",t),R&&S.append("date_format",R);let N=S.toString()?`?${S.toString()}`:"";return this.client.sendRequest("GET",`/${i}${N}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.client.sendRequest("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.client.sendRequest("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.client.sendRequest("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.client.sendRequest("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.client.sendRequest("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.client.sendRequest("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};
2
2
  //# sourceMappingURL=flow.js.map
package/dist/api/flow.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var l=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var B="BaseAPI",N=!1,_=new l(B,process.env.DEBUG==="true"||N),S=class{config;client;constructor(i,t){this.config=i,this.client=t,_.log("Initialized with HTTPSClient")}};var f="FlowAPI",G=!1,U=new l(f,process.env.DEBUG==="true"||G),D=class extends S{constructor(i,t){super(i,t),U.log("FlowAPI initialized")}async listFlows(i){return this.client.sendRequest("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let p=new URLSearchParams;t&&p.append("fields",t),R&&p.append("date_format",R);let P=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${i}${P}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.client.sendRequest("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.client.sendRequest("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.client.sendRequest("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.client.sendRequest("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.client.sendRequest("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.client.sendRequest("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};export{D as default};
1
+ var A=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var N="BaseAPI",G=!1,_=new A(N,process.env.DEBUG==="true"||G),S=class{config;client;constructor(i,t){this.config=i,this.client=t,_.log("Initialized with HTTPSClient")}};var U="FlowAPI",O=!1,B=new A(U,process.env.DEBUG==="true"||O),P=class extends S{constructor(i,t){super(i,t),B.log("FlowAPI initialized")}async listFlows(i){return this.client.sendRequest("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let l=new URLSearchParams;t&&l.append("fields",t),R&&l.append("date_format",R);let p=l.toString()?`?${l.toString()}`:"";return this.client.sendRequest("GET",`/${i}${p}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.client.sendRequest("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.client.sendRequest("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.client.sendRequest("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.client.sendRequest("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.client.sendRequest("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.client.sendRequest("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};export{P as default};
2
2
  //# sourceMappingURL=flow.mjs.map
@@ -1,25 +1,27 @@
1
- export { default as MessagesAPI } from './messages.mjs';
2
1
  export { default as BaseAPI } from './base.mjs';
2
+ export { default as BusinessProfileAPI } from './businessProfile.mjs';
3
+ export { default as EncryptionAPI } from './encryption.mjs';
4
+ export { default as FlowAPI } from './flow.mjs';
5
+ export { default as MediaAPI } from './media.mjs';
6
+ export { default as MessagesAPI } from './messages.mjs';
3
7
  export { default as PhoneNumberAPI } from './phoneNumber.mjs';
4
- export { default as TemplateAPI } from './template.mjs';
8
+ export { default as QrCodeAPI } from './qrCode.mjs';
5
9
  export { default as RegistrationAPI } from './registration.mjs';
10
+ export { default as TemplateAPI } from './template.mjs';
6
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.mjs';
7
- export { default as QrCodeAPI } from './qrCode.mjs';
8
- export { default as EncryptionAPI } from './encryption.mjs';
9
12
  export { default as WabaAPI } from './waba.mjs';
10
- export { default as MediaAPI } from './media.mjs';
11
- export { default as FlowAPI } from './flow.mjs';
12
- import '../types/config.mjs';
13
- import '../enums-D6WRUWH9.mjs';
14
- import '../types/messages.mjs';
15
13
  import '../types/base.mjs';
14
+ import '../types/config.mjs';
15
+ import '../enums-Dn5Y1Nom.mjs';
16
16
  import '../types/request.mjs';
17
+ import '../types/businessProfile.mjs';
18
+ import '../types/encryption.mjs';
19
+ import '../types/flow.mjs';
20
+ import '../types/media.mjs';
21
+ import '../types/messages.mjs';
17
22
  import '../types/phoneNumber.mjs';
18
- import '../types/template.mjs';
23
+ import '../types/qrCode.mjs';
19
24
  import '../types/registration.mjs';
25
+ import '../types/template.mjs';
20
26
  import '../types/twoStepVerification.mjs';
21
- import '../types/qrCode.mjs';
22
- import '../types/encryption.mjs';
23
27
  import '../types/waba.mjs';
24
- import '../types/media.mjs';
25
- import '../types/flow.mjs';
@@ -1,25 +1,27 @@
1
- export { default as MessagesAPI } from './messages.js';
2
1
  export { default as BaseAPI } from './base.js';
2
+ export { default as BusinessProfileAPI } from './businessProfile.js';
3
+ export { default as EncryptionAPI } from './encryption.js';
4
+ export { default as FlowAPI } from './flow.js';
5
+ export { default as MediaAPI } from './media.js';
6
+ export { default as MessagesAPI } from './messages.js';
3
7
  export { default as PhoneNumberAPI } from './phoneNumber.js';
4
- export { default as TemplateAPI } from './template.js';
8
+ export { default as QrCodeAPI } from './qrCode.js';
5
9
  export { default as RegistrationAPI } from './registration.js';
10
+ export { default as TemplateAPI } from './template.js';
6
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.js';
7
- export { default as QrCodeAPI } from './qrCode.js';
8
- export { default as EncryptionAPI } from './encryption.js';
9
12
  export { default as WabaAPI } from './waba.js';
10
- export { default as MediaAPI } from './media.js';
11
- export { default as FlowAPI } from './flow.js';
12
- import '../types/config.js';
13
- import '../enums-D6WRUWH9.js';
14
- import '../types/messages.js';
15
13
  import '../types/base.js';
14
+ import '../types/config.js';
15
+ import '../enums-Dn5Y1Nom.js';
16
16
  import '../types/request.js';
17
+ import '../types/businessProfile.js';
18
+ import '../types/encryption.js';
19
+ import '../types/flow.js';
20
+ import '../types/media.js';
21
+ import '../types/messages.js';
17
22
  import '../types/phoneNumber.js';
18
- import '../types/template.js';
23
+ import '../types/qrCode.js';
19
24
  import '../types/registration.js';
25
+ import '../types/template.js';
20
26
  import '../types/twoStepVerification.js';
21
- import '../types/qrCode.js';
22
- import '../types/encryption.js';
23
27
  import '../types/waba.js';
24
- import '../types/media.js';
25
- import '../types/flow.js';