UNPKG

meta-cloud-api

Version:
2 lines 2.69 kB
import {a}from'./chunk-RIL6QABY.js';var i=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(e,s){super(e,s);}bodyBuilder(e,s,a,t){let n={messaging_product:"whatsapp",recipient_type:"individual",to:a,type:e,[e]:s};return t&&(n.context={message_id:t}),n}send(e){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,e)}async audio(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("audio",s,a,t)))}async contacts(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("contacts",s,a,t)))}async document(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("document",s,a,t)))}async image(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("image",s,a,t)))}async interactive(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,a,t)))}async location(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("location",s,a,t)))}async sticker(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("sticker",s,a,t)))}async template(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("template",s,a,t)))}async text(e){let{body:s,to:a,replyMessageId:t,previewUrl:n}=e,o=typeof s=="string"?{body:s,preview_url:n}:{...s,preview_url:n??s.preview_url};return this.send(JSON.stringify(this.bodyBuilder("text",o,a,t)))}async video(e){let{body:s,to:a,replyMessageId:t}=e;return this.send(JSON.stringify(this.bodyBuilder("video",s,a,t)))}async status(e){let s={messaging_product:"whatsapp",status:e.status,message_id:e.messageId,...e.typingIndicator&&{typing_indicator:e.typingIndicator}};return this.send(JSON.stringify(s))}async markAsRead(e){return this.status({status:"read",messageId:e.messageId})}async showTypingIndicator(e){return this.status({status:"read",messageId:e.messageId,typingIndicator:{type:"text"}})}async interactiveList(e){return this.interactive(e)}async interactiveCtaUrl(e){return this.interactive(e)}async interactiveLocationRequest(e){return this.interactive(e)}async interactiveAddressMessage(e){return this.interactive(e)}async interactiveReplyButtons(e){return this.interactive(e)}async interactiveFlow(e){return this.interactive(e)}async reaction(e){let s={message_id:e.messageId,emoji:e.emoji};return this.send(JSON.stringify(this.bodyBuilder("reaction",s,e.to)))}};var g=i;export{i as a,g as b};//# sourceMappingURL=chunk-7QBIZCJ4.js.map //# sourceMappingURL=chunk-7QBIZCJ4.js.map