meta-cloud-api 0.1.23 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) 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 +1 -1
  4. package/dist/api/businessProfile.d.ts +1 -1
  5. package/dist/api/businessProfile.js +1 -1
  6. package/dist/api/encryption.d.mts +1 -1
  7. package/dist/api/encryption.d.ts +1 -1
  8. package/dist/api/encryption.js +1 -1
  9. package/dist/api/encryption.mjs +1 -1
  10. package/dist/api/flow.d.mts +2 -1
  11. package/dist/api/flow.d.ts +2 -1
  12. package/dist/api/flow.js +1 -1
  13. package/dist/api/flow.mjs +1 -1
  14. package/dist/api/index.d.mts +2 -1
  15. package/dist/api/index.d.ts +2 -1
  16. package/dist/api/index.js +1 -1
  17. package/dist/api/index.mjs +1 -1
  18. package/dist/api/media.d.mts +1 -1
  19. package/dist/api/media.d.ts +1 -1
  20. package/dist/api/media.js +1 -1
  21. package/dist/api/media.mjs +1 -1
  22. package/dist/api/messages.d.mts +1 -1
  23. package/dist/api/messages.d.ts +1 -1
  24. package/dist/api/messages.js +1 -1
  25. package/dist/api/messages.mjs +1 -1
  26. package/dist/api/phoneNumber.d.mts +1 -1
  27. package/dist/api/phoneNumber.d.ts +1 -1
  28. package/dist/api/phoneNumber.js +1 -1
  29. package/dist/api/phoneNumber.mjs +1 -1
  30. package/dist/api/qrCode.d.mts +1 -1
  31. package/dist/api/qrCode.d.ts +1 -1
  32. package/dist/api/qrCode.js +1 -1
  33. package/dist/api/qrCode.mjs +1 -1
  34. package/dist/api/registration.d.mts +1 -1
  35. package/dist/api/registration.d.ts +1 -1
  36. package/dist/api/registration.js +1 -1
  37. package/dist/api/registration.mjs +1 -1
  38. package/dist/api/template.d.mts +1 -1
  39. package/dist/api/template.d.ts +1 -1
  40. package/dist/api/template.js +1 -1
  41. package/dist/api/template.mjs +1 -1
  42. package/dist/api/twoStepVerification.d.mts +1 -1
  43. package/dist/api/twoStepVerification.d.ts +1 -1
  44. package/dist/api/twoStepVerification.js +1 -1
  45. package/dist/api/twoStepVerification.mjs +1 -1
  46. package/dist/api/waba.d.mts +1 -1
  47. package/dist/api/waba.d.ts +1 -1
  48. package/dist/api/waba.js +1 -1
  49. package/dist/api/waba.mjs +1 -1
  50. package/dist/{enums-Bcd3jLw2.d.mts → enums-CI7vzKhn.d.mts} +3 -1
  51. package/dist/{enums-Bcd3jLw2.d.ts → enums-CI7vzKhn.d.ts} +3 -1
  52. package/dist/httpsClient.d.mts +1 -1
  53. package/dist/httpsClient.d.ts +1 -1
  54. package/dist/index.d.mts +3 -2
  55. package/dist/index.d.ts +3 -2
  56. package/dist/index.js +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.mjs +1 -1
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/request.d.mts +1 -1
  61. package/dist/request.d.ts +1 -1
  62. package/dist/types/base.d.mts +1 -1
  63. package/dist/types/base.d.ts +1 -1
  64. package/dist/types/businessProfile.d.mts +1 -1
  65. package/dist/types/businessProfile.d.ts +1 -1
  66. package/dist/types/config.d.mts +9 -1
  67. package/dist/types/config.d.ts +9 -1
  68. package/dist/types/config.js +1 -1
  69. package/dist/types/config.js.map +1 -1
  70. package/dist/types/encryption.d.mts +1 -1
  71. package/dist/types/encryption.d.ts +1 -1
  72. package/dist/types/enums.d.mts +1 -1
  73. package/dist/types/enums.d.ts +1 -1
  74. package/dist/types/enums.js +1 -1
  75. package/dist/types/enums.js.map +1 -1
  76. package/dist/types/enums.mjs +1 -1
  77. package/dist/types/enums.mjs.map +1 -1
  78. package/dist/types/flow.d.mts +114 -10
  79. package/dist/types/flow.d.ts +114 -10
  80. package/dist/types/flow.js +1 -1
  81. package/dist/types/flow.js.map +1 -1
  82. package/dist/types/flow.mjs +1 -1
  83. package/dist/types/flow.mjs.map +1 -1
  84. package/dist/types/httpsClient.d.mts +1 -1
  85. package/dist/types/httpsClient.d.ts +1 -1
  86. package/dist/types/index.d.mts +3 -2
  87. package/dist/types/index.d.ts +3 -2
  88. package/dist/types/index.js +1 -1
  89. package/dist/types/index.js.map +1 -1
  90. package/dist/types/index.mjs +1 -1
  91. package/dist/types/index.mjs.map +1 -1
  92. package/dist/types/media.d.mts +1 -1
  93. package/dist/types/media.d.ts +1 -1
  94. package/dist/types/messages.d.mts +1 -1
  95. package/dist/types/messages.d.ts +1 -1
  96. package/dist/types/phoneNumber.d.mts +1 -1
  97. package/dist/types/phoneNumber.d.ts +1 -1
  98. package/dist/types/qrCode.d.mts +1 -1
  99. package/dist/types/qrCode.d.ts +1 -1
  100. package/dist/types/registration.d.mts +1 -1
  101. package/dist/types/registration.d.ts +1 -1
  102. package/dist/types/request.d.mts +1 -1
  103. package/dist/types/request.d.ts +1 -1
  104. package/dist/types/template.d.mts +1 -1
  105. package/dist/types/template.d.ts +1 -1
  106. package/dist/types/twoStepVerification.d.mts +1 -1
  107. package/dist/types/twoStepVerification.d.ts +1 -1
  108. package/dist/types/waba.d.mts +1 -1
  109. package/dist/types/waba.d.ts +1 -1
  110. package/dist/types/webhook.d.mts +1 -1
  111. package/dist/types/webhook.d.ts +1 -1
  112. package/dist/types/whatsapp.d.mts +4 -1
  113. package/dist/types/whatsapp.d.ts +4 -1
  114. package/dist/types/whatsapp.js +1 -1
  115. package/dist/types/whatsapp.js.map +1 -1
  116. package/dist/utils/filters.d.mts +1 -1
  117. package/dist/utils/filters.d.ts +1 -1
  118. package/dist/utils/filters.js +1 -1
  119. package/dist/utils/filters.mjs +1 -1
  120. package/dist/utils/importConfig.d.mts +2 -1
  121. package/dist/utils/importConfig.d.ts +2 -1
  122. package/dist/utils/importConfig.js +1 -1
  123. package/dist/utils/importConfig.js.map +1 -1
  124. package/dist/utils/importConfig.mjs +1 -1
  125. package/dist/utils/importConfig.mjs.map +1 -1
  126. package/dist/utils/index.d.mts +2 -1
  127. package/dist/utils/index.d.ts +2 -1
  128. package/dist/utils/index.js +1 -1
  129. package/dist/utils/index.js.map +1 -1
  130. package/dist/utils/index.mjs +1 -1
  131. package/dist/utils/index.mjs.map +1 -1
  132. package/dist/webhook.d.mts +13 -4
  133. package/dist/webhook.d.ts +13 -4
  134. package/dist/webhook.js +1 -1
  135. package/dist/webhook.js.map +1 -1
  136. package/dist/webhook.mjs +1 -1
  137. package/dist/webhook.mjs.map +1 -1
  138. package/dist/whatsapp.d.mts +2 -1
  139. package/dist/whatsapp.d.ts +2 -1
  140. package/dist/whatsapp.js +1 -1
  141. package/dist/whatsapp.js.map +1 -1
  142. package/dist/whatsapp.mjs +1 -1
  143. package/dist/whatsapp.mjs.map +1 -1
  144. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { H as HttpMethodsEnum } from '../enums-Bcd3jLw2.mjs';
