meta-cloud-api 0.0.15 → 0.0.17
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.
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/waba.d.mts +2 -3
- package/dist/api/waba.d.ts +2 -3
- package/dist/api/waba.js +1 -1
- package/dist/api/waba.js.map +1 -1
- package/dist/api/waba.mjs +1 -1
- package/dist/api/waba.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/waba.d.mts +8 -3
- package/dist/types/waba.d.ts +8 -3
- package/dist/types/waba.js +1 -1
- package/dist/types/waba.js.map +1 -1
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +1 -1
package/dist/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var M=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},_=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of O(e))!B.call(o,p)&&p!==t&&b(o,p,{get:()=>e[p],enumerable:!(s=D(e,p))||s.enumerable});return o};var G=o=>_(b({},"__esModule",{value:!0}),o);var x={};M(x,{BaseAPI:()=>i,BusinessProfileAPI:()=>l,EncryptionAPI:()=>f,FlowAPI:()=>c,MediaAPI:()=>P,MessagesAPI:()=>h,PhoneNumberAPI:()=>S,QrCodeAPI:()=>I,RegistrationAPI:()=>g,TemplateAPI:()=>T,TwoStepVerificationAPI:()=>q,WabaAPI:()=>A});module.exports=G(x);var n=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var U="BaseAPI",d=!1,F=new n(U,process.env.DEBUG==="true"||d),i=class{config;client;constructor(e,t){this.config=e,this.client=t,F.log("Initialized with HTTPSClient")}};var r=o=>{if(!o||Object.keys(o).length===0)return"";let e=new URLSearchParams;for(let[s,p]of Object.entries(o))p!==void 0&&e.append(s,String(p));let t=e.toString();return t?`?${t}`:""};var l=class extends i{endpoint="whatsapp_business_profile";constructor(e,t){super(e,t)}async getBusinessProfile(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${t}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async createUploadSession(e,t,s){let p=r({file_length:e,file_type:t,file_name:s});return this.client.sendRequest("POST",`app/uploads/${p}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,t)}async getUploadHandle(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}};var f=class extends i{endpoint="whatsapp_business_encryption";constructor(e,t){super(e,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(e){let t=new FormData;return t.append("business_public_key",e),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};var m="FlowAPI",w=!1,K=new n(m,process.env.DEBUG==="true"||w),c=class extends i{constructor(e,t){super(e,t),K.log("FlowAPI initialized")}async listFlows(e){return this.client.sendRequest("GET",`/${e}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&s.append("clone_flow_id",t.clone_flow_id),t.flow_json&&s.append("flow_json",t.flow_json),t.publish!==void 0&&s.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${e}/flows`,this.config.REQUEST_TIMEOUT,s)}async getFlow(e,t,s){let p=new URLSearchParams;t&&p.append("fields",t),s&&p.append("date_format",s);let N=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${e}${N}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.application_id&&s.append("application_id",t.application_id),this.client.sendRequest("POST",`/${e}`,this.config.REQUEST_TIMEOUT,s)}async deleteFlow(e){return this.client.sendRequest("DELETE",`/${e}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(e){return this.client.sendRequest("GET",`/${e}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(e,t){let s=new FormData;return s.append("asset_type",t.asset_type),s.append("file",t.file),s.append("name",t.name),this.client.sendRequest("POST",`/${e}/assets`,this.config.REQUEST_TIMEOUT,s)}async publishFlow(e){return this.client.sendRequest("POST",`/${e}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(e){return this.client.sendRequest("POST",`/${e}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(e,t){let s=new FormData;return s.append("source_waba_id",t.source_waba_id),t.source_flow_names&&s.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${e}/migrate_flows`,this.config.REQUEST_TIMEOUT,s)}};var P=class extends i{endpoint="media";constructor(e,t){super(e,t)}async getMediaById(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t="whatsapp"){let s=new FormData;return s.append("file",e),s.append("messaging_product",t),s.append("type",e.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(e){return this.client.sendRequest("DELETE",`${e}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(e){return this.client.sendRequest("GET",e,this.config.REQUEST_TIMEOUT,null)}};var h=class extends i{commonMethod="POST";commonEndpoint="messages";constructor(e,t){super(e,t)}bodyBuilder(e,t,s,p){let N={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:e,[e]:t};return p&&(N.context={message_id:p}),N}send(e){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,e)}async audio(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("audio",e,t.toString(),s)))}async contacts(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("contacts",e,t.toString(),s)))}async document(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("document",e,t.toString(),s)))}async image(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("image",e,t.toString(),s)))}async interactive(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async location(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("location",e,t.toString(),s)))}async sticker(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("sticker",e,t.toString(),s)))}async template(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("template",e,t.toString(),s)))}async text(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("text",e,t.toString(),s)))}async video(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("video",e,t.toString(),s)))}async status(e){let t={messaging_product:"whatsapp",...e};return this.send(JSON.stringify(t))}async markAsRead(e){return this.status({status:"read",message_id:e})}async showTypingIndicator(e){return this.status({status:"read",message_id:e,typing_indicator:{type:"text"}})}async interactiveList(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveCtaUrl(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveLocationRequest(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveAddressMessage(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveReplyButtons(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveFlow(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async reaction(e,t,s){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s.toString(),type:"reaction",reaction:{message_id:e,emoji:t}};return this.send(JSON.stringify(p))}};var S=class extends i{endpoint="phone_numbers";constructor(e,t){super(e,t)}async getPhoneNumberById(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${t}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async verifyCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var I=class extends i{endpoint="message_qrdls";constructor(e,t){super(e,t)}async createQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(e){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteQrCode(e){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}};var g=class extends i{constructor(e,t){super(e,t)}async register(e,t){let s={messaging_product:"whatsapp",pin:e,...t&&{data_localization_region:t}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends i{endpoint="message_templates";constructor(e,t){super(e,t)}async getTemplate(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getTemplates(e){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(e){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteTemplate(e){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends i{constructor(e,t){super(e,t)}async setTwoStepVerificationCode(e){let t={pin:e};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var A=class extends i{constructor(e,t){super(e,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(e,t){let s={url:e,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};0&&(module.exports={BaseAPI,BusinessProfileAPI,EncryptionAPI,FlowAPI,MediaAPI,MessagesAPI,PhoneNumberAPI,QrCodeAPI,RegistrationAPI,TemplateAPI,TwoStepVerificationAPI,WabaAPI});
|
|
1
|
+
"use strict";var b=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var M=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},_=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of O(e))!B.call(o,p)&&p!==t&&b(o,p,{get:()=>e[p],enumerable:!(s=D(e,p))||s.enumerable});return o};var U=o=>_(b({},"__esModule",{value:!0}),o);var x={};M(x,{BaseAPI:()=>i,BusinessProfileAPI:()=>l,EncryptionAPI:()=>f,FlowAPI:()=>c,MediaAPI:()=>P,MessagesAPI:()=>S,PhoneNumberAPI:()=>h,QrCodeAPI:()=>I,RegistrationAPI:()=>g,TemplateAPI:()=>T,TwoStepVerificationAPI:()=>q,WabaAPI:()=>A});module.exports=U(x);var n=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var G="BaseAPI",d=!1,F=new n(G,process.env.DEBUG==="true"||d),i=class{config;client;constructor(e,t){this.config=e,this.client=t,F.log("Initialized with HTTPSClient")}};var r=o=>{if(!o||Object.keys(o).length===0)return"";let e=new URLSearchParams;for(let[s,p]of Object.entries(o))p!==void 0&&e.append(s,String(p));let t=e.toString();return t?`?${t}`:""};var l=class extends i{endpoint="whatsapp_business_profile";constructor(e,t){super(e,t)}async getBusinessProfile(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${t}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async createUploadSession(e,t,s){let p=r({file_length:e,file_type:t,file_name:s});return this.client.sendRequest("POST",`app/uploads/${p}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,t)}async getUploadHandle(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}};var f=class extends i{endpoint="whatsapp_business_encryption";constructor(e,t){super(e,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(e){let t=new FormData;return t.append("business_public_key",e),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};var w="FlowAPI",K=!1,m=new n(w,process.env.DEBUG==="true"||K),c=class extends i{constructor(e,t){super(e,t),m.log("FlowAPI initialized")}async listFlows(e){return this.client.sendRequest("GET",`/${e}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&s.append("clone_flow_id",t.clone_flow_id),t.flow_json&&s.append("flow_json",t.flow_json),t.publish!==void 0&&s.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${e}/flows`,this.config.REQUEST_TIMEOUT,s)}async getFlow(e,t,s){let p=new URLSearchParams;t&&p.append("fields",t),s&&p.append("date_format",s);let N=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${e}${N}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.application_id&&s.append("application_id",t.application_id),this.client.sendRequest("POST",`/${e}`,this.config.REQUEST_TIMEOUT,s)}async deleteFlow(e){return this.client.sendRequest("DELETE",`/${e}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(e){return this.client.sendRequest("GET",`/${e}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(e,t){let s=new FormData;return s.append("asset_type",t.asset_type),s.append("file",t.file),s.append("name",t.name),this.client.sendRequest("POST",`/${e}/assets`,this.config.REQUEST_TIMEOUT,s)}async publishFlow(e){return this.client.sendRequest("POST",`/${e}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(e){return this.client.sendRequest("POST",`/${e}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(e,t){let s=new FormData;return s.append("source_waba_id",t.source_waba_id),t.source_flow_names&&s.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${e}/migrate_flows`,this.config.REQUEST_TIMEOUT,s)}};var P=class extends i{endpoint="media";constructor(e,t){super(e,t)}async getMediaById(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t="whatsapp"){let s=new FormData;return s.append("file",e),s.append("messaging_product",t),s.append("type",e.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(e){return this.client.sendRequest("DELETE",`${e}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(e){return this.client.sendRequest("GET",e,this.config.REQUEST_TIMEOUT,null)}};var S=class extends i{commonMethod="POST";commonEndpoint="messages";constructor(e,t){super(e,t)}bodyBuilder(e,t,s,p){let N={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:e,[e]:t};return p&&(N.context={message_id:p}),N}send(e){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,e)}async audio(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("audio",e,t.toString(),s)))}async contacts(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("contacts",e,t.toString(),s)))}async document(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("document",e,t.toString(),s)))}async image(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("image",e,t.toString(),s)))}async interactive(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async location(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("location",e,t.toString(),s)))}async sticker(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("sticker",e,t.toString(),s)))}async template(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("template",e,t.toString(),s)))}async text(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("text",e,t.toString(),s)))}async video(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("video",e,t.toString(),s)))}async status(e){let t={messaging_product:"whatsapp",...e};return this.send(JSON.stringify(t))}async markAsRead(e){return this.status({status:"read",message_id:e})}async showTypingIndicator(e){return this.status({status:"read",message_id:e,typing_indicator:{type:"text"}})}async interactiveList(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveCtaUrl(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveLocationRequest(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveAddressMessage(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveReplyButtons(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveFlow(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async reaction(e,t,s){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s.toString(),type:"reaction",reaction:{message_id:e,emoji:t}};return this.send(JSON.stringify(p))}};var h=class extends i{endpoint="phone_numbers";constructor(e,t){super(e,t)}async getPhoneNumberById(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${t}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async verifyCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var I=class extends i{endpoint="message_qrdls";constructor(e,t){super(e,t)}async createQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(e){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteQrCode(e){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}};var g=class extends i{constructor(e,t){super(e,t)}async register(e,t){let s={messaging_product:"whatsapp",pin:e,...t&&{data_localization_region:t}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends i{endpoint="message_templates";constructor(e,t){super(e,t)}async getTemplate(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getTemplates(e){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(e){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteTemplate(e){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends i{constructor(e,t){super(e,t)}async setTwoStepVerificationCode(e){let t={pin:e};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var A=class extends i{constructor(e,t){super(e,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:e,verify_token:t}){let s={override_callback_uri:e,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.client.sendRequest("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
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/index.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/utils/objectToQueryString.ts","../../src/api/businessProfile.ts","../../src/api/encryption.ts","../../src/api/flow.ts","../../src/api/media.ts","../../src/api/messages.ts","../../src/api/phoneNumber.ts","../../src/api/qrCode.ts","../../src/api/registration.ts","../../src/api/template.ts","../../src/api/twoStepVerification.ts","../../src/api/waba.ts"],"sourcesContent":["import BaseAPI from './base';\nimport BusinessProfileAPI from './businessProfile';\nimport EncryptionAPI from './encryption';\nimport FlowAPI from './flow';\nimport MediaAPI from './media';\nimport MessagesAPI from './messages';\nimport PhoneNumberAPI from './phoneNumber';\nimport QrCodeAPI from './qrCode';\nimport RegistrationAPI from './registration';\nimport TemplateAPI from './template';\nimport TwoStepVerificationAPI from './twoStepVerification';\nimport WabaAPI from './waba';\n\nexport {\n BaseAPI,\n BusinessProfileAPI,\n EncryptionAPI,\n FlowAPI,\n MediaAPI,\n MessagesAPI,\n PhoneNumberAPI,\n QrCodeAPI,\n RegistrationAPI,\n TemplateAPI,\n TwoStepVerificationAPI,\n WabaAPI,\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import BaseAPI from './base';\nimport { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport {\n FlowClass,\n FlowsListResponse,\n FlowCategoryEnum,\n Flow,\n FlowPreviewResponse,\n FlowAssetsResponse,\n FlowValidationError,\n FlowMigrationResponse,\n} from '../types/flow';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n async createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<\n RequesterResponseInterface<{ id: string; success: boolean; validation_errors?: FlowValidationError[] }>\n > {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.clone_flow_id) formData.append('clone_flow_id', data.clone_flow_id);\n if (data.flow_json) formData.append('flow_json', data.flow_json);\n if (data.publish !== undefined) formData.append('publish', String(data.publish));\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n async getFlow(\n flowId: string,\n fields?: string,\n dateFormat?: string,\n ): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n async updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.application_id) formData.append('application_id', data.application_id);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n async updateFlowJson(\n flowId: string,\n data: {\n asset_type: 'FLOW_JSON';\n file: Blob;\n name: string;\n },\n ): Promise<RequesterResponseInterface<{ success: boolean; validation_errors?: FlowValidationError[] }>> {\n const formData = new FormData();\n\n formData.append('asset_type', data.asset_type);\n formData.append('file', data.file);\n formData.append('name', data.name);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n async migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<RequesterResponseInterface<FlowMigrationResponse>> {\n const formData = new FormData();\n\n formData.append('source_waba_id', data.source_waba_id);\n if (data.source_flow_names) {\n formData.append('source_flow_names', JSON.stringify(data.source_flow_names));\n }\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport type { WabaConfigType } from '../types/config';\nimport type { MediaClass, MediaResponse, MediasResponse, UploadMediaResponse } from '../types/media';\nimport BaseAPI from './base';\n\nexport default class MediaAPI extends BaseAPI implements MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getMediaById(mediaId: string): Promise<RequesterResponseInterface<MediaResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${mediaId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async uploadMedia(\n file: File,\n messagingProduct: string = 'whatsapp',\n ): Promise<RequesterResponseInterface<UploadMediaResponse>> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n async deleteMedia(mediaId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${mediaId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async downloadMedia(mediaUrl: string): Promise<RequesterResponseInterface<Blob>> {\n return this.client.sendRequest(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n InteractiveTypesEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n toNumber: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: toNumber,\n type: type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param recipient Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n recipient: number,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: recipient.toString(),\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","import {\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n RequestVerificationCodeRequest,\n VerifyCodeRequest,\n} from 'src/types/phoneNumber';\nimport { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getPhoneNumberById(fields?: string): Promise<RequesterResponseInterface<PhoneNumberResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getPhoneNumbers(): Promise<RequesterResponseInterface<PhoneNumbersResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async requestVerificationCode(\n requestVerificationCodeRequest: RequestVerificationCodeRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(requestVerificationCodeRequest),\n );\n }\n\n async verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(verifyCodeRequest),\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\nimport {\n CreateQrCodeRequest,\n QrCodeClass,\n QrCodeResponse,\n QrCodesResponse,\n UpdateQrCodeRequest,\n} from '../types/qrCode';\n\nexport default class QrCodeAPI extends BaseAPI implements QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async createQrCode(request: CreateQrCodeRequest): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async getQrCodes(): Promise<RequesterResponseInterface<QrCodesResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getQrCode(qrCodeId: string): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateQrCode(request: UpdateQrCodeRequest): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async deleteQrCode(qrCodeId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { RegistrationClass } from '../types/registration';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum, DataLocalizationRegionEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class RegistrationAPI extends BaseAPI implements RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async register(\n pin: string,\n dataLocalizationRegion?: DataLocalizationRegionEnum,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async deregister(): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponsePagination, ResponseSuccess } from '../types/request';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from '../types/template';\nimport BaseAPI from './base';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<RequesterResponseInterface<TemplateResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateTemplate(\n templateId: string,\n template: Partial<TemplateRequestBody>,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(\n params: TemplateGetParams,\n ): Promise<RequesterResponseInterface<ResponsePagination<TemplateResponse>>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<RequesterResponseInterface<TemplateResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { TwoStepVerificationClass } from '../types/twoStepVerification';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async setTwoStepVerificationCode(pin: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n pin,\n };\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\nimport { WABAClass, WabaSubscriptions } from '../types/waba';\n\nexport default class WabaAPI extends BaseAPI implements WABAClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getAllWabaSubscriptions(): Promise<RequesterResponseInterface<WabaSubscriptions>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async subscribeToWaba(): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async unsubscribeFromWaba(): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async overrideWabaWebhook(\n webhookUrl: string,\n verifyToken: string,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n url: webhookUrl,\n verify_token: verifyToken,\n };\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/webhooks`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n"],"mappings":"yaAAA,IAAA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K,OAAO,sBAA8B,IAAI,KAAK,QAAQ,GAAGC,EAAoBD,CAAM,CAAC,GAC5F,KAAK,OAAO,gBACZ,IACJ,CACJ,CACJ,EC/DA,IAAqBE,EAArB,cAAoDC,CAA4C,CAC5F,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAEA,MAAM,2BAA2BC,EAAmE,CAChG,IAAMC,EAAO,CACT,IAAAD,CACJ,EAEA,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,kBAA6B,GAC5C,KAAK,OAAO,gBACZ,KAAK,UAAUC,CAAI,CACvB,CACJ,CACJ,ECjBA,IAAqBC,EAArB,cAAqCC,CAA6B,CAC9D,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAEA,MAAM,yBAAkF,CACpF,OAAO,KAAK,OAAO,kBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,iBAAwE,CAC1E,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,qBAA4E,CAC9E,OAAO,KAAK,OAAO,qBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,oBACFC,EACAC,EACoD,CACpD,IAAMC,EAAO,CACT,IAAKF,EACL,aAAcC,CAClB,EAEA,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,sBAA8B,YAC7C,KAAK,OAAO,gBACZ,KAAK,UAAUC,CAAI,CACvB,CACJ,CACJ","names":["api_exports","__export","BaseAPI","BusinessProfileAPI","EncryptionAPI","FlowAPI","MediaAPI","MessagesApi","PhoneNumberApi","QrCodeAPI","RegistrationAPI","TemplateApi","TwoStepVerificationAPI","WabaAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","objectToQueryString","params","searchParams","key","value","queryString","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","formData","flowId","fields","dateFormat","params","queryString","MediaAPI","BaseAPI","config","client","mediaId","file","messagingProduct","formData","mediaUrl","MessagesApi","BaseAPI","config","client","type","payload","toNumber","replyMessageId","body","recipient","bodyToSend","messageId","emoji","PhoneNumberApi","BaseAPI","config","client","fields","queryParams","objectToQueryString","requestVerificationCodeRequest","verifyCodeRequest","QrCodeAPI","BaseAPI","config","client","request","qrCodeId","RegistrationAPI","BaseAPI","config","client","pin","dataLocalizationRegion","body","TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","TwoStepVerificationAPI","BaseAPI","config","client","pin","body","WabaAPI","BaseAPI","config","client","webhookUrl","verifyToken","body"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/index.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/utils/objectToQueryString.ts","../../src/api/businessProfile.ts","../../src/api/encryption.ts","../../src/api/flow.ts","../../src/api/media.ts","../../src/api/messages.ts","../../src/api/phoneNumber.ts","../../src/api/qrCode.ts","../../src/api/registration.ts","../../src/api/template.ts","../../src/api/twoStepVerification.ts","../../src/api/waba.ts"],"sourcesContent":["import BaseAPI from './base';\nimport BusinessProfileAPI from './businessProfile';\nimport EncryptionAPI from './encryption';\nimport FlowAPI from './flow';\nimport MediaAPI from './media';\nimport MessagesAPI from './messages';\nimport PhoneNumberAPI from './phoneNumber';\nimport QrCodeAPI from './qrCode';\nimport RegistrationAPI from './registration';\nimport TemplateAPI from './template';\nimport TwoStepVerificationAPI from './twoStepVerification';\nimport WabaAPI from './waba';\n\nexport {\n BaseAPI,\n BusinessProfileAPI,\n EncryptionAPI,\n FlowAPI,\n MediaAPI,\n MessagesAPI,\n PhoneNumberAPI,\n QrCodeAPI,\n RegistrationAPI,\n TemplateAPI,\n TwoStepVerificationAPI,\n WabaAPI,\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import BaseAPI from './base';\nimport { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport {\n FlowClass,\n FlowsListResponse,\n FlowCategoryEnum,\n Flow,\n FlowPreviewResponse,\n FlowAssetsResponse,\n FlowValidationError,\n FlowMigrationResponse,\n} from '../types/flow';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n async createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<\n RequesterResponseInterface<{ id: string; success: boolean; validation_errors?: FlowValidationError[] }>\n > {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.clone_flow_id) formData.append('clone_flow_id', data.clone_flow_id);\n if (data.flow_json) formData.append('flow_json', data.flow_json);\n if (data.publish !== undefined) formData.append('publish', String(data.publish));\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n async getFlow(\n flowId: string,\n fields?: string,\n dateFormat?: string,\n ): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n async updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.application_id) formData.append('application_id', data.application_id);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n async updateFlowJson(\n flowId: string,\n data: {\n asset_type: 'FLOW_JSON';\n file: Blob;\n name: string;\n },\n ): Promise<RequesterResponseInterface<{ success: boolean; validation_errors?: FlowValidationError[] }>> {\n const formData = new FormData();\n\n formData.append('asset_type', data.asset_type);\n formData.append('file', data.file);\n formData.append('name', data.name);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n async migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<RequesterResponseInterface<FlowMigrationResponse>> {\n const formData = new FormData();\n\n formData.append('source_waba_id', data.source_waba_id);\n if (data.source_flow_names) {\n formData.append('source_flow_names', JSON.stringify(data.source_flow_names));\n }\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport type { WabaConfigType } from '../types/config';\nimport type { MediaClass, MediaResponse, MediasResponse, UploadMediaResponse } from '../types/media';\nimport BaseAPI from './base';\n\nexport default class MediaAPI extends BaseAPI implements MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getMediaById(mediaId: string): Promise<RequesterResponseInterface<MediaResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${mediaId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async uploadMedia(\n file: File,\n messagingProduct: string = 'whatsapp',\n ): Promise<RequesterResponseInterface<UploadMediaResponse>> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n async deleteMedia(mediaId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${mediaId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async downloadMedia(mediaUrl: string): Promise<RequesterResponseInterface<Blob>> {\n return this.client.sendRequest(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n InteractiveTypesEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n toNumber: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: toNumber,\n type: type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param recipient Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n recipient: number,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: recipient.toString(),\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","import {\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n RequestVerificationCodeRequest,\n VerifyCodeRequest,\n} from 'src/types/phoneNumber';\nimport { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getPhoneNumberById(fields?: string): Promise<RequesterResponseInterface<PhoneNumberResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getPhoneNumbers(): Promise<RequesterResponseInterface<PhoneNumbersResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async requestVerificationCode(\n requestVerificationCodeRequest: RequestVerificationCodeRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(requestVerificationCodeRequest),\n );\n }\n\n async verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(verifyCodeRequest),\n );\n }\n}\n","import { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\nimport {\n CreateQrCodeRequest,\n QrCodeClass,\n QrCodeResponse,\n QrCodesResponse,\n UpdateQrCodeRequest,\n} from '../types/qrCode';\n\nexport default class QrCodeAPI extends BaseAPI implements QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async createQrCode(request: CreateQrCodeRequest): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async getQrCodes(): Promise<RequesterResponseInterface<QrCodesResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async getQrCode(qrCodeId: string): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateQrCode(request: UpdateQrCodeRequest): Promise<RequesterResponseInterface<QrCodeResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n async deleteQrCode(qrCodeId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { RegistrationClass } from '../types/registration';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum, DataLocalizationRegionEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class RegistrationAPI extends BaseAPI implements RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async register(\n pin: string,\n dataLocalizationRegion?: DataLocalizationRegionEnum,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async deregister(): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { objectToQueryString } from 'src/utils/objectToQueryString';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponsePagination, ResponseSuccess } from '../types/request';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from '../types/template';\nimport BaseAPI from './base';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<RequesterResponseInterface<TemplateResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateTemplate(\n templateId: string,\n template: Partial<TemplateRequestBody>,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(\n params: TemplateGetParams,\n ): Promise<RequesterResponseInterface<ResponsePagination<TemplateResponse>>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<RequesterResponseInterface<TemplateResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { TwoStepVerificationClass } from '../types/twoStepVerification';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async setTwoStepVerificationCode(pin: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n pin,\n };\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { UpdateWabaSubscription, WABAClass, WabaSubscriptions } from '../types/waba';\nimport BaseAPI from './base';\n\nexport default class WabaAPI extends BaseAPI implements WABAClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getAllWabaSubscriptions(): Promise<RequesterResponseInterface<WabaSubscriptions>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async updateWabaSubscription({\n override_callback_uri,\n verify_token,\n }: UpdateWabaSubscription): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const body = {\n override_callback_uri,\n verify_token,\n };\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n async unsubscribeFromWaba(): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/subscribed_apps`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,uBAAAC,EAAA,kBAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,oBAAAC,EAAA,gBAAAC,EAAA,2BAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAd,GCGA,IAAqBe,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,C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ACpF,OAAO,KAAK,OAAO,kBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,uBAAuB,CACzB,sBAAAC,EACA,aAAAC,CACJ,EAAiF,CAC7E,IAAMC,EAAO,CACT,sBAAAF,EACA,aAAAC,CACJ,EACA,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,KAAK,UAAUC,CAAI,CACvB,CACJ,CAEA,MAAM,qBAA4E,CAC9E,OAAO,KAAK,OAAO,qBAEf,GAAG,KAAK,OAAO,sBAA8B,mBAC7C,KAAK,OAAO,gBACZ,IACJ,CACJ,CACJ","names":["api_exports","__export","BaseAPI","BusinessProfileAPI","EncryptionAPI","FlowAPI","MediaAPI","MessagesApi","PhoneNumberApi","QrCodeAPI","RegistrationAPI","TemplateApi","TwoStepVerificationAPI","WabaAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","objectToQueryString","params","searchParams","key","value","queryString","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","formData","flowId","fields","dateFormat","params","queryString","MediaAPI","BaseAPI","config","client","mediaId","file","messagingProduct","formData","mediaUrl","MessagesApi","BaseAPI","config","client","type","payload","toNumber","replyMessageId","body","recipient","bodyToSend","messageId","emoji","PhoneNumberApi","BaseAPI","config","client","fields","queryParams","objectToQueryString","requestVerificationCodeRequest","verifyCodeRequest","QrCodeAPI","BaseAPI","config","client","request","qrCodeId","RegistrationAPI","BaseAPI","config","client","pin","dataLocalizationRegion","body","TemplateApi","BaseAPI","config","client","templateId","template","params","objectToQueryString","TwoStepVerificationAPI","BaseAPI","config","client","pin","body","WabaAPI","BaseAPI","config","client","override_callback_uri","verify_token","body"]}
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var b="BaseAPI",D=!1,O=new n(b,process.env.DEBUG==="true"||D),i=class{config;client;constructor(e,t){this.config=e,this.client=t,O.log("Initialized with HTTPSClient")}};var r=o=>{if(!o||Object.keys(o).length===0)return"";let e=new URLSearchParams;for(let[s,p]of Object.entries(o))p!==void 0&&e.append(s,String(p));let t=e.toString();return t?`?${t}`:""};var f=class extends i{endpoint="whatsapp_business_profile";constructor(e,t){super(e,t)}async getBusinessProfile(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${t}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async createUploadSession(e,t,s){let p=r({file_length:e,file_type:t,file_name:s});return this.client.sendRequest("POST",`app/uploads/${p}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,t)}async getUploadHandle(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}};var c=class extends i{endpoint="whatsapp_business_encryption";constructor(e,t){super(e,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(e){let t=new FormData;return t.append("business_public_key",e),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};var B="FlowAPI",M=!1,_=new n(B,process.env.DEBUG==="true"||M),P=class extends i{constructor(e,t){super(e,t),_.log("FlowAPI initialized")}async listFlows(e){return this.client.sendRequest("GET",`/${e}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&s.append("clone_flow_id",t.clone_flow_id),t.flow_json&&s.append("flow_json",t.flow_json),t.publish!==void 0&&s.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${e}/flows`,this.config.REQUEST_TIMEOUT,s)}async getFlow(e,t,s){let p=new URLSearchParams;t&&p.append("fields",t),s&&p.append("date_format",s);let l=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${e}${l}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.application_id&&s.append("application_id",t.application_id),this.client.sendRequest("POST",`/${e}`,this.config.REQUEST_TIMEOUT,s)}async deleteFlow(e){return this.client.sendRequest("DELETE",`/${e}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(e){return this.client.sendRequest("GET",`/${e}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(e,t){let s=new FormData;return s.append("asset_type",t.asset_type),s.append("file",t.file),s.append("name",t.name),this.client.sendRequest("POST",`/${e}/assets`,this.config.REQUEST_TIMEOUT,s)}async publishFlow(e){return this.client.sendRequest("POST",`/${e}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(e){return this.client.sendRequest("POST",`/${e}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(e,t){let s=new FormData;return s.append("source_waba_id",t.source_waba_id),t.source_flow_names&&s.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${e}/migrate_flows`,this.config.REQUEST_TIMEOUT,s)}};var h=class extends i{endpoint="media";constructor(e,t){super(e,t)}async getMediaById(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t="whatsapp"){let s=new FormData;return s.append("file",e),s.append("messaging_product",t),s.append("type",e.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(e){return this.client.sendRequest("DELETE",`${e}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(e){return this.client.sendRequest("GET",e,this.config.REQUEST_TIMEOUT,null)}};var S=class extends i{commonMethod="POST";commonEndpoint="messages";constructor(e,t){super(e,t)}bodyBuilder(e,t,s,p){let l={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:e,[e]:t};return p&&(l.context={message_id:p}),l}send(e){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,e)}async audio(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("audio",e,t.toString(),s)))}async contacts(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("contacts",e,t.toString(),s)))}async document(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("document",e,t.toString(),s)))}async image(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("image",e,t.toString(),s)))}async interactive(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async location(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("location",e,t.toString(),s)))}async sticker(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("sticker",e,t.toString(),s)))}async template(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("template",e,t.toString(),s)))}async text(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("text",e,t.toString(),s)))}async video(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("video",e,t.toString(),s)))}async status(e){let t={messaging_product:"whatsapp",...e};return this.send(JSON.stringify(t))}async markAsRead(e){return this.status({status:"read",message_id:e})}async showTypingIndicator(e){return this.status({status:"read",message_id:e,typing_indicator:{type:"text"}})}async interactiveList(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveCtaUrl(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveLocationRequest(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveAddressMessage(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveReplyButtons(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveFlow(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async reaction(e,t,s){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s.toString(),type:"reaction",reaction:{message_id:e,emoji:t}};return this.send(JSON.stringify(p))}};var I=class extends i{endpoint="phone_numbers";constructor(e,t){super(e,t)}async getPhoneNumberById(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${t}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async verifyCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var g=class extends i{endpoint="message_qrdls";constructor(e,t){super(e,t)}async createQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(e){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteQrCode(e){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends i{constructor(e,t){super(e,t)}async register(e,t){let s={messaging_product:"whatsapp",pin:e,...t&&{data_localization_region:t}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends i{endpoint="message_templates";constructor(e,t){super(e,t)}async getTemplate(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getTemplates(e){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(e){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteTemplate(e){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends i{constructor(e,t){super(e,t)}async setTwoStepVerificationCode(e){let t={pin:e};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var N=class extends i{constructor(e,t){super(e,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(e,t){let s={url:e,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};export{i as BaseAPI,f as BusinessProfileAPI,c as EncryptionAPI,P as FlowAPI,h as MediaAPI,S as MessagesAPI,I as PhoneNumberAPI,g as QrCodeAPI,T as RegistrationAPI,q as TemplateAPI,A as TwoStepVerificationAPI,N as WabaAPI};
|
|
1
|
+
var n=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var b="BaseAPI",D=!1,O=new n(b,process.env.DEBUG==="true"||D),i=class{config;client;constructor(e,t){this.config=e,this.client=t,O.log("Initialized with HTTPSClient")}};var r=o=>{if(!o||Object.keys(o).length===0)return"";let e=new URLSearchParams;for(let[s,p]of Object.entries(o))p!==void 0&&e.append(s,String(p));let t=e.toString();return t?`?${t}`:""};var f=class extends i{endpoint="whatsapp_business_profile";constructor(e,t){super(e,t)}async getBusinessProfile(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${t}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async createUploadSession(e,t,s){let p=r({file_length:e,file_type:t,file_name:s});return this.client.sendRequest("POST",`app/uploads/${p}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,t)}async getUploadHandle(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}};var c=class extends i{endpoint="whatsapp_business_encryption";constructor(e,t){super(e,t)}async getEncryptionPublicKey(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(e){let t=new FormData;return t.append("business_public_key",e),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};var B="FlowAPI",M=!1,_=new n(B,process.env.DEBUG==="true"||M),P=class extends i{constructor(e,t){super(e,t),_.log("FlowAPI initialized")}async listFlows(e){return this.client.sendRequest("GET",`/${e}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&s.append("clone_flow_id",t.clone_flow_id),t.flow_json&&s.append("flow_json",t.flow_json),t.publish!==void 0&&s.append("publish",String(t.publish)),this.client.sendRequest("POST",`/${e}/flows`,this.config.REQUEST_TIMEOUT,s)}async getFlow(e,t,s){let p=new URLSearchParams;t&&p.append("fields",t),s&&p.append("date_format",s);let l=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${e}${l}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(e,t){let s=new FormData;return t.name&&s.append("name",t.name),t.categories&&s.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&s.append("endpoint_uri",t.endpoint_uri),t.application_id&&s.append("application_id",t.application_id),this.client.sendRequest("POST",`/${e}`,this.config.REQUEST_TIMEOUT,s)}async deleteFlow(e){return this.client.sendRequest("DELETE",`/${e}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(e){return this.client.sendRequest("GET",`/${e}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(e,t){let s=new FormData;return s.append("asset_type",t.asset_type),s.append("file",t.file),s.append("name",t.name),this.client.sendRequest("POST",`/${e}/assets`,this.config.REQUEST_TIMEOUT,s)}async publishFlow(e){return this.client.sendRequest("POST",`/${e}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(e){return this.client.sendRequest("POST",`/${e}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(e,t){let s=new FormData;return s.append("source_waba_id",t.source_waba_id),t.source_flow_names&&s.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.client.sendRequest("POST",`/${e}/migrate_flows`,this.config.REQUEST_TIMEOUT,s)}};var S=class extends i{endpoint="media";constructor(e,t){super(e,t)}async getMediaById(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(e,t="whatsapp"){let s=new FormData;return s.append("file",e),s.append("messaging_product",t),s.append("type",e.type),this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(e){return this.client.sendRequest("DELETE",`${e}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(e){return this.client.sendRequest("GET",e,this.config.REQUEST_TIMEOUT,null)}};var h=class extends i{commonMethod="POST";commonEndpoint="messages";constructor(e,t){super(e,t)}bodyBuilder(e,t,s,p){let l={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:e,[e]:t};return p&&(l.context={message_id:p}),l}send(e){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,e)}async audio(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("audio",e,t.toString(),s)))}async contacts(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("contacts",e,t.toString(),s)))}async document(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("document",e,t.toString(),s)))}async image(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("image",e,t.toString(),s)))}async interactive(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async location(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("location",e,t.toString(),s)))}async sticker(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("sticker",e,t.toString(),s)))}async template(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("template",e,t.toString(),s)))}async text(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("text",e,t.toString(),s)))}async video(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("video",e,t.toString(),s)))}async status(e){let t={messaging_product:"whatsapp",...e};return this.send(JSON.stringify(t))}async markAsRead(e){return this.status({status:"read",message_id:e})}async showTypingIndicator(e){return this.status({status:"read",message_id:e,typing_indicator:{type:"text"}})}async interactiveList(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveCtaUrl(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveLocationRequest(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveAddressMessage(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveReplyButtons(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async interactiveFlow(e,t,s){return this.send(JSON.stringify(this.bodyBuilder("interactive",e,t.toString(),s)))}async reaction(e,t,s){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s.toString(),type:"reaction",reaction:{message_id:e,emoji:t}};return this.send(JSON.stringify(p))}};var I=class extends i{endpoint="phone_numbers";constructor(e,t){super(e,t)}async getPhoneNumberById(e){let t=e?r({fields:e}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${t}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async verifyCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var g=class extends i{endpoint="message_qrdls";constructor(e,t){super(e,t)}async createQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(e){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(e){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteQrCode(e){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${e}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends i{constructor(e,t){super(e,t)}async register(e,t){let s={messaging_product:"whatsapp",pin:e,...t&&{data_localization_region:t}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends i{endpoint="message_templates";constructor(e,t){super(e,t)}async getTemplate(e){return this.client.sendRequest("GET",`${e}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(e,t){return this.client.sendRequest("POST",`${e}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getTemplates(e){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(e){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async deleteTemplate(e){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${r(e)}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends i{constructor(e,t){super(e,t)}async setTwoStepVerificationCode(e){let t={pin:e};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var N=class extends i{constructor(e,t){super(e,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:e,verify_token:t}){let s={override_callback_uri:e,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};export{i as BaseAPI,f as BusinessProfileAPI,c as EncryptionAPI,P as FlowAPI,S as MediaAPI,h as MessagesAPI,I as PhoneNumberAPI,g as QrCodeAPI,T as RegistrationAPI,q as TemplateAPI,A as TwoStepVerificationAPI,N as WabaAPI};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|