meta-cloud-api 0.2.11 → 0.2.13

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 (297) hide show
  1. package/README.md +5 -2
  2. package/dist/api/index.d.mts +495 -27
  3. package/dist/api/index.mjs +1 -1
  4. package/dist/api/index.mjs.map +1 -1
  5. package/dist/chunk-KZQQJAPX.mjs +2 -0
  6. package/dist/chunk-KZQQJAPX.mjs.map +1 -0
  7. package/dist/chunk-N7A7DQDX.mjs +2 -0
  8. package/dist/chunk-N7A7DQDX.mjs.map +1 -0
  9. package/dist/chunk-QE4PKOSW.mjs +2 -0
  10. package/dist/chunk-QE4PKOSW.mjs.map +1 -0
  11. package/dist/chunk-R4CFE2XP.mjs +2 -0
  12. package/dist/chunk-R4CFE2XP.mjs.map +1 -0
  13. package/dist/chunk-XVYL7ZTG.mjs +2 -0
  14. package/dist/chunk-XVYL7ZTG.mjs.map +1 -0
  15. package/dist/index.d.mts +142 -43
  16. package/dist/index.mjs +2 -2
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/types/index.d.mts +512 -19
  19. package/dist/types/index.mjs +1 -1
  20. package/dist/types/index.mjs.map +1 -1
  21. package/dist/utils/index.d.mts +70 -21
  22. package/dist/utils/index.mjs +1 -1
  23. package/dist/utils/index.mjs.map +1 -1
  24. package/dist/waba-RRlZTQUG.d.mts +2229 -0
  25. package/dist/{types/whatsapp.d.ts → whatsapp-BNHXjrds.d.mts} +2 -17
  26. package/package.json +52 -18
  27. package/dist/api/base.d.mts +0 -15
  28. package/dist/api/base.d.ts +0 -15
  29. package/dist/api/base.js +0 -2
  30. package/dist/api/base.js.map +0 -1
  31. package/dist/api/base.mjs +0 -2
  32. package/dist/api/base.mjs.map +0 -1
  33. package/dist/api/businessProfile.d.mts +0 -145
  34. package/dist/api/businessProfile.d.ts +0 -145
  35. package/dist/api/businessProfile.js +0 -2
  36. package/dist/api/businessProfile.js.map +0 -1
  37. package/dist/api/businessProfile.mjs +0 -2
  38. package/dist/api/businessProfile.mjs.map +0 -1
  39. package/dist/api/encryption.d.mts +0 -15
  40. package/dist/api/encryption.d.ts +0 -15
  41. package/dist/api/encryption.js +0 -2
  42. package/dist/api/encryption.js.map +0 -1
  43. package/dist/api/encryption.mjs +0 -2
  44. package/dist/api/encryption.mjs.map +0 -1
  45. package/dist/api/flow.d.mts +0 -126
  46. package/dist/api/flow.d.ts +0 -126
  47. package/dist/api/flow.js +0 -2
  48. package/dist/api/flow.js.map +0 -1
  49. package/dist/api/flow.mjs +0 -2
  50. package/dist/api/flow.mjs.map +0 -1
  51. package/dist/api/index.d.ts +0 -28
  52. package/dist/api/index.js +0 -2
  53. package/dist/api/index.js.map +0 -1
  54. package/dist/api/media.d.mts +0 -17
  55. package/dist/api/media.d.ts +0 -17
  56. package/dist/api/media.js +0 -2
  57. package/dist/api/media.js.map +0 -1
  58. package/dist/api/media.mjs +0 -2
  59. package/dist/api/media.mjs.map +0 -1
  60. package/dist/api/messages.d.mts +0 -193
  61. package/dist/api/messages.d.ts +0 -193
  62. package/dist/api/messages.js +0 -2
  63. package/dist/api/messages.js.map +0 -1
  64. package/dist/api/messages.mjs +0 -2
  65. package/dist/api/messages.mjs.map +0 -1
  66. package/dist/api/phoneNumber.d.mts +0 -17
  67. package/dist/api/phoneNumber.d.ts +0 -17
  68. package/dist/api/phoneNumber.js +0 -2
  69. package/dist/api/phoneNumber.js.map +0 -1
  70. package/dist/api/phoneNumber.mjs +0 -2
  71. package/dist/api/phoneNumber.mjs.map +0 -1
  72. package/dist/api/qrCode.d.mts +0 -18
  73. package/dist/api/qrCode.d.ts +0 -18
  74. package/dist/api/qrCode.js +0 -2
  75. package/dist/api/qrCode.js.map +0 -1
  76. package/dist/api/qrCode.mjs +0 -2
  77. package/dist/api/qrCode.mjs.map +0 -1
  78. package/dist/api/registration.d.mts +0 -14
  79. package/dist/api/registration.d.ts +0 -14
  80. package/dist/api/registration.js +0 -2
  81. package/dist/api/registration.js.map +0 -1
  82. package/dist/api/registration.mjs +0 -2
  83. package/dist/api/registration.mjs.map +0 -1
  84. package/dist/api/template.d.mts +0 -18
  85. package/dist/api/template.d.ts +0 -18
  86. package/dist/api/template.js +0 -2
  87. package/dist/api/template.js.map +0 -1
  88. package/dist/api/template.mjs +0 -2
  89. package/dist/api/template.mjs.map +0 -1
  90. package/dist/api/twoStepVerification.d.mts +0 -13
  91. package/dist/api/twoStepVerification.d.ts +0 -13
  92. package/dist/api/twoStepVerification.js +0 -2
  93. package/dist/api/twoStepVerification.js.map +0 -1
  94. package/dist/api/twoStepVerification.mjs +0 -2
  95. package/dist/api/twoStepVerification.mjs.map +0 -1
  96. package/dist/api/waba.d.mts +0 -16
  97. package/dist/api/waba.d.ts +0 -16
  98. package/dist/api/waba.js +0 -2
  99. package/dist/api/waba.js.map +0 -1
  100. package/dist/api/waba.mjs +0 -2
  101. package/dist/api/waba.mjs.map +0 -1
  102. package/dist/enums-CI7vzKhn.d.mts +0 -687
  103. package/dist/enums-CI7vzKhn.d.ts +0 -687
  104. package/dist/httpsClient.d.mts +0 -22
  105. package/dist/httpsClient.d.ts +0 -22
  106. package/dist/httpsClient.js +0 -2
  107. package/dist/httpsClient.js.map +0 -1
  108. package/dist/httpsClient.mjs +0 -2
  109. package/dist/httpsClient.mjs.map +0 -1
  110. package/dist/index.d.ts +0 -46
  111. package/dist/index.js +0 -3
  112. package/dist/index.js.map +0 -1
  113. package/dist/request.d.mts +0 -25
  114. package/dist/request.d.ts +0 -25
  115. package/dist/request.js +0 -2
  116. package/dist/request.js.map +0 -1
  117. package/dist/request.mjs +0 -2
  118. package/dist/request.mjs.map +0 -1
  119. package/dist/types/base.d.mts +0 -8
  120. package/dist/types/base.d.ts +0 -8
  121. package/dist/types/base.js +0 -2
  122. package/dist/types/base.js.map +0 -1
  123. package/dist/types/base.mjs +0 -1
  124. package/dist/types/base.mjs.map +0 -1
  125. package/dist/types/businessProfile.d.mts +0 -153
  126. package/dist/types/businessProfile.d.ts +0 -153
  127. package/dist/types/businessProfile.js +0 -2
  128. package/dist/types/businessProfile.js.map +0 -1
  129. package/dist/types/businessProfile.mjs +0 -1
  130. package/dist/types/businessProfile.mjs.map +0 -1
  131. package/dist/types/config.d.mts +0 -62
  132. package/dist/types/config.d.ts +0 -62
  133. package/dist/types/config.js +0 -2
  134. package/dist/types/config.js.map +0 -1
  135. package/dist/types/config.mjs +0 -1
  136. package/dist/types/config.mjs.map +0 -1
  137. package/dist/types/encryption.d.mts +0 -13
  138. package/dist/types/encryption.d.ts +0 -13
  139. package/dist/types/encryption.js +0 -2
  140. package/dist/types/encryption.js.map +0 -1
  141. package/dist/types/encryption.mjs +0 -1
  142. package/dist/types/encryption.mjs.map +0 -1
  143. package/dist/types/enums.d.mts +0 -1
  144. package/dist/types/enums.d.ts +0 -1
  145. package/dist/types/enums.js +0 -2
  146. package/dist/types/enums.js.map +0 -1
  147. package/dist/types/enums.mjs +0 -2
  148. package/dist/types/enums.mjs.map +0 -1
  149. package/dist/types/flow.d.mts +0 -404
  150. package/dist/types/flow.d.ts +0 -404
  151. package/dist/types/flow.js +0 -2
  152. package/dist/types/flow.js.map +0 -1
  153. package/dist/types/flow.mjs +0 -2
  154. package/dist/types/flow.mjs.map +0 -1
  155. package/dist/types/httpsClient.d.mts +0 -19
  156. package/dist/types/httpsClient.d.ts +0 -19
  157. package/dist/types/httpsClient.js +0 -2
  158. package/dist/types/httpsClient.js.map +0 -1
  159. package/dist/types/httpsClient.mjs +0 -1
  160. package/dist/types/httpsClient.mjs.map +0 -1
  161. package/dist/types/index.d.ts +0 -20
  162. package/dist/types/index.js +0 -2
  163. package/dist/types/index.js.map +0 -1
  164. package/dist/types/logger.d.mts +0 -9
  165. package/dist/types/logger.d.ts +0 -9
  166. package/dist/types/logger.js +0 -2
  167. package/dist/types/logger.js.map +0 -1
  168. package/dist/types/logger.mjs +0 -1
  169. package/dist/types/logger.mjs.map +0 -1
  170. package/dist/types/media.d.mts +0 -31
  171. package/dist/types/media.d.ts +0 -31
  172. package/dist/types/media.js +0 -2
  173. package/dist/types/media.js.map +0 -1
  174. package/dist/types/media.mjs +0 -1
  175. package/dist/types/media.mjs.map +0 -1
  176. package/dist/types/messages.d.mts +0 -558
  177. package/dist/types/messages.d.ts +0 -558
  178. package/dist/types/messages.js +0 -2
  179. package/dist/types/messages.js.map +0 -1
  180. package/dist/types/messages.mjs +0 -1
  181. package/dist/types/messages.mjs.map +0 -1
  182. package/dist/types/phoneNumber.d.mts +0 -82
  183. package/dist/types/phoneNumber.d.ts +0 -82
  184. package/dist/types/phoneNumber.js +0 -2
  185. package/dist/types/phoneNumber.js.map +0 -1
  186. package/dist/types/phoneNumber.mjs +0 -1
  187. package/dist/types/phoneNumber.mjs.map +0 -1
  188. package/dist/types/qrCode.d.mts +0 -27
  189. package/dist/types/qrCode.d.ts +0 -27
  190. package/dist/types/qrCode.js +0 -2
  191. package/dist/types/qrCode.js.map +0 -1
  192. package/dist/types/qrCode.mjs +0 -1
  193. package/dist/types/qrCode.mjs.map +0 -1
  194. package/dist/types/registration.d.mts +0 -14
  195. package/dist/types/registration.d.ts +0 -14
  196. package/dist/types/registration.js +0 -2
  197. package/dist/types/registration.js.map +0 -1
  198. package/dist/types/registration.mjs +0 -1
  199. package/dist/types/registration.mjs.map +0 -1
  200. package/dist/types/request.d.mts +0 -50
  201. package/dist/types/request.d.ts +0 -50
  202. package/dist/types/request.js +0 -2
  203. package/dist/types/request.js.map +0 -1
  204. package/dist/types/request.mjs +0 -1
  205. package/dist/types/request.mjs.map +0 -1
  206. package/dist/types/template.d.mts +0 -106
  207. package/dist/types/template.d.ts +0 -106
  208. package/dist/types/template.js +0 -2
  209. package/dist/types/template.js.map +0 -1
  210. package/dist/types/template.mjs +0 -1
  211. package/dist/types/template.mjs.map +0 -1
  212. package/dist/types/twoStepVerification.d.mts +0 -11
  213. package/dist/types/twoStepVerification.d.ts +0 -11
  214. package/dist/types/twoStepVerification.js +0 -2
  215. package/dist/types/twoStepVerification.js.map +0 -1
  216. package/dist/types/twoStepVerification.mjs +0 -1
  217. package/dist/types/twoStepVerification.mjs.map +0 -1
  218. package/dist/types/waba.d.mts +0 -78
  219. package/dist/types/waba.d.ts +0 -78
  220. package/dist/types/waba.js +0 -2
  221. package/dist/types/waba.js.map +0 -1
  222. package/dist/types/waba.mjs +0 -2
  223. package/dist/types/waba.mjs.map +0 -1
  224. package/dist/types/webhook.d.mts +0 -486
  225. package/dist/types/webhook.d.ts +0 -486
  226. package/dist/types/webhook.js +0 -2
  227. package/dist/types/webhook.js.map +0 -1
  228. package/dist/types/webhook.mjs +0 -2
  229. package/dist/types/webhook.mjs.map +0 -1
  230. package/dist/types/whatsapp.d.mts +0 -61
  231. package/dist/types/whatsapp.js +0 -2
  232. package/dist/types/whatsapp.js.map +0 -1
  233. package/dist/types/whatsapp.mjs +0 -1
  234. package/dist/types/whatsapp.mjs.map +0 -1
  235. package/dist/utils/buildFieldsQueryString.d.mts +0 -3
  236. package/dist/utils/buildFieldsQueryString.d.ts +0 -3
  237. package/dist/utils/buildFieldsQueryString.js +0 -2
  238. package/dist/utils/buildFieldsQueryString.js.map +0 -1
  239. package/dist/utils/buildFieldsQueryString.mjs +0 -2
  240. package/dist/utils/buildFieldsQueryString.mjs.map +0 -1
  241. package/dist/utils/filters.d.mts +0 -144
  242. package/dist/utils/filters.d.ts +0 -144
  243. package/dist/utils/filters.js +0 -2
  244. package/dist/utils/filters.js.map +0 -1
  245. package/dist/utils/filters.mjs +0 -2
  246. package/dist/utils/filters.mjs.map +0 -1
  247. package/dist/utils/flowTypeGuards.d.mts +0 -46
  248. package/dist/utils/flowTypeGuards.d.ts +0 -46
  249. package/dist/utils/flowTypeGuards.js +0 -2
  250. package/dist/utils/flowTypeGuards.js.map +0 -1
  251. package/dist/utils/flowTypeGuards.mjs +0 -2
  252. package/dist/utils/flowTypeGuards.mjs.map +0 -1
  253. package/dist/utils/generateXHub256Sig.d.mts +0 -3
  254. package/dist/utils/generateXHub256Sig.d.ts +0 -3
  255. package/dist/utils/generateXHub256Sig.js +0 -2
  256. package/dist/utils/generateXHub256Sig.js.map +0 -1
  257. package/dist/utils/generateXHub256Sig.mjs +0 -2
  258. package/dist/utils/generateXHub256Sig.mjs.map +0 -1
  259. package/dist/utils/importConfig.d.mts +0 -21
  260. package/dist/utils/importConfig.d.ts +0 -21
  261. package/dist/utils/importConfig.js +0 -2
  262. package/dist/utils/importConfig.js.map +0 -1
  263. package/dist/utils/importConfig.mjs +0 -2
  264. package/dist/utils/importConfig.mjs.map +0 -1
  265. package/dist/utils/index.d.ts +0 -22
  266. package/dist/utils/index.js +0 -2
  267. package/dist/utils/index.js.map +0 -1
  268. package/dist/utils/isMetaError.d.mts +0 -21
  269. package/dist/utils/isMetaError.d.ts +0 -21
  270. package/dist/utils/isMetaError.js +0 -2
  271. package/dist/utils/isMetaError.js.map +0 -1
  272. package/dist/utils/isMetaError.mjs +0 -2
  273. package/dist/utils/isMetaError.mjs.map +0 -1
  274. package/dist/utils/logger.d.mts +0 -13
  275. package/dist/utils/logger.d.ts +0 -13
  276. package/dist/utils/logger.js +0 -2
  277. package/dist/utils/logger.js.map +0 -1
  278. package/dist/utils/logger.mjs +0 -2
  279. package/dist/utils/logger.mjs.map +0 -1
  280. package/dist/utils/objectToQueryString.d.mts +0 -3
  281. package/dist/utils/objectToQueryString.d.ts +0 -3
  282. package/dist/utils/objectToQueryString.js +0 -2
  283. package/dist/utils/objectToQueryString.js.map +0 -1
  284. package/dist/utils/objectToQueryString.mjs +0 -2
  285. package/dist/utils/objectToQueryString.mjs.map +0 -1
  286. package/dist/webhook.d.mts +0 -123
  287. package/dist/webhook.d.ts +0 -123
  288. package/dist/webhook.js +0 -3
  289. package/dist/webhook.js.map +0 -1
  290. package/dist/webhook.mjs +0 -3
  291. package/dist/webhook.mjs.map +0 -1
  292. package/dist/whatsapp.d.mts +0 -58
  293. package/dist/whatsapp.d.ts +0 -58
  294. package/dist/whatsapp.js +0 -2
  295. package/dist/whatsapp.js.map +0 -1
  296. package/dist/whatsapp.mjs +0 -2
  297. package/dist/whatsapp.mjs.map +0 -1
