@great-detail/whatsapp
Advanced tools
Comparing version 6.10.1 to 6.10.2
#!/usr/bin/env node | ||
import{b as p}from"./chunk-KDS6MCMJ.js";import{program as m}from"commander";import E from"get-stdin";import{oraPromise as a}from"ora";var t={spinner:"simpleDotsScrolling"},i=process.env.WHATSAPP_ACCESS_TOKEN,r=process.env.WHATSAPP_PHONE_NUMBER_ID,s=new p;m.name("whatsapp").description("WhatsApp SDK CLI");var d=m.command("media").description("Media");d.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let c=await(await a(()=>s.media.download(n).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Downloading media"})).response.arrayBuffer(),l=Buffer.from(c);process.stdout.write(l)});d.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.delete(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Deleting media"});console.log(await o.json())});d.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.getURL(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Getting media URL"});console.log(await o.json())});d.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async n=>{let e=await E.buffer(),o=new Blob([e],{type:n.mimeType}),c=await a(()=>s.media.upload(o,{phoneNumberID:n.phoneNumberId,mimeType:n.mimeType,filename:n.filename}).send({headers:{Authorization:`Bearer ${n.accessToken}`}}),{...t,text:"Uploading media"});console.log(await c.json())});var A=m.command("message").description("Message"),u=A.command("send");u.command("image").description("Send a media message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).requiredOption("--media-id <MEDIA_ID>","Media ID").option("--filename <FILENAME>","Filename").option("--caption <CAPTION>","Caption").action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).image({id:e.mediaId,filename:e.filename,caption:e.caption},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending image"});console.log(await o.json())});u.command("text").description("Send a text message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--body <MESSAGE_TEXT_BODY>","Message Body").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).text({body:e.body},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending text message"});console.log(await o.json())});m.parseAsync(); | ||
import{b as p}from"./chunk-R3JEOSPQ.js";import{program as m}from"commander";import E from"get-stdin";import{oraPromise as a}from"ora";var t={spinner:"simpleDotsScrolling"},i=process.env.WHATSAPP_ACCESS_TOKEN,r=process.env.WHATSAPP_PHONE_NUMBER_ID,s=new p;m.name("whatsapp").description("WhatsApp SDK CLI");var d=m.command("media").description("Media");d.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let c=await(await a(()=>s.media.download(n).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Downloading media"})).response.arrayBuffer(),l=Buffer.from(c);process.stdout.write(l)});d.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.delete(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Deleting media"});console.log(await o.json())});d.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.media.getURL(n,{phoneNumberID:e.phoneNumberId}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Getting media URL"});console.log(await o.json())});d.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async n=>{let e=await E.buffer(),o=new Blob([e],{type:n.mimeType}),c=await a(()=>s.media.upload(o,{phoneNumberID:n.phoneNumberId,mimeType:n.mimeType,filename:n.filename}).send({headers:{Authorization:`Bearer ${n.accessToken}`}}),{...t,text:"Uploading media"});console.log(await c.json())});var A=m.command("message").description("Message"),u=A.command("send");u.command("image").description("Send a media message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).requiredOption("--media-id <MEDIA_ID>","Media ID").option("--filename <FILENAME>","Filename").option("--caption <CAPTION>","Caption").action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).image({id:e.mediaId,filename:e.filename,caption:e.caption},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending image"});console.log(await o.json())});u.command("text").description("Send a text message").argument("<TO_NUMBER>","To Number").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",r).requiredOption("--body <MESSAGE_TEXT_BODY>","Message Body").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",i).action(async(n,e)=>{let o=await a(()=>s.message({phoneNumberID:e.phoneNumberId}).text({body:e.body},{toNumber:n}).send({headers:{Authorization:`Bearer ${e.accessToken}`}}),{...t,text:"Sending text message"});console.log(await o.json())});m.parseAsync(); |
@@ -1,1 +0,1 @@ | ||
import{a,b,c}from"./chunk-KDS6MCMJ.js";export{b as CloudAPI,c as IncomingMessageType,a as OutgoingMessageType,b as default}; | ||
import{a,b,c}from"./chunk-R3JEOSPQ.js";export{b as CloudAPI,c as IncomingMessageType,a as OutgoingMessageType,b as default}; |
{ | ||
"name": "@great-detail/whatsapp", | ||
"version": "6.10.1", | ||
"version": "6.10.2", | ||
"type": "module", | ||
@@ -99,3 +99,3 @@ "description": "SDK for interfacing with WhatsApp Business Platform in Typescript or Node.js using the Cloud API, hosted by Meta.", | ||
"@types/node": "^20.12.8", | ||
"eslint": "^8.56.0", | ||
"eslint": "^9.2.0", | ||
"jest": "^29.7.0", | ||
@@ -102,0 +102,0 @@ "npm-run-all": "^4.1.5", |
@@ -25,3 +25,3 @@ /** | ||
expect(graphRequest.request.url).toBe( | ||
`https://graph.facebook.com/v19.0${endpoint}`, | ||
`https://graph.facebook.com/v20.0${endpoint}`, | ||
); | ||
@@ -39,3 +39,3 @@ }); | ||
expect(graphRequest.request.url).toBe( | ||
`https://graph.facebook.com/v19.0${endpoint}`, | ||
`https://graph.facebook.com/v20.0${endpoint}`, | ||
); | ||
@@ -67,3 +67,3 @@ }); | ||
// Assert | ||
expect(graphRequest.request.url).toBe(`${baseUrl}/v19.0${endpoint}`); | ||
expect(graphRequest.request.url).toBe(`${baseUrl}/v20.0${endpoint}`); | ||
}); | ||
@@ -70,0 +70,0 @@ |
@@ -65,3 +65,3 @@ /** | ||
*/ | ||
public static DEFAULT_GRAPH_VERSION = "v19.0"; | ||
public static DEFAULT_GRAPH_VERSION = "v20.0"; | ||
@@ -68,0 +68,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
307529