@great-detail/whatsapp
Advanced tools
Comparing version 7.0.3 to 7.0.4
#!/usr/bin/env node | ||
import{a as c}from"./chunk-4GPT2GSB.js";import{program as r}from"commander";import d from"get-stdin";var a=process.env.WHATSAPP_ACCESS_TOKEN,m=process.env.WHATSAPP_PHONE_NUMBER_ID,i=new c;r.name("whatsapp").description("WhatsApp SDK CLI");var t=r.command("media").description("Media");t.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async e=>{let o=await(await i.media.download(e)).arrayBuffer(),s=Buffer.from(o);process.stdout.write(s)});t.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async(e,n)=>{let o=await i.media.delete({mediaID:e,phoneNumberID:n.phoneNumberId});console.log(await o.json())});t.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async(e,n)=>{let o=await i.media.getURL({mediaID:e,phoneNumberID:n.phoneNumberId});console.log(await o.json())});t.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",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async e=>{let n=await d.buffer(),o=new Blob([n],{type:e.mimeType}),s=await i.media.upload({file:o,phoneNumberID:e.phoneNumberId,mimeType:e.mimeType,filename:e.filename});console.log(await s.json())});r.parseAsync(); | ||
import{a as c}from"./chunk-AHXAI4LG.js";import{program as r}from"commander";import d from"get-stdin";var a=process.env.WHATSAPP_ACCESS_TOKEN,m=process.env.WHATSAPP_PHONE_NUMBER_ID,i=new c;r.name("whatsapp").description("WhatsApp SDK CLI");var t=r.command("media").description("Media");t.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async e=>{let o=await(await i.media.download(e)).arrayBuffer(),s=Buffer.from(o);process.stdout.write(s)});t.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async(e,n)=>{let o=await i.media.delete({mediaID:e,phoneNumberID:n.phoneNumberId});console.log(await o.json())});t.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async(e,n)=>{let o=await i.media.getURL({mediaID:e,phoneNumberID:n.phoneNumberId});console.log(await o.json())});t.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",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",a).action(async e=>{let n=await d.buffer(),o=new Blob([n],{type:e.mimeType}),s=await i.media.upload({file:o,phoneNumberID:e.phoneNumberId,mimeType:e.mimeType,filename:e.filename});console.log(await s.json())});r.parseAsync(); |
@@ -30,2 +30,76 @@ import * as ky from 'ky'; | ||
type GetBusinessProfileFields = { | ||
about?: boolean; | ||
address?: boolean; | ||
description?: boolean; | ||
email?: boolean; | ||
profile_picture_url?: boolean; | ||
websites?: boolean; | ||
vertical?: boolean; | ||
}; | ||
type GetBusinessProfileOptions<Fields extends GetBusinessProfileFields = object> = { | ||
phoneNumberID: PhoneNumberID; | ||
fields?: Fields; | ||
}; | ||
type GetBusinessProfilePayload<Fields extends GetBusinessProfileFields = object> = { | ||
data: [ | ||
{ | ||
about: Fields extends { | ||
about: true; | ||
} ? string : undefined; | ||
address: Fields extends { | ||
address: true; | ||
} ? string : undefined; | ||
description: Fields extends { | ||
description: true; | ||
} ? string : undefined; | ||
email: Fields extends { | ||
email: true; | ||
} ? string : undefined; | ||
messaging_product: "whatsapp"; | ||
profile_picture_url: Fields extends { | ||
profile_picture_url: true; | ||
} ? string : undefined; | ||
vertical: Fields extends { | ||
vertical: true; | ||
} ? "" | (string & NonNullable<unknown>) : undefined; | ||
websites: Fields extends { | ||
websites: true; | ||
} ? [string] | [string, string] | (string[] & NonNullable<unknown>) : undefined; | ||
} | ||
]; | ||
}; | ||
type UpdateBusinessProfileOptions = { | ||
phoneNumberID: PhoneNumberID; | ||
about?: string; | ||
address?: string; | ||
description?: string; | ||
email?: string; | ||
profile_picture_handle?: string; | ||
vertical?: "" | (string & NonNullable<unknown>); | ||
websites?: [string] | [string, string] | (string[] & NonNullable<unknown>); | ||
}; | ||
type UpdateBusinessProfilePayload = { | ||
success: boolean; | ||
}; | ||
interface MethodOptions$3 { | ||
request?: Options$1; | ||
} | ||
declare class BusinessProfile { | ||
protected _request: Options$1; | ||
constructor(_request: Options$1); | ||
protected getEndpoint(phoneNumberID: PhoneNumberID): string; | ||
getBusinessProfile<Fields extends GetBusinessProfileFields = object>({ phoneNumberID, fields, request, }: MethodOptions$3 & GetBusinessProfileOptions<Fields>): ky.ResponsePromise<GetBusinessProfilePayload<Fields>>; | ||
updateBusinessProfile({ phoneNumberID, request, ...json }: MethodOptions$3 & UpdateBusinessProfileOptions): ky.ResponsePromise<UpdateBusinessProfilePayload>; | ||
} | ||
/** | ||
* WhatsApp NodeJS SDK. | ||
* | ||
* @author Great Detail Ltd <info@greatdetail.com> | ||
* @author Dom Webber <dom.webber@hotmail.com> | ||
* @see https://greatdetail.com | ||
*/ | ||
type MediaID = string; | ||
@@ -787,2 +861,6 @@ interface MediaUploadOptions { | ||
/** | ||
* Additional unique, alphanumeric identifier for a WhatsApp user. | ||
*/ | ||
user_id?: string; | ||
/** | ||
* A customer profile object. | ||
@@ -1263,2 +1341,3 @@ */ | ||
protected _request: Options$1; | ||
businessProfile: BusinessProfile; | ||
message: Message; | ||
@@ -1265,0 +1344,0 @@ subscribedApps: SubscribedApps; |
@@ -1,1 +0,1 @@ | ||
import{a}from"./chunk-4GPT2GSB.js";export{a as Client,a as CloudAPI,a as default}; | ||
import{a}from"./chunk-AHXAI4LG.js";export{a as Client,a as CloudAPI,a as default}; |
{ | ||
"name": "@great-detail/whatsapp", | ||
"version": "7.0.3", | ||
"version": "7.0.4", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "SDK for interfacing with WhatsApp Business Platform in Typescript or Node.js using the Cloud API, hosted by Meta.", |
@@ -98,5 +98,5 @@ # Node.js SDK for WhatsApp Business Platform APIs | ||
| SDK | Cloud API | NodeJS (Tested) | | ||
| :--- | :-------: | --------------: | | ||
| v7.x | v20 | v18+ | | ||
| SDK | Cloud API | NodeJS | | ||
| :--- | :-------: | -----: | | ||
| v7.x | v20 | v18+ | | ||
@@ -103,0 +103,0 @@ Whilst the SDK may work with alternative versions of the Graph API, it is |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111575
1377