@@ -1,19 +1,4 @@
1
- import { BusinessProfileClass } from './businessProfile.js';
2
- import { EncryptionClass } from './encryption.js';
3
- import { FlowClass } from './flow.js';
4
- import { MediaClass } from './media.js';
5
- import { MessagesClass } from './messages.js';
6
- import { PhoneNumberClass } from './phoneNumber.js';
7
- import { QrCodeClass } from './qrCode.js';
8
- import { RegistrationClass } from './registration.js';
9
- import { TemplateClass } from './template.js';
10
- import { TwoStepVerificationClass } from './twoStepVerification.js';
11
- import { WABAClass } from './waba.js';
12
- import '../enums-CI7vzKhn.js';
13
- import './request.js';
14
- import 'http';
15
- import './base.js';
16
- import './config.js';
1
+ import { M as MessagesClass, T as TemplateClass, P as PhoneNumberClass, Q as QrCodeClass, E as EncryptionClass, a as TwoStepVerificationClass, R as RegistrationClass, b as MediaClass, W as WABAClass, F as FlowClass, B as BusinessProfileClass } from './waba-RRlZTQUG.mjs';
17
2
 
18
3
  /**
19
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -58,4 +43,4 @@ declare class WhatsAppClass {
58
43
  updateWabaId(wabaId: string): boolean;
59
44
  }
60
45
 
61
- export { WhatsAppClass, type WhatsAppConfig };
46
+ export { WhatsAppClass as W, type WhatsAppConfig as a };
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "meta-cloud-api",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "TypeScript wrapper for Meta's Cloud API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "prepare": "husky",
9
+ "cz": "cz",
10
+ "dev": "tsup --watch",
11
+ "build": "tsup --clean",
12
+ "format": "prettier .",
13
+ "lint": "eslint .",
14
+ "clean": "rm -rf dist node_modules",
15
+ "typecheck": "tsc --noEmit"
16
+ },
7
17
  "publishConfig": {
8
18
  "access": "public"
9
19
  },
@@ -30,13 +40,6 @@
30
40
  },
31
41
  "./package.json": "./package.json"
32
42
  },
33
- "files": [
34
- "dist",
35
- "README.md"
36
- ],
37
- "engines": {
38
- "node": ">=18"
39
- },
40
43
  "keywords": [
41
44
  "whatsapp-api",
42
45
  "cloud-api",
@@ -70,18 +73,49 @@
70
73
  "bugs": {
71
74
  "url": "https://github.com/froggy1014/meta-cloud-api/issues"
72
75
  },
76
+ "files": [
77
+ "dist",
78
+ "README.md"
79
+ ],
80
+ "engines": {
81
+ "node": ">=18"
82
+ },
73
83
  "devDependencies": {
74
- "@types/node": "^22.13.4",
84
+ "@changesets/cli": "^2.28.1",
85
+ "@commitlint/cli": "^19.6.1",
86
+ "@commitlint/config-conventional": "^19.6.0",
87
+ "@commitlint/cz-commitlint": "^19.6.1",
88
+ "@commitlint/types": "^19.5.0",
89
+ "@eslint/eslintrc": "^3.2.0",
90
+ "@eslint/js": "^9.17.0",
91
+ "@types/eslint-config-prettier": "^6.11.3",
92
+ "@types/eslint__eslintrc": "^2.1.2",
93
+ "@types/node": "^22.15.29",
94
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
95
+ "@typescript-eslint/parser": "^8.15.0",
96
+ "commitizen": "^4.3.1",
75
97
  "dotenv": "^16.4.7",
98
+ "eslint": "^9.20.1",
99
+ "eslint-config-prettier": "^9.1.0",
100
+ "eslint-plugin-only-warn": "^1.1.0",
101
+ "eslint-plugin-unused-imports": "^4.1.4",
102
+ "husky": "^9.1.7",
103
+ "lint-staged": "^15.3.0",
104
+ "prettier": "^3.5.0",
76
105
  "tsup": "^8.3.6",
77
106
  "typescript": "^5.7.3",
78
- "@repo/typescript-config": "0.0.0"
107
+ "typescript-eslint": "^8.23.0"
79
108
  },
80
- "scripts": {
81
- "test": "echo \"Error: no test specified\" && exit 1",
82
- "dev": "tsup --watch",
83
- "build": "tsup --clean",
84
- "clean": "rm -rf dist node_modules",
85
- "typecheck": "tsc --noEmit"
86
- }
87
- }
109
+ "lint-staged": {
110
+ "**/*.{ts,tsx}": [
111
+ "prettier --write --ignore-unknown",
112
+ "eslint --fix"
113
+ ]
114
+ },
115
+ "config": {
116
+ "commitizen": {
117
+ "path": "@commitlint/cz-commitlint"
118
+ }
119
+ },
120
+ "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
121
+ }
@@ -1,15 +0,0 @@
1
- import { H as HttpMethodsEnum } from '../enums-CI7vzKhn.mjs';
2
- import { BaseClass } from '../types/base.mjs';
3
- import { WabaConfigType } from '../types/config.mjs';
4
- import { RequesterClass } from '../types/request.mjs';
5
-
6
- declare class BaseAPI implements BaseClass {
7
- protected config: WabaConfigType;
8
- protected client: RequesterClass;
9
- constructor(config: WabaConfigType, client: RequesterClass);
10
- protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
11
- protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
12
- protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
13
- }
14
-
15
- export { BaseAPI as default };
@@ -1,15 +0,0 @@
1
- import { H as HttpMethodsEnum } from '../enums-CI7vzKhn.js';
2
- import { BaseClass } from '../types/base.js';
3
- import { WabaConfigType } from '../types/config.js';
4
- import { RequesterClass } from '../types/request.js';
5
-
6
- declare class BaseAPI implements BaseClass {
7
- protected config: WabaConfigType;
8
- protected client: RequesterClass;
9
- constructor(config: WabaConfigType, client: RequesterClass);
10
- protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
11
- protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
12
- protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
13
- }
14
-
15
- export { BaseAPI as default };
package/dist/api/base.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=(o,e)=>{for(var t in e)a(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!m.call(o,n)&&n!==t&&a(o,n,{get:()=>e[n],enumerable:!(s=p(e,n))||s.enumerable});return o};var d=o=>f(a({},"__esModule",{value:!0}),o);var h={};c(h,{default:()=>i});module.exports=d(h);var r=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var g="BaseAPI",u=!1,y=new r(g,process.env.DEBUG==="true"||u),i=class{config;client;constructor(e,t){this.config=e,this.client=t,y.log("Initialized with HTTPSClient")}sendJson(e,t,s,n){return this.client.getJson(e,t,s,n)}sendFormData(e,t,s,n){return this.client.sendFormData(e,t,s,n)}sendUrlEncodedForm(e,t,s,n){return this.client.sendUrlEncodedForm(e,t,s,n)}};
2
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/base.ts","../../src/utils/logger.ts"],"sourcesContent":["import { HttpMethodsEnum } from '../types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\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 protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\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"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD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wB,CAC1G,OAAO,KAAK,OAAO,aAAgBH,EAAQC,EAAUC,EAASC,CAAI,CACtE,CAEU,mBACNH,EACAC,EACAC,EACAC,EACU,CACV,OAAO,KAAK,OAAO,mBAAsBH,EAAQC,EAAUC,EAASC,CAAI,CAC5E,CACJ","names":["base_exports","__export","BaseAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body"]}
package/dist/api/base.mjs DELETED
@@ -1,2 +0,0 @@
1
- var s=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var a="BaseAPI",p=!1,l=new s(a,process.env.DEBUG==="true"||p),r=class{config;client;constructor(t,e){this.config=t,this.client=e,l.log("Initialized with HTTPSClient")}sendJson(t,e,n,o){return this.client.getJson(t,e,n,o)}sendFormData(t,e,n,o){return this.client.sendFormData(t,e,n,o)}sendUrlEncodedForm(t,e,n,o){return this.client.sendUrlEncodedForm(t,e,n,o)}};export{r as default};
2
- //# sourceMappingURL=base.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["// @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 { HttpMethodsEnum } from '../types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\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 protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAA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,CAAI,CACtE,CAEU,mBACNH,EACAC,EACAC,EACAC,EACU,CACV,OAAO,KAAK,OAAO,mBAAsBH,EAAQC,EAAUC,EAASC,CAAI,CAC5E,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body"]}
@@ -1,145 +0,0 @@
1
- import { BusinessProfileClass, BusinessProfileFieldsParam, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadBusinessProfileResponse, UploadHandle } from '../types/businessProfile.mjs';
2
- import { WabaConfigType } from '../types/config.mjs';
3
- import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
- import BaseAPI from './base.mjs';
5
- import '../enums-CI7vzKhn.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
- * // Using the BusinessProfileFieldsParam type
40
- * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);
41
- */
42
- getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
43
- /**
44
- * Update your business profile.
45
- *
46
- * Use this method to update one or more fields of your WhatsApp business profile.
47
- *
48
- * @param updateRequest The request object containing the fields to update.
49
- * - messaging_product: Required. Always set to "whatsapp".
50
- * - about: Optional. Business's About text (1-139 characters).
51
- * - address: Optional. Business address (max 256 characters).
52
- * - description: Optional. Business description (max 512 characters).
53
- * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
54
- * - email: Optional. Contact email (valid format, max 128 characters).
55
- * - websites: Optional. Up to 2 URLs (max 256 characters each).
56
- * - profile_picture_handle: Optional. Handle from upload process.
57
- * @returns Response indicating success or failure.
58
- *
59
- * @example
60
- * // Update business profile with multiple fields including vertical using enum
61
- * await whatsappClient.businessProfile.updateBusinessProfile({
62
- * messaging_product: 'whatsapp',
63
- * about: 'We provide excellent service',
64
- * email: 'contact@example.com',
65
- * websites: ['https://example.com'],
66
- * vertical: BusinessVerticalEnum.RETAIL
67
- * });
68
- */
69
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
70
- /**
71
- * Create an upload session for a profile picture.
72
- *
73
- * This is the first step in the profile picture upload process.
74
- *
75
- * @param fileLength Length of the file to be uploaded in bytes.
76
- * @param fileType MIME type of the file (e.g., 'image/jpeg').
77
- * @param fileName Name of the file with extension.
78
- * @returns Response containing the upload session ID needed for the next step.
79
- *
80
- * @example
81
- * // Create upload session for profile picture
82
- * const session = await whatsappClient.businessProfile.createUploadSession(
83
- * fileBuffer.length,
84
- * 'image/jpeg',
85
- * 'profile.jpg'
86
- * );
87
- * const uploadSessionId = session.upload_session_id;
88
- */
89
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
90
- /**
91
- * Upload media file to the upload session.
92
- *
93
- * This is the second step in the profile picture upload process.
94
- * Upload the binary content of the file to the previously created upload session.
95
- *
96
- * @param uploadId The upload session ID from createUploadSession response.
97
- * @param file The binary data of the file (Buffer).
98
- * @returns Response indicating success or failure.
99
- *
100
- * @example
101
- * // Upload the actual file content
102
- * await whatsappClient.businessProfile.uploadMedia(
103
- * uploadSessionId,
104
- * fileBuffer
105
- * );
106
- */
107
- uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
108
- /**
109
- * Get the upload handle information.
110
- *
111
- * This is the third step in the profile picture upload process.
112
- * After uploading the file, get the handle to use when updating the profile.
113
- *
114
- * @param uploadId The upload session ID from createUploadSession response.
115
- * @returns Response containing the upload handle information.
116
- *
117
- * @example
118
- * // Complete profile picture update process
119
- * // 1. Create upload session
120
- * const session = await whatsappClient.businessProfile.createUploadSession(
121
- * fileBuffer.length, 'image/jpeg', 'profile.jpg'
122
- * );
123
- *
124
- * // 2. Upload the image data
125
- * await whatsappClient.businessProfile.uploadMedia(
126
- * session.upload_session_id, fileBuffer
127
- * );
128
- *
129
- * // 3. Get the handle for the uploaded file
130
- * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
131
- * session.upload_session_id
132
- * );
133
- *
134
- * // 4. Update profile with new picture and business information
135
- * await whatsappClient.businessProfile.updateBusinessProfile({
136
- * messaging_product: 'whatsapp',
137
- * profile_picture_handle: handleInfo.handle,
138
- * vertical: BusinessVerticalEnum.RESTAURANT,
139
- * about: 'Delicious food served daily'
140
- * });
141
- */
142
- getUploadHandle(uploadId: string): Promise<UploadHandle>;
143
- }
144
-
145
- export { BusinessProfileAPI as default };
@@ -1,145 +0,0 @@
1
- import { BusinessProfileClass, BusinessProfileFieldsParam, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadBusinessProfileResponse, UploadHandle } from '../types/businessProfile.js';
2
- import { WabaConfigType } from '../types/config.js';
3
- import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
- import BaseAPI from './base.js';
5
- import '../enums-CI7vzKhn.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
- * // Using the BusinessProfileFieldsParam type
40
- * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);
41
- */
42
- getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
43
- /**
44
- * Update your business profile.
45
- *
46
- * Use this method to update one or more fields of your WhatsApp business profile.
47
- *
48
- * @param updateRequest The request object containing the fields to update.
49
- * - messaging_product: Required. Always set to "whatsapp".
50
- * - about: Optional. Business's About text (1-139 characters).
51
- * - address: Optional. Business address (max 256 characters).
52
- * - description: Optional. Business description (max 512 characters).
53
- * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
54
- * - email: Optional. Contact email (valid format, max 128 characters).
55
- * - websites: Optional. Up to 2 URLs (max 256 characters each).
56
- * - profile_picture_handle: Optional. Handle from upload process.
57
- * @returns Response indicating success or failure.
58
- *
59
- * @example
60
- * // Update business profile with multiple fields including vertical using enum
61
- * await whatsappClient.businessProfile.updateBusinessProfile({
62
- * messaging_product: 'whatsapp',
63
- * about: 'We provide excellent service',
64
- * email: 'contact@example.com',
65
- * websites: ['https://example.com'],
66
- * vertical: BusinessVerticalEnum.RETAIL
67
- * });
68
- */
69
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
70
- /**
71
- * Create an upload session for a profile picture.
72
- *
73
- * This is the first step in the profile picture upload process.
74
- *
75
- * @param fileLength Length of the file to be uploaded in bytes.
76
- * @param fileType MIME type of the file (e.g., 'image/jpeg').
77
- * @param fileName Name of the file with extension.
78
- * @returns Response containing the upload session ID needed for the next step.
79
- *
80
- * @example
81
- * // Create upload session for profile picture
82
- * const session = await whatsappClient.businessProfile.createUploadSession(
83
- * fileBuffer.length,
84
- * 'image/jpeg',
85
- * 'profile.jpg'
86
- * );
87
- * const uploadSessionId = session.upload_session_id;
88
- */
89
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
90
- /**
91
- * Upload media file to the upload session.
92
- *
93
- * This is the second step in the profile picture upload process.
94
- * Upload the binary content of the file to the previously created upload session.
95
- *
96
- * @param uploadId The upload session ID from createUploadSession response.
97
- * @param file The binary data of the file (Buffer).
98
- * @returns Response indicating success or failure.
99
- *
100
- * @example
101
- * // Upload the actual file content
102
- * await whatsappClient.businessProfile.uploadMedia(
103
- * uploadSessionId,
104
- * fileBuffer
105
- * );
106
- */
107
- uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
108
- /**
109
- * Get the upload handle information.
110
- *
111
- * This is the third step in the profile picture upload process.
112
- * After uploading the file, get the handle to use when updating the profile.
113
- *
114
- * @param uploadId The upload session ID from createUploadSession response.
115
- * @returns Response containing the upload handle information.
116
- *
117
- * @example
118
- * // Complete profile picture update process
119
- * // 1. Create upload session
120
- * const session = await whatsappClient.businessProfile.createUploadSession(
121
- * fileBuffer.length, 'image/jpeg', 'profile.jpg'
122
- * );
123
- *
124
- * // 2. Upload the image data
125
- * await whatsappClient.businessProfile.uploadMedia(
126
- * session.upload_session_id, fileBuffer
127
- * );
128
- *
129
- * // 3. Get the handle for the uploaded file
130
- * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
131
- * session.upload_session_id
132
- * );
133
- *
134
- * // 4. Update profile with new picture and business information
135
- * await whatsappClient.businessProfile.updateBusinessProfile({
136
- * messaging_product: 'whatsapp',
137
- * profile_picture_handle: handleInfo.handle,
138
- * vertical: BusinessVerticalEnum.RESTAURANT,
139
- * about: 'Delicious food served daily'
140
- * });
141
- */
142
- getUploadHandle(uploadId: string): Promise<UploadHandle>;
143
- }
144
-
145
- export { BusinessProfileAPI as default };
@@ -1,2 +0,0 @@
1
- "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var I=(i,t)=>{for(var R in t)U(i,R,{get:t[R],enumerable:!0})},T=(i,t,R,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of O(t))!p.call(i,A)&&A!==R&&U(i,A,{get:()=>t[A],enumerable:!(P=G(t,A))||P.enumerable});return i};var K=i=>T(U({},"__esModule",{value:!0}),i);var F={};I(F,{default:()=>N});module.exports=K(F);function l(i){if(!i)return"";let t="";return Array.isArray(i)?t=i.join(","):t=Object.entries(i).filter(([R,P])=>P).map(([R])=>R).join(","),t?`?fields=${t}`:""}var B=i=>{if(!i||Object.keys(i).length===0)return"";let t=new URLSearchParams;for(let[P,A]of Object.entries(i))A!==void 0&&t.append(P,String(A));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 _="BaseAPI",M=!1,f=new S(_,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,f.log("Initialized with HTTPSClient")}sendJson(t,R,P,A){return this.client.getJson(t,R,P,A)}sendFormData(t,R,P,A){return this.client.sendFormData(t,R,P,A)}sendUrlEncodedForm(t,R,P,A){return this.client.sendUrlEncodedForm(t,R,P,A)}};var N=class extends D{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${l(t)}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,P){let A=B({file_length:t,file_type:R,file_name:P});return this.sendJson("POST",`app/uploads/${A}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};
2
- //# sourceMappingURL=businessProfile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/businessProfile.ts","../../src/utils/buildFieldsQueryString.ts","../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import { buildFieldsQueryString } from '../utils/buildFieldsQueryString';\nimport {\n BusinessProfileClass,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, 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 * // Using the BusinessProfileFieldsParam type\n * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);\n */\n async getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<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: 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(fileLength: number, fileType: string, fileName: string): Promise<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<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<UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","export function buildFieldsQueryString(fields?: string[]): string {\n if (!fields) return '';\n\n let fieldParams = '';\n\n if (Array.isArray(fields)) {\n fieldParams = fields.join(',');\n } else {\n fieldParams = Object.entries(fields)\n .filter(([_, value]) => value)\n .map(([key]) => key)\n .join(',');\n }\n\n return fieldParams ? `?fields=${fieldParams}` : '';\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 { HttpMethodsEnum } from '../types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\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 protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCAO,SAASI,EAAuBC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O,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBAAoBC,EAAoBC,EAAkBC,EAAkD,CAC9G,IAAMC,EAAcC,EAAoB,CACpC,YAAaJ,EACb,UAAWC,EACX,UAAWC,CACf,CAAC,EAED,OAAO,KAAK,gBAER,eAAeC,CAAW,GAC1B,KAAK,OAAO,gBACZ,IACJ,CACJ,CAmBA,MAAM,YAAYE,EAAkBC,EAAsD,CACtF,OAAO,KAAK,gBAA+B,GAAGD,CAAQ,GAAI,KAAK,OAAO,gBAAgCC,CAAI,CAC9G,CAoCA,MAAM,gBAAgBD,EAAyC,CAC3D,OAAO,KAAK,eAA8B,GAAGA,CAAQ,GAAI,KAAK,OAAO,gBAAgC,IAAI,CAC7G,CACJ","names":["businessProfile_exports","__export","BusinessProfileAPI","__toCommonJS","buildFieldsQueryString","fields","fieldParams","_","value","key","objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","BusinessProfileAPI","BaseAPI","config","client","fields","buildFieldsQueryString","updateRequest","fileLength","fileType","fileName","queryParams","objectToQueryString","uploadId","file"]}
@@ -1,2 +0,0 @@
1
- function U(i){if(!i)return"";let t="";return Array.isArray(i)?t=i.join(","):t=Object.entries(i).filter(([R,A])=>A).map(([R])=>R).join(","),t?`?fields=${t}`:""}var l=i=>{if(!i||Object.keys(i).length===0)return"";let t=new URLSearchParams;for(let[A,P]of Object.entries(i))P!==void 0&&t.append(A,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),D=class{config;client;constructor(t,R){this.config=t,this.client=R,O.log("Initialized with HTTPSClient")}sendJson(t,R,A,P){return this.client.getJson(t,R,A,P)}sendFormData(t,R,A,P){return this.client.sendFormData(t,R,A,P)}sendUrlEncodedForm(t,R,A,P){return this.client.sendUrlEncodedForm(t,R,A,P)}};var N=class extends D{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${U(t)}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,A){let P=l({file_length:t,file_type:R,file_name:A});return this.sendJson("POST",`app/uploads/${P}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};export{N as default};
2
- //# sourceMappingURL=businessProfile.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/buildFieldsQueryString.ts","../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/businessProfile.ts"],"sourcesContent":["export function buildFieldsQueryString(fields?: string[]): string {\n if (!fields) return '';\n\n let fieldParams = '';\n\n if (Array.isArray(fields)) {\n fieldParams = fields.join(',');\n } else {\n fieldParams = Object.entries(fields)\n .filter(([_, value]) => value)\n .map(([key]) => key)\n .join(',');\n }\n\n return fieldParams ? `?fields=${fieldParams}` : '';\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 { HttpMethodsEnum } from '../types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\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 protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body);\n }\n}\n","import { buildFieldsQueryString } from '../utils/buildFieldsQueryString';\nimport {\n BusinessProfileClass,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, 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 * // Using the BusinessProfileFieldsParam type\n * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);\n */\n async getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<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: 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(fileLength: number, fileType: string, fileName: string): Promise<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<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<UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[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GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBAAoBC,EAAoBC,EAAkBC,EAAkD,CAC9G,IAAMC,EAAcC,EAAoB,CACpC,YAAaJ,EACb,UAAWC,EACX,UAAWC,CACf,CAAC,EAED,OAAO,KAAK,gBAER,eAAeC,CAAW,GAC1B,KAAK,OAAO,gBACZ,IACJ,CACJ,CAmBA,MAAM,YAAYE,EAAkBC,EAAsD,CACtF,OAAO,KAAK,gBAA+B,GAAGD,CAAQ,GAAI,KAAK,OAAO,gBAAgCC,CAAI,CAC9G,CAoCA,MAAM,gBAAgBD,EAAyC,CAC3D,OAAO,KAAK,eAA8B,GAAGA,CAAQ,GAAI,KAAK,OAAO,gBAAgC,IAAI,CAC7G,CACJ","names":["buildFieldsQueryString","fields","fieldParams","_","value","key","objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","BusinessProfileAPI","BaseAPI","config","client","fields","buildFieldsQueryString","updateRequest","fileLength","fileType","fileName","queryParams","objectToQueryString","uploadId","file"]}
@@ -1,15 +0,0 @@
1
- import { WabaConfigType } from '../types/config.mjs';
2
- import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
3
- import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
- import BaseAPI from './base.mjs';
5
- import '../enums-CI7vzKhn.mjs';
6
- import '../types/base.mjs';
7
-
8
- declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
9
- private readonly endpoint;
10
- constructor(config: WabaConfigType, client: RequesterClass);
11
- getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
12
- setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
13
- }
14
-
15
- export { EncryptionAPI as default };
@@ -1,15 +0,0 @@
1
- import { WabaConfigType } from '../types/config.js';
2
- import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
3
- import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
- import BaseAPI from './base.js';
5
- import '../enums-CI7vzKhn.js';
6
- import '../types/base.js';
7
-
8
- declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
9
- private readonly endpoint;
10
- constructor(config: WabaConfigType, client: RequesterClass);
11
- getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
12
- setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
13
- }
14
-
15
- export { EncryptionAPI as default };
@@ -1,2 +0,0 @@
1
- "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var I=(P,t)=>{for(var R in t)U(P,R,{get:t[R],enumerable:!0})},K=(P,t,R,S)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of O(t))!B.call(P,A)&&A!==R&&U(P,A,{get:()=>t[A],enumerable:!(S=G(t,A))||S.enumerable});return P};var p=P=>K(U({},"__esModule",{value:!0}),P);var M={};I(M,{default:()=>i});module.exports=p(M);var D=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 T="BaseAPI",l=!1,_=new D(T,process.env.DEBUG==="true"||l),N=class{config;client;constructor(t,R){this.config=t,this.client=R,_.log("Initialized with HTTPSClient")}sendJson(t,R,S,A){return this.client.getJson(t,R,S,A)}sendFormData(t,R,S,A){return this.client.sendFormData(t,R,S,A)}sendUrlEncodedForm(t,R,S,A){return this.client.sendUrlEncodedForm(t,R,S,A)}};var i=class extends N{endpoint="whatsapp_business_encryption";constructor(t,R){super(t,R)}async getEncryptionPublicKey(){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,R)}};
2
- //# sourceMappingURL=encryption.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/encryption.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import type { WabaConfigType } from '../types/config';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse> {\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 async setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\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","// @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 { HttpMethodsEnum } from '../types/enums';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport Logger from '../utils/logger';\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 protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n\n protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.sendFormData<T>(method, endpoint, timeout, body);\n }\n\n protected sendUrlEncodedForm<T>(\n method: HttpMethodsEnum,\n endpoint: string,\n timeout: number,\n body?: any,\n ): Promise<T> {\n return this.client.sendUrlEncodedForm<T>(method, endpoint, timeout, body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,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CAEU,aAAgBH,EAAyBC,EAAkBC,EAAiBC,EAAwB,CAC1G,OAAO,KAAK,OAAO,aAAgBH,EAAQC,EAAUC,EAASC,CAAI,CACtE,CAEU,mBACNH,EACAC,EACAC,EACAC,EACU,CACV,OAAO,KAAK,OAAO,mBAAsBH,EAAQC,EAAUC,EAASC,CAAI,CAC5E,CACJ,EF9BA,IAAqBC,EAArB,cAA2CC,CAAmC,CACzD,SAAW,+BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAEA,MAAM,wBAA+D,CACjE,OAAO,KAAK,eAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,uBAAuBC,EAAqD,CAC9E,IAAMC,EAAW,IAAI,SACrB,OAAAA,EAAS,OAAO,sBAAuBD,CAAiB,EAEjD,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZC,CACJ,CACJ,CACJ","names":["encryption_exports","__export","EncryptionAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData"]}