1
+ import { H as HttpMethodsEnum } from '../enums-CI7vzKhn.mjs';
2
2
  import { BaseClass } from '../types/base.mjs';
3
3
  import { WabaConfigType } from '../types/config.mjs';
4
4
  import { RequesterClass } from '../types/request.mjs';
@@ -1,4 +1,4 @@
1
- import { H as HttpMethodsEnum } from '../enums-Bcd3jLw2.js';
1
+ import { H as HttpMethodsEnum } from '../enums-CI7vzKhn.js';
2
2
  import { BaseClass } from '../types/base.js';
3
3
  import { WabaConfigType } from '../types/config.js';
4
4
  import { RequesterClass } from '../types/request.js';
@@ -2,7 +2,7 @@ import { BusinessProfileClass, BusinessProfileFieldsParam, BusinessProfileRespon
2
2
  import { WabaConfigType } from '../types/config.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@ import { BusinessProfileClass, BusinessProfileFieldsParam, BusinessProfileRespon
2
2
  import { WabaConfigType } from '../types/config.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  /**
@@ -1,2 +1,2 @@
1
- "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var T=(i,t)=>{for(var R in t)U(i,R,{get:t[R],enumerable:!0})},I=(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=>I(U({},"__esModule",{value:!0}),i);var F={};T(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 f="BaseAPI",M=!1,_=new S(f,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,_.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)}};
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
2
  //# sourceMappingURL=businessProfile.js.map
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.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 { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.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 U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(S,t)=>{for(var R in t)U(S,R,{get:t[R],enumerable:!0})},K=(S,t,R,D)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of B(t))!O.call(S,A)&&A!==R&&U(S,A,{get:()=>t[A],enumerable:!(D=G(t,A))||D.enumerable});return S};var p=S=>K(U({},"__esModule",{value:!0}),S);var _={};I(_,{default:()=>i});module.exports=p(_);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 T="BaseAPI",l=!1,M=new P(T,process.env.DEBUG==="true"||l),N=class{config;client;constructor(t,R){this.config=t,this.client=R,M.log("Initialized with HTTPSClient")}sendJson(t,R,D,A){return this.client.getJson(t,R,D,A)}sendFormData(t,R,D,A){return this.client.sendFormData(t,R,D,A)}sendUrlEncodedForm(t,R,D,A){return this.client.sendUrlEncodedForm(t,R,D,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)}};
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
2
  //# sourceMappingURL=encryption.js.map
@@ -1,2 +1,2 @@
1
- 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 U="BaseAPI",G=!1,B=new D(U,process.env.DEBUG==="true"||G),P=class{config;client;constructor(R,t){this.config=R,this.client=t,B.log("Initialized with HTTPSClient")}sendJson(R,t,A,S){return this.client.getJson(R,t,A,S)}sendFormData(R,t,A,S){return this.client.sendFormData(R,t,A,S)}sendUrlEncodedForm(R,t,A,S){return this.client.sendUrlEncodedForm(R,t,A,S)}};var N=class extends P{endpoint="whatsapp_business_encryption";constructor(R,t){super(R,t)}async getEncryptionPublicKey(){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};export{N as default};
1
+ var S=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 U="BaseAPI",G=!1,O=new S(U,process.env.DEBUG==="true"||G),D=class{config;client;constructor(R,t){this.config=R,this.client=t,O.log("Initialized with HTTPSClient")}sendJson(R,t,A,P){return this.client.getJson(R,t,A,P)}sendFormData(R,t,A,P){return this.client.sendFormData(R,t,A,P)}sendUrlEncodedForm(R,t,A,P){return this.client.sendUrlEncodedForm(R,t,A,P)}};var N=class extends D{endpoint="whatsapp_business_encryption";constructor(R,t){super(R,t)}async getEncryptionPublicKey(){return this.sendJson("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.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};export{N as default};
2
2
  //# sourceMappingURL=encryption.mjs.map
@@ -2,7 +2,8 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { FlowClass, FlowsListResponse, FlowCategoryEnum, CreateFlowResponse, Flow, FlowPreviewResponse, FlowAssetsResponse, UpdateFlowResponse, ValidateFlowJsonResponse, FlowMigrationResponse } from '../types/flow.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.mjs';
6
+ import 'http';
6
7
  import '../types/base.mjs';
7
8
 
8
9
  declare class FlowAPI extends BaseAPI implements FlowClass {
@@ -2,7 +2,8 @@ import { WabaConfigType } from '../types/config.js';
2
2
  import { FlowClass, FlowsListResponse, FlowCategoryEnum, CreateFlowResponse, Flow, FlowPreviewResponse, FlowAssetsResponse, UpdateFlowResponse, ValidateFlowJsonResponse, FlowMigrationResponse } from '../types/flow.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.js';
6
+ import 'http';
6
7
  import '../types/base.js';
7
8
 
8
9
  declare class FlowAPI extends BaseAPI implements FlowClass {
package/dist/api/flow.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var N=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var _=(A,i)=>{for(var t in i)N(A,t,{get:i[t],enumerable:!0})},f=(A,i,t,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let R of G(i))!U.call(A,R)&&R!==t&&N(A,R,{get:()=>i[R],enumerable:!(l=O(i,R))||l.enumerable});return A};var F=A=>f(N({},"__esModule",{value:!0}),A);var M={};_(M,{default:()=>D});module.exports=F(M);var S=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 w="BaseAPI",T=!1,I=new S(w,process.env.DEBUG==="true"||T),P=class{config;client;constructor(i,t){this.config=i,this.client=t,I.log("Initialized with HTTPSClient")}sendJson(i,t,l,R){return this.client.getJson(i,t,l,R)}sendFormData(i,t,l,R){return this.client.sendFormData(i,t,l,R)}sendUrlEncodedForm(i,t,l,R){return this.client.sendUrlEncodedForm(i,t,l,R)}};var K="FlowAPI",h=!1,B=new S(K,process.env.DEBUG==="true"||h),D=class extends P{constructor(i,t){super(i,t),B.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let l={name:t.name,categories:t.categories,...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.clone_flow_id&&{clone_flow_id:t.clone_flow_id},...t.flow_json&&{flow_json:t.flow_json},...t.publish!==void 0&&{publish:t.publish}};return this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}async getFlow(i,t,l){let R=new URLSearchParams;t&&R.append("fields",t),l&&R.append("date_format",l);let p=R.toString()?`?${R.toString()}`:"";return this.sendJson("GET",`/${i}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(i,t=!1){let l=`preview.invalidate(${t})`;return this.getFlow(i,l)}async updateFlowMetadata(i,t){let l={...t.name&&{name:t.name},...t.categories&&{categories:t.categories},...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.application_id&&{application_id:t.application_id}};return this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let l=new FormData,R;if(t.file instanceof Buffer)R=new globalThis.Blob([t.file]),l.append("file",R);else if(typeof t.file=="object"&&!(t.file instanceof Blob))try{R=new globalThis.Blob([JSON.stringify(t.file,null,2)],{type:"application/json"}),l.append("file",R)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(t.file instanceof Blob)R=t.file,l.append("file",R);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return l.append("asset_type","FLOW_JSON"),l.append("name",t.name||"flow.json"),this.sendFormData("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,l)}async validateFlowJson(i,t){try{let l=await this.updateFlowJson(i,{file:t}),R=!l.validation_errors||l.validation_errors.length===0;return{...l,valid:R}}catch(l){throw B.error("Error during Flow JSON validation attempt:",l),l}}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let l={source_waba_id:t.source_waba_id,...t.source_flow_names&&{source_flow_names:t.source_flow_names}};return this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}};
1
+ "use strict";var N=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var U=(A,i)=>{for(var t in i)N(A,t,{get:i[t],enumerable:!0})},F=(A,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of _(i))!G.call(A,l)&&l!==t&&N(A,l,{get:()=>i[l],enumerable:!(R=O(i,l))||R.enumerable});return A};var f=A=>F(N({},"__esModule",{value:!0}),A);var M={};U(M,{default:()=>D});module.exports=f(M);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 w="BaseAPI",T=!1,I=new P(w,process.env.DEBUG==="true"||T),S=class{config;client;constructor(i,t){this.config=i,this.client=t,I.log("Initialized with HTTPSClient")}sendJson(i,t,R,l){return this.client.getJson(i,t,R,l)}sendFormData(i,t,R,l){return this.client.sendFormData(i,t,R,l)}sendUrlEncodedForm(i,t,R,l){return this.client.sendUrlEncodedForm(i,t,R,l)}};var K="FlowAPI",h=!1,B=new P(K,process.env.DEBUG==="true"||h),D=class extends S{constructor(i,t){super(i,t),B.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R={name:t.name,categories:t.categories,...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.clone_flow_id&&{clone_flow_id:t.clone_flow_id},...t.flow_json&&{flow_json:t.flow_json},...t.publish!==void 0&&{publish:t.publish}};return this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(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.sendJson("GET",`/${i}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(i,t=!1){let R=`preview.invalidate(${t})`;return this.getFlow(i,R)}async updateFlowMetadata(i,t){let R={...t.name&&{name:t.name},...t.categories&&{categories:t.categories},...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.application_id&&{application_id:t.application_id}};return this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData,l;if(t.file instanceof Buffer)l=new globalThis.Blob([t.file]),R.append("file",l);else if(typeof t.file=="object"&&!(t.file instanceof Blob))try{l=new globalThis.Blob([JSON.stringify(t.file,null,2)],{type:"application/json"}),R.append("file",l)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(t.file instanceof Blob)l=t.file,R.append("file",l);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return R.append("asset_type","FLOW_JSON"),R.append("name",t.name||"flow.json"),this.sendFormData("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async validateFlowJson(i,t){try{let R=await this.updateFlowJson(i,{file:t}),l=!R.validation_errors||R.validation_errors.length===0;return{...R,valid:l}}catch(R){throw B.error("Error during Flow JSON validation attempt:",R),R}}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R={source_waba_id:t.source_waba_id,...t.source_flow_names&&{source_flow_names:t.source_flow_names}};return this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}};
2
2
  //# sourceMappingURL=flow.js.map
package/dist/api/flow.mjs CHANGED
@@ -1,2 +1,2 @@
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 B="BaseAPI",O=!1,G=new A(B,process.env.DEBUG==="true"||O),S=class{config;client;constructor(i,t){this.config=i,this.client=t,G.log("Initialized with HTTPSClient")}sendJson(i,t,l,R){return this.client.getJson(i,t,l,R)}sendFormData(i,t,l,R){return this.client.sendFormData(i,t,l,R)}sendUrlEncodedForm(i,t,l,R){return this.client.sendUrlEncodedForm(i,t,l,R)}};var U="FlowAPI",_=!1,N=new A(U,process.env.DEBUG==="true"||_),D=class extends S{constructor(i,t){super(i,t),N.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let l={name:t.name,categories:t.categories,...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.clone_flow_id&&{clone_flow_id:t.clone_flow_id},...t.flow_json&&{flow_json:t.flow_json},...t.publish!==void 0&&{publish:t.publish}};return this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}async getFlow(i,t,l){let R=new URLSearchParams;t&&R.append("fields",t),l&&R.append("date_format",l);let P=R.toString()?`?${R.toString()}`:"";return this.sendJson("GET",`/${i}${P}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(i,t=!1){let l=`preview.invalidate(${t})`;return this.getFlow(i,l)}async updateFlowMetadata(i,t){let l={...t.name&&{name:t.name},...t.categories&&{categories:t.categories},...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.application_id&&{application_id:t.application_id}};return this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let l=new FormData,R;if(t.file instanceof Buffer)R=new globalThis.Blob([t.file]),l.append("file",R);else if(typeof t.file=="object"&&!(t.file instanceof Blob))try{R=new globalThis.Blob([JSON.stringify(t.file,null,2)],{type:"application/json"}),l.append("file",R)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(t.file instanceof Blob)R=t.file,l.append("file",R);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return l.append("asset_type","FLOW_JSON"),l.append("name",t.name||"flow.json"),this.sendFormData("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,l)}async validateFlowJson(i,t){try{let l=await this.updateFlowJson(i,{file:t}),R=!l.validation_errors||l.validation_errors.length===0;return{...l,valid:R}}catch(l){throw N.error("Error during Flow JSON validation attempt:",l),l}}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let l={source_waba_id:t.source_waba_id,...t.source_flow_names&&{source_flow_names:t.source_flow_names}};return this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(l))}};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 B="BaseAPI",O=!1,_=new A(B,process.env.DEBUG==="true"||O),P=class{config;client;constructor(i,t){this.config=i,this.client=t,_.log("Initialized with HTTPSClient")}sendJson(i,t,R,l){return this.client.getJson(i,t,R,l)}sendFormData(i,t,R,l){return this.client.sendFormData(i,t,R,l)}sendUrlEncodedForm(i,t,R,l){return this.client.sendUrlEncodedForm(i,t,R,l)}};var G="FlowAPI",U=!1,N=new A(G,process.env.DEBUG==="true"||U),D=class extends P{constructor(i,t){super(i,t),N.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R={name:t.name,categories:t.categories,...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.clone_flow_id&&{clone_flow_id:t.clone_flow_id},...t.flow_json&&{flow_json:t.flow_json},...t.publish!==void 0&&{publish:t.publish}};return this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}async getFlow(i,t,R){let l=new URLSearchParams;t&&l.append("fields",t),R&&l.append("date_format",R);let S=l.toString()?`?${l.toString()}`:"";return this.sendJson("GET",`/${i}${S}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(i,t=!1){let R=`preview.invalidate(${t})`;return this.getFlow(i,R)}async updateFlowMetadata(i,t){let R={...t.name&&{name:t.name},...t.categories&&{categories:t.categories},...t.endpoint_uri&&{endpoint_uri:t.endpoint_uri},...t.application_id&&{application_id:t.application_id}};return this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData,l;if(t.file instanceof Buffer)l=new globalThis.Blob([t.file]),R.append("file",l);else if(typeof t.file=="object"&&!(t.file instanceof Blob))try{l=new globalThis.Blob([JSON.stringify(t.file,null,2)],{type:"application/json"}),R.append("file",l)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(t.file instanceof Blob)l=t.file,R.append("file",l);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return R.append("asset_type","FLOW_JSON"),R.append("name",t.name||"flow.json"),this.sendFormData("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async validateFlowJson(i,t){try{let R=await this.updateFlowJson(i,{file:t}),l=!R.validation_errors||R.validation_errors.length===0;return{...R,valid:l}}catch(R){throw N.error("Error during Flow JSON validation attempt:",R),R}}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R={source_waba_id:t.source_waba_id,...t.source_flow_names&&{source_flow_names:t.source_flow_names}};return this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}};export{D as default};
2
2
  //# sourceMappingURL=flow.mjs.map
@@ -10,13 +10,14 @@ export { default as RegistrationAPI } from './registration.mjs';
10
10
  export { default as TemplateAPI } from './template.mjs';
11
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.mjs';
12
12
  export { default as WabaAPI } from './waba.mjs';
13
- import '../enums-Bcd3jLw2.mjs';
13
+ import '../enums-CI7vzKhn.mjs';
14
14
  import '../types/base.mjs';
15
15
  import '../types/config.mjs';
16
16
  import '../types/request.mjs';
17
17
  import '../types/businessProfile.mjs';
18
18
  import '../types/encryption.mjs';
19
19
  import '../types/flow.mjs';
20
+ import 'http';
20
21
  import '../types/media.mjs';
21
22
  import '../types/messages.mjs';
22
23
  import '../types/phoneNumber.mjs';
@@ -10,13 +10,14 @@ export { default as RegistrationAPI } from './registration.js';
10
10
  export { default as TemplateAPI } from './template.js';
11
11
  export { default as TwoStepVerificationAPI } from './twoStepVerification.js';
12
12
  export { default as WabaAPI } from './waba.js';
13
- import '../enums-Bcd3jLw2.js';
13
+ import '../enums-CI7vzKhn.js';
14
14
  import '../types/base.js';
15
15
  import '../types/config.js';
16
16
  import '../types/request.js';
17
17
  import '../types/businessProfile.js';
18
18
  import '../types/encryption.js';
19
19
  import '../types/flow.js';
20
+ import 'http';
20
21
  import '../types/media.js';
21
22
  import '../types/messages.js';
22
23
  import '../types/phoneNumber.js';
package/dist/api/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var B=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var U=(o,t)=>{for(var e in t)B(o,e,{get:t[e],enumerable:!0})},w=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of D(t))!_.call(o,i)&&i!==e&&B(o,i,{get:()=>t[i],enumerable:!(s=m(t,i))||s.enumerable});return o};var G=o=>w(B({},"__esModule",{value:!0}),o);var H={};U(H,{BaseAPI:()=>a,BusinessProfileAPI:()=>f,EncryptionAPI:()=>P,FlowAPI:()=>h,MediaAPI:()=>c,MessagesAPI:()=>g,PhoneNumberAPI:()=>S,QrCodeAPI:()=>T,RegistrationAPI:()=>d,TemplateAPI:()=>b,TwoStepVerificationAPI:()=>A,WabaAPI:()=>I});module.exports=G(H);var n=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 F="BaseAPI",q=!1,J=new n(F,process.env.DEBUG==="true"||q),a=class{config;client;constructor(t,e){this.config=t,this.client=e,J.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function N(o){if(!o)return"";let t="";return Array.isArray(o)?t=o.join(","):t=Object.entries(o).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=o=>{if(!o||Object.keys(o).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(o))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var f=class extends a{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${N(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,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var P=class extends a{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var x="FlowAPI",K=!1,O=new n(x,process.env.DEBUG==="true"||K),h=class extends a{constructor(t,e){super(t,e),O.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw O.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var c=class extends a{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var g=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,M;return typeof e=="string"?M={body:e,preview_url:s}:M=e,this.send(JSON.stringify(this.bodyBuilder("text",M,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var S=class extends a{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var T=class extends a{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var d=class extends a{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends a{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends a{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var I=class extends a{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=N(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};0&&(module.exports={BaseAPI,BusinessProfileAPI,EncryptionAPI,FlowAPI,MediaAPI,MessagesAPI,PhoneNumberAPI,QrCodeAPI,RegistrationAPI,TemplateAPI,TwoStepVerificationAPI,WabaAPI});
1
+ "use strict";var B=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var U=(o,t)=>{for(var e in t)B(o,e,{get:t[e],enumerable:!0})},w=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of D(t))!m.call(o,i)&&i!==e&&B(o,i,{get:()=>t[i],enumerable:!(s=_(t,i))||s.enumerable});return o};var G=o=>w(B({},"__esModule",{value:!0}),o);var H={};U(H,{BaseAPI:()=>a,BusinessProfileAPI:()=>f,EncryptionAPI:()=>P,FlowAPI:()=>h,MediaAPI:()=>c,MessagesAPI:()=>g,PhoneNumberAPI:()=>S,QrCodeAPI:()=>T,RegistrationAPI:()=>d,TemplateAPI:()=>A,TwoStepVerificationAPI:()=>b,WabaAPI:()=>I});module.exports=G(H);var n=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 F="BaseAPI",q=!1,J=new n(F,process.env.DEBUG==="true"||q),a=class{config;client;constructor(t,e){this.config=t,this.client=e,J.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function N(o){if(!o)return"";let t="";return Array.isArray(o)?t=o.join(","):t=Object.entries(o).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=o=>{if(!o||Object.keys(o).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(o))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var f=class extends a{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${N(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,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var P=class extends a{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var x="FlowAPI",K=!1,O=new n(x,process.env.DEBUG==="true"||K),h=class extends a{constructor(t,e){super(t,e),O.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw O.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var c=class extends a{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var g=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,M;return typeof e=="string"?M={body:e,preview_url:s}:M=e,this.send(JSON.stringify(this.bodyBuilder("text",M,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var S=class extends a{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var T=class extends a{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var d=class extends a{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends a{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends a{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var I=class extends a{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=N(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};0&&(module.exports={BaseAPI,BusinessProfileAPI,EncryptionAPI,FlowAPI,MediaAPI,MessagesAPI,PhoneNumberAPI,QrCodeAPI,RegistrationAPI,TemplateAPI,TwoStepVerificationAPI,WabaAPI});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- var n=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 O="BaseAPI",m=!1,D=new n(O,process.env.DEBUG==="true"||m),o=class{config;client;constructor(t,e){this.config=t,this.client=e,D.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function f(a){if(!a)return"";let t="";return Array.isArray(a)?t=a.join(","):t=Object.entries(a).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(a))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var P=class extends o{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${f(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,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var h=class extends o{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var _="FlowAPI",U=!1,B=new n(_,process.env.DEBUG==="true"||U),c=class extends o{constructor(t,e){super(t,e),B.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw B.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var g=class extends o{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var S=class extends o{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,M;return typeof e=="string"?M={body:e,preview_url:s}:M=e,this.send(JSON.stringify(this.bodyBuilder("text",M,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var T=class extends o{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var d=class extends o{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends o{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends o{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var I=class extends o{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var N=class extends o{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=f(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};export{o as BaseAPI,P as BusinessProfileAPI,h as EncryptionAPI,c as FlowAPI,g as MediaAPI,S as MessagesAPI,T as PhoneNumberAPI,d as QrCodeAPI,b as RegistrationAPI,A as TemplateAPI,I as TwoStepVerificationAPI,N as WabaAPI};
1
+ var n=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 O="BaseAPI",_=!1,D=new n(O,process.env.DEBUG==="true"||_),o=class{config;client;constructor(t,e){this.config=t,this.client=e,D.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function f(a){if(!a)return"";let t="";return Array.isArray(a)?t=a.join(","):t=Object.entries(a).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(a))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var P=class extends o{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${f(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,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var h=class extends o{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var m="FlowAPI",U=!1,B=new n(m,process.env.DEBUG==="true"||U),c=class extends o{constructor(t,e){super(t,e),B.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw B.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var g=class extends o{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var S=class extends o{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,M;return typeof e=="string"?M={body:e,preview_url:s}:M=e,this.send(JSON.stringify(this.bodyBuilder("text",M,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var T=class extends o{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var d=class extends o{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends o{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends o{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var I=class extends o{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var N=class extends o{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=f(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};export{o as BaseAPI,P as BusinessProfileAPI,h as EncryptionAPI,c as FlowAPI,g as MediaAPI,S as MessagesAPI,T as PhoneNumberAPI,d as QrCodeAPI,A as RegistrationAPI,b as TemplateAPI,I as TwoStepVerificationAPI,N as WabaAPI};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { MediaClass, MediaResponse, UploadMediaResponse } from '../types/media.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  declare class MediaAPI extends BaseAPI implements MediaClass {
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.js';
2
2
  import { MediaClass, MediaResponse, UploadMediaResponse } from '../types/media.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  declare class MediaAPI extends BaseAPI implements MediaClass {
package/dist/api/media.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(D,t)=>{for(var R in t)U(D,R,{get:t[R],enumerable:!0})},p=(D,t,R,A)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of B(t))!O.call(D,S)&&S!==R&&U(D,S,{get:()=>t[S],enumerable:!(A=G(t,S))||A.enumerable});return D};var T=D=>p(U({},"__esModule",{value:!0}),D);var F={};I(F,{default:()=>N});module.exports=T(F);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 l="BaseAPI",K=!1,M=new P(l,process.env.DEBUG==="true"||K),i=class{config;client;constructor(t,R){this.config=t,this.client=R,M.log("Initialized with HTTPSClient")}sendJson(t,R,A,S){return this.client.getJson(t,R,A,S)}sendFormData(t,R,A,S){return this.client.sendFormData(t,R,A,S)}sendUrlEncodedForm(t,R,A,S){return this.client.sendUrlEncodedForm(t,R,A,S)}};var N=class extends i{endpoint="media";constructor(t,R){super(t,R)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R="whatsapp"){let A=new FormData;return A.append("file",t),A.append("messaging_product",R),A.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,A)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};
1
+ "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(P,t)=>{for(var R in t)U(P,R,{get:t[R],enumerable:!0})},p=(P,t,R,A)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of B(t))!O.call(P,S)&&S!==R&&U(P,S,{get:()=>t[S],enumerable:!(A=G(t,S))||A.enumerable});return P};var T=P=>p(U({},"__esModule",{value:!0}),P);var _={};I(_,{default:()=>N});module.exports=T(_);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 l="BaseAPI",K=!1,M=new D(l,process.env.DEBUG==="true"||K),i=class{config;client;constructor(t,R){this.config=t,this.client=R,M.log("Initialized with HTTPSClient")}sendJson(t,R,A,S){return this.client.getJson(t,R,A,S)}sendFormData(t,R,A,S){return this.client.sendFormData(t,R,A,S)}sendUrlEncodedForm(t,R,A,S){return this.client.sendUrlEncodedForm(t,R,A,S)}};var N=class extends i{endpoint="media";constructor(t,R){super(t,R)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R="whatsapp"){let A=new FormData;return A.append("file",t),A.append("messaging_product",R),A.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,A)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};
2
2
  //# sourceMappingURL=media.js.map
@@ -1,2 +1,2 @@
1
- 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 U="BaseAPI",G=!1,B=new D(U,process.env.DEBUG==="true"||G),P=class{config;client;constructor(t,R){this.config=t,this.client=R,B.log("Initialized with HTTPSClient")}sendJson(t,R,A,S){return this.client.getJson(t,R,A,S)}sendFormData(t,R,A,S){return this.client.sendFormData(t,R,A,S)}sendUrlEncodedForm(t,R,A,S){return this.client.sendUrlEncodedForm(t,R,A,S)}};var i=class extends P{endpoint="media";constructor(t,R){super(t,R)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R="whatsapp"){let A=new FormData;return A.append("file",t),A.append("messaging_product",R),A.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,A)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};export{i as default};
1
+ 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 U="BaseAPI",G=!1,B=new P(U,process.env.DEBUG==="true"||G),D=class{config;client;constructor(t,R){this.config=t,this.client=R,B.log("Initialized with HTTPSClient")}sendJson(t,R,A,S){return this.client.getJson(t,R,A,S)}sendFormData(t,R,A,S){return this.client.sendFormData(t,R,A,S)}sendUrlEncodedForm(t,R,A,S){return this.client.sendUrlEncodedForm(t,R,A,S)}};var i=class extends D{endpoint="media";constructor(t,R){super(t,R)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R="whatsapp"){let A=new FormData;return A.append("file",t),A.append("messaging_product",R),A.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,A)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};export{i as default};
2
2
  //# sourceMappingURL=media.mjs.map
@@ -1,5 +1,5 @@
1
1
  import { WabaConfigType } from '../types/config.mjs';
2
- import { M as MessageTypesEnum, b as ComponentTypesEnum, I as InteractiveTypesEnum } from '../enums-Bcd3jLw2.mjs';
2
+ import { M as MessageTypesEnum, b as ComponentTypesEnum, I as InteractiveTypesEnum } from '../enums-CI7vzKhn.mjs';
3
3
  import { MessagesClass, AudioMediaObject, ContactObject, DocumentMediaObject, ImageMediaObject, InteractiveObject, LocationObject, MessageTemplateObject, StickerMediaObject, TextObject, VideoMediaObject, MessageRequestBody, MessageRequestParams as MessageRequestParams$1, MessagesResponse, TextMessageParams as TextMessageParams$1, StatusParams as StatusParams$1, ReactionParams as ReactionParams$1 } from '../types/messages.mjs';
4
4
  import { RequesterClass } from '../types/request.mjs';
5
5
  import BaseAPI from './base.mjs';
@@ -1,5 +1,5 @@
1
1
  import { WabaConfigType } from '../types/config.js';
2
- import { M as MessageTypesEnum, b as ComponentTypesEnum, I as InteractiveTypesEnum } from '../enums-Bcd3jLw2.js';
2
+ import { M as MessageTypesEnum, b as ComponentTypesEnum, I as InteractiveTypesEnum } from '../enums-CI7vzKhn.js';
3
3
  import { MessagesClass, AudioMediaObject, ContactObject, DocumentMediaObject, ImageMediaObject, InteractiveObject, LocationObject, MessageTemplateObject, StickerMediaObject, TextObject, VideoMediaObject, MessageRequestBody, MessageRequestParams as MessageRequestParams$1, MessagesResponse, TextMessageParams as TextMessageParams$1, StatusParams as StatusParams$1, ReactionParams as ReactionParams$1 } from '../types/messages.js';
4
4
  import { RequesterClass } from '../types/request.js';
5
5
  import BaseAPI from './base.js';
@@ -1,2 +1,2 @@
1
- "use strict";var M=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var O=(p,i)=>{for(var t in i)M(p,t,{get:i[t],enumerable:!0})},l=(p,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of N(i))!D.call(p,a)&&a!==t&&M(p,a,{get:()=>i[a],enumerable:!(R=I(i,a))||R.enumerable});return p};var T=p=>l(M({},"__esModule",{value:!0}),p);var _={};O(_,{default:()=>e});module.exports=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 B="BaseAPI",U=!1,G=new P(B,process.env.DEBUG==="true"||U),A=class{config;client;constructor(i,t){this.config=i,this.client=t,G.log("Initialized with HTTPSClient")}sendJson(i,t,R,a){return this.client.getJson(i,t,R,a)}sendFormData(i,t,R,a){return this.client.sendFormData(i,t,R,a)}sendUrlEncodedForm(i,t,R,a){return this.client.sendUrlEncodedForm(i,t,R,a)}};var e=class extends A{commonMethod="POST";commonEndpoint="messages";constructor(i,t){super(i,t)}bodyBuilder(i,t,R,a){let s={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:i,[i]:t};return a&&(s.context={message_id:a}),s}send(i){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,i)}async audio(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("audio",t,R,a)))}async contacts(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("contacts",t,R,a)))}async document(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("document",t,R,a)))}async image(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("image",t,R,a)))}async interactive(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async location(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("location",t,R,a)))}async sticker(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("sticker",t,R,a)))}async template(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("template",t,R,a)))}async text(i){let{body:t,previewUrl:R,to:a,replyMessageId:s}=i,S;return typeof t=="string"?S={body:t,preview_url:R}:S=t,this.send(JSON.stringify(this.bodyBuilder("text",S,a,s)))}async video(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("video",t,R,a)))}async status(i){let{status:t,messageId:R,typingIndicator:a}=i,s={messaging_product:"whatsapp",status:t,message_id:R,...a&&{typing_indicator:a}};return this.send(JSON.stringify(s))}async markAsRead(i){return this.status({status:"read",messageId:i.messageId})}async showTypingIndicator(i){return this.status({status:"read",messageId:i.messageId,typingIndicator:{type:"text"}})}async interactiveList(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveCtaUrl(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveLocationRequest(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveAddressMessage(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveReplyButtons(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveFlow(i){let{body:t,to:R,replyMessageId:a}=i;return t.action.parameters.flow_message_version===void 0&&(t.action.parameters.flow_message_version="3"),t.action.parameters.mode===void 0&&(t.action.parameters.mode="published"),t.action.parameters.flow_action===void 0&&(t.action.parameters.flow_action="navigate"),t.action.parameters.flow_action==="navigate"?t.action.parameters.flow_action_payload?.screen===void 0&&(t.action.parameters.flow_action_payload={...t.action.parameters.flow_action_payload,screen:"INIT"}):t.action.parameters.flow_action==="data_exchange"&&delete t.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async reaction(i){let{messageId:t,emoji:R,to:a}=i,s={messaging_product:"whatsapp",recipient_type:"individual",to:a,type:"reaction",reaction:{message_id:t,emoji:R}};return this.send(JSON.stringify(s))}};
1
+ "use strict";var M=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var D=(p,i)=>{for(var t in i)M(p,t,{get:i[t],enumerable:!0})},l=(p,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of O(i))!N.call(p,a)&&a!==t&&M(p,a,{get:()=>i[a],enumerable:!(R=I(i,a))||R.enumerable});return p};var T=p=>l(M({},"__esModule",{value:!0}),p);var _={};D(_,{default:()=>e});module.exports=T(_);var s=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",U=!1,G=new s(B,process.env.DEBUG==="true"||U),A=class{config;client;constructor(i,t){this.config=i,this.client=t,G.log("Initialized with HTTPSClient")}sendJson(i,t,R,a){return this.client.getJson(i,t,R,a)}sendFormData(i,t,R,a){return this.client.sendFormData(i,t,R,a)}sendUrlEncodedForm(i,t,R,a){return this.client.sendUrlEncodedForm(i,t,R,a)}};var e=class extends A{commonMethod="POST";commonEndpoint="messages";constructor(i,t){super(i,t)}bodyBuilder(i,t,R,a){let P={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:i,[i]:t};return a&&(P.context={message_id:a}),P}send(i){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,i)}async audio(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("audio",t,R,a)))}async contacts(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("contacts",t,R,a)))}async document(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("document",t,R,a)))}async image(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("image",t,R,a)))}async interactive(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async location(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("location",t,R,a)))}async sticker(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("sticker",t,R,a)))}async template(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("template",t,R,a)))}async text(i){let{body:t,previewUrl:R,to:a,replyMessageId:P}=i,S;return typeof t=="string"?S={body:t,preview_url:R}:S=t,this.send(JSON.stringify(this.bodyBuilder("text",S,a,P)))}async video(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("video",t,R,a)))}async status(i){let{status:t,messageId:R,typingIndicator:a}=i,P={messaging_product:"whatsapp",status:t,message_id:R,...a&&{typing_indicator:a}};return this.send(JSON.stringify(P))}async markAsRead(i){return this.status({status:"read",messageId:i.messageId})}async showTypingIndicator(i){return this.status({status:"read",messageId:i.messageId,typingIndicator:{type:"text"}})}async interactiveList(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveCtaUrl(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveLocationRequest(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveAddressMessage(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveReplyButtons(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveFlow(i){let{body:t,to:R,replyMessageId:a}=i;return t.action.parameters.flow_message_version===void 0&&(t.action.parameters.flow_message_version="3"),t.action.parameters.mode===void 0&&(t.action.parameters.mode="published"),t.action.parameters.flow_action===void 0&&(t.action.parameters.flow_action="navigate"),t.action.parameters.flow_action==="navigate"?t.action.parameters.flow_action_payload?.screen===void 0&&(t.action.parameters.flow_action_payload={...t.action.parameters.flow_action_payload,screen:"INIT"}):t.action.parameters.flow_action==="data_exchange"&&delete t.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async reaction(i){let{messageId:t,emoji:R,to:a}=i,P={messaging_product:"whatsapp",recipient_type:"individual",to:a,type:"reaction",reaction:{message_id:t,emoji:R}};return this.send(JSON.stringify(P))}};
2
2
  //# sourceMappingURL=messages.js.map
@@ -1,2 +1,2 @@
1
- var s=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 M="BaseAPI",I=!1,N=new s(M,process.env.DEBUG==="true"||I),P=class{config;client;constructor(i,t){this.config=i,this.client=t,N.log("Initialized with HTTPSClient")}sendJson(i,t,R,a){return this.client.getJson(i,t,R,a)}sendFormData(i,t,R,a){return this.client.sendFormData(i,t,R,a)}sendUrlEncodedForm(i,t,R,a){return this.client.sendUrlEncodedForm(i,t,R,a)}};var e=class extends P{commonMethod="POST";commonEndpoint="messages";constructor(i,t){super(i,t)}bodyBuilder(i,t,R,a){let p={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:i,[i]:t};return a&&(p.context={message_id:a}),p}send(i){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,i)}async audio(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("audio",t,R,a)))}async contacts(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("contacts",t,R,a)))}async document(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("document",t,R,a)))}async image(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("image",t,R,a)))}async interactive(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async location(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("location",t,R,a)))}async sticker(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("sticker",t,R,a)))}async template(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("template",t,R,a)))}async text(i){let{body:t,previewUrl:R,to:a,replyMessageId:p}=i,A;return typeof t=="string"?A={body:t,preview_url:R}:A=t,this.send(JSON.stringify(this.bodyBuilder("text",A,a,p)))}async video(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("video",t,R,a)))}async status(i){let{status:t,messageId:R,typingIndicator:a}=i,p={messaging_product:"whatsapp",status:t,message_id:R,...a&&{typing_indicator:a}};return this.send(JSON.stringify(p))}async markAsRead(i){return this.status({status:"read",messageId:i.messageId})}async showTypingIndicator(i){return this.status({status:"read",messageId:i.messageId,typingIndicator:{type:"text"}})}async interactiveList(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveCtaUrl(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveLocationRequest(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveAddressMessage(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveReplyButtons(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveFlow(i){let{body:t,to:R,replyMessageId:a}=i;return t.action.parameters.flow_message_version===void 0&&(t.action.parameters.flow_message_version="3"),t.action.parameters.mode===void 0&&(t.action.parameters.mode="published"),t.action.parameters.flow_action===void 0&&(t.action.parameters.flow_action="navigate"),t.action.parameters.flow_action==="navigate"?t.action.parameters.flow_action_payload?.screen===void 0&&(t.action.parameters.flow_action_payload={...t.action.parameters.flow_action_payload,screen:"INIT"}):t.action.parameters.flow_action==="data_exchange"&&delete t.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async reaction(i){let{messageId:t,emoji:R,to:a}=i,p={messaging_product:"whatsapp",recipient_type:"individual",to:a,type:"reaction",reaction:{message_id:t,emoji:R}};return this.send(JSON.stringify(p))}};export{e as default};
1
+ 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 M="BaseAPI",I=!1,O=new P(M,process.env.DEBUG==="true"||I),s=class{config;client;constructor(i,t){this.config=i,this.client=t,O.log("Initialized with HTTPSClient")}sendJson(i,t,R,a){return this.client.getJson(i,t,R,a)}sendFormData(i,t,R,a){return this.client.sendFormData(i,t,R,a)}sendUrlEncodedForm(i,t,R,a){return this.client.sendUrlEncodedForm(i,t,R,a)}};var e=class extends s{commonMethod="POST";commonEndpoint="messages";constructor(i,t){super(i,t)}bodyBuilder(i,t,R,a){let p={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:i,[i]:t};return a&&(p.context={message_id:a}),p}send(i){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,i)}async audio(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("audio",t,R,a)))}async contacts(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("contacts",t,R,a)))}async document(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("document",t,R,a)))}async image(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("image",t,R,a)))}async interactive(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async location(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("location",t,R,a)))}async sticker(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("sticker",t,R,a)))}async template(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("template",t,R,a)))}async text(i){let{body:t,previewUrl:R,to:a,replyMessageId:p}=i,A;return typeof t=="string"?A={body:t,preview_url:R}:A=t,this.send(JSON.stringify(this.bodyBuilder("text",A,a,p)))}async video(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("video",t,R,a)))}async status(i){let{status:t,messageId:R,typingIndicator:a}=i,p={messaging_product:"whatsapp",status:t,message_id:R,...a&&{typing_indicator:a}};return this.send(JSON.stringify(p))}async markAsRead(i){return this.status({status:"read",messageId:i.messageId})}async showTypingIndicator(i){return this.status({status:"read",messageId:i.messageId,typingIndicator:{type:"text"}})}async interactiveList(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveCtaUrl(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveLocationRequest(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveAddressMessage(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveReplyButtons(i){let{body:t,to:R,replyMessageId:a}=i;return this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async interactiveFlow(i){let{body:t,to:R,replyMessageId:a}=i;return t.action.parameters.flow_message_version===void 0&&(t.action.parameters.flow_message_version="3"),t.action.parameters.mode===void 0&&(t.action.parameters.mode="published"),t.action.parameters.flow_action===void 0&&(t.action.parameters.flow_action="navigate"),t.action.parameters.flow_action==="navigate"?t.action.parameters.flow_action_payload?.screen===void 0&&(t.action.parameters.flow_action_payload={...t.action.parameters.flow_action_payload,screen:"INIT"}):t.action.parameters.flow_action==="data_exchange"&&delete t.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",t,R,a)))}async reaction(i){let{messageId:t,emoji:R,to:a}=i,p={messaging_product:"whatsapp",recipient_type:"individual",to:a,type:"reaction",reaction:{message_id:t,emoji:R}};return this.send(JSON.stringify(p))}};export{e as default};
2
2
  //# sourceMappingURL=messages.mjs.map
@@ -2,7 +2,7 @@ import { PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, RequestVer
2
2
  import { WabaConfigType } from '../types/config.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
@@ -2,7 +2,7 @@ import { PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, RequestVer
2
2
  import { WabaConfigType } from '../types/config.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
@@ -1,2 +1,2 @@
1
- "use strict";var U=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var T=(A,t)=>{for(var R in t)U(A,R,{get:t[R],enumerable:!0})},K=(A,t,R,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of B(t))!I.call(A,S)&&S!==R&&U(A,S,{get:()=>t[S],enumerable:!(P=O(t,S))||P.enumerable});return A};var l=A=>K(U({},"__esModule",{value:!0}),A);var _={};T(_,{default:()=>N});module.exports=l(_);var G=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[P,S]of Object.entries(A))S!==void 0&&t.append(P,String(S));let R=t.toString();return R?`?${R}`:""};var i=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 p="BaseAPI",M=!1,h=new i(p,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,h.log("Initialized with HTTPSClient")}sendJson(t,R,P,S){return this.client.getJson(t,R,P,S)}sendFormData(t,R,P,S){return this.client.sendFormData(t,R,P,S)}sendUrlEncodedForm(t,R,P,S){return this.client.sendUrlEncodedForm(t,R,P,S)}};var N=class extends D{endpoint="phone_numbers";constructor(t,R){super(t,R)}async getPhoneNumberById(t){let R=t?G({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${R}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};
1
+ "use strict";var U=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var T=(A,t)=>{for(var R in t)U(A,R,{get:t[R],enumerable:!0})},K=(A,t,R,S)=>{if(t&&typeof t=="object"||typeof t=="function")for(let P of B(t))!I.call(A,P)&&P!==R&&U(A,P,{get:()=>t[P],enumerable:!(S=O(t,P))||S.enumerable});return A};var l=A=>K(U({},"__esModule",{value:!0}),A);var h={};T(h,{default:()=>N});module.exports=l(h);var G=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[S,P]of Object.entries(A))P!==void 0&&t.append(S,String(P));let R=t.toString();return R?`?${R}`:""};var i=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 p="BaseAPI",_=!1,M=new i(p,process.env.DEBUG==="true"||_),D=class{config;client;constructor(t,R){this.config=t,this.client=R,M.log("Initialized with HTTPSClient")}sendJson(t,R,S,P){return this.client.getJson(t,R,S,P)}sendFormData(t,R,S,P){return this.client.sendFormData(t,R,S,P)}sendUrlEncodedForm(t,R,S,P){return this.client.sendUrlEncodedForm(t,R,S,P)}};var N=class extends D{endpoint="phone_numbers";constructor(t,R){super(t,R)}async getPhoneNumberById(t){let R=t?G({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${R}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};
2
2
  //# sourceMappingURL=phoneNumber.js.map
@@ -1,2 +1,2 @@
1
- var U=P=>{if(!P||Object.keys(P).length===0)return"";let t=new URLSearchParams;for(let[S,A]of Object.entries(P))A!==void 0&&t.append(S,String(A));let R=t.toString();return R?`?${R}`:""};var i=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 G="BaseAPI",O=!1,B=new i(G,process.env.DEBUG==="true"||O),D=class{config;client;constructor(t,R){this.config=t,this.client=R,B.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 N=class extends D{endpoint="phone_numbers";constructor(t,R){super(t,R)}async getPhoneNumberById(t){let R=t?U({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${R}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};export{N as default};
1
+ var U=S=>{if(!S||Object.keys(S).length===0)return"";let t=new URLSearchParams;for(let[P,A]of Object.entries(S))A!==void 0&&t.append(P,String(A));let R=t.toString();return R?`?${R}`:""};var i=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 G="BaseAPI",O=!1,B=new i(G,process.env.DEBUG==="true"||O),D=class{config;client;constructor(t,R){this.config=t,this.client=R,B.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="phone_numbers";constructor(t,R){super(t,R)}async getPhoneNumberById(t){let R=t?U({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${R}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};export{N as default};
2
2
  //# sourceMappingURL=phoneNumber.mjs.map
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { QrCodeClass, CreateQrCodeRequest, QrCodeResponse, QrCodesResponse, UpdateQrCodeRequest } from '../types/qrCode.mjs';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
- import '../enums-Bcd3jLw2.mjs';
5
+ import '../enums-CI7vzKhn.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  declare class QrCodeAPI extends BaseAPI implements QrCodeClass {
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.js';
2
2
  import { QrCodeClass, CreateQrCodeRequest, QrCodeResponse, QrCodesResponse, UpdateQrCodeRequest } from '../types/qrCode.js';
3
3
  import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
- import '../enums-Bcd3jLw2.js';
5
+ import '../enums-CI7vzKhn.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  declare class QrCodeAPI extends BaseAPI implements QrCodeClass {
@@ -1,2 +1,2 @@
1
- "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var I=(S,t)=>{for(var R in t)U(S,R,{get:t[R],enumerable:!0})},T=(S,t,R,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of O(t))!B.call(S,A)&&A!==R&&U(S,A,{get:()=>t[A],enumerable:!(P=G(t,A))||P.enumerable});return S};var K=S=>T(U({},"__esModule",{value:!0}),S);var h={};I(h,{default:()=>N});module.exports=K(h);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 l="BaseAPI",p=!1,M=new D(l,process.env.DEBUG==="true"||p),i=class{config;client;constructor(t,R){this.config=t,this.client=R,M.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 i{endpoint="message_qrdls";constructor(t,R){super(t,R)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};
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})},T=(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 K=P=>T(U({},"__esModule",{value:!0}),P);var _={};I(_,{default:()=>N});module.exports=K(_);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 p="BaseAPI",l=!1,M=new D(p,process.env.DEBUG==="true"||l),i=class{config;client;constructor(t,R){this.config=t,this.client=R,M.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 N=class extends i{endpoint="message_qrdls";constructor(t,R){super(t,R)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};
2
2
  //# sourceMappingURL=qrCode.js.map
@@ -1,2 +1,2 @@
1
- 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 U="BaseAPI",G=!1,O=new P(U,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,S){return this.client.getJson(t,R,A,S)}sendFormData(t,R,A,S){return this.client.sendFormData(t,R,A,S)}sendUrlEncodedForm(t,R,A,S){return this.client.sendUrlEncodedForm(t,R,A,S)}};var i=class extends D{endpoint="message_qrdls";constructor(t,R){super(t,R)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};export{i as default};
1
+ 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 U="BaseAPI",G=!1,O=new S(U,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 i=class extends D{endpoint="message_qrdls";constructor(t,R){super(t,R)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};export{i as default};
2
2
  //# sourceMappingURL=qrCode.mjs.map