@great-detail/whatsapp
Advanced tools
Comparing version 6.5.0 to 6.5.1
@@ -19,3 +19,3 @@ /** | ||
} | ||
export interface GraphRequestSendParams extends RequestInit { | ||
export interface GraphRequestSendParams { | ||
/** | ||
@@ -29,2 +29,10 @@ * Fetch provider. | ||
fetch?: typeof fetch; | ||
/** | ||
* Request headers. | ||
* Used to override the default request headers or set sensitive headers that | ||
* shouldn't be included in debug log outputs. | ||
* | ||
* @since 6.5.1 | ||
*/ | ||
headers?: HeadersInit; | ||
} | ||
@@ -31,0 +39,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import t from"../GraphResponse/index.js";export default class s extends Request{static{this.DEFAULT_GRAPH_API_BASE_URL="https://graph.facebook.com"}static{this.DEFAULT_GRAPH_VERSION="v18.0"}constructor(t,{logger:e,version:i=s.DEFAULT_GRAPH_VERSION,baseUrl:n=s.DEFAULT_GRAPH_API_BASE_URL,...r}={}){let h=new URL([i?"/":"",i,t].join(""),n);super(h,r),this.version=i,this.endpoint=t,this.baseUrl=n,e?.http(`${h.toString()} ${JSON.stringify(r)}`)}async send({fetch:s=fetch,...e}={}){return await s(this,e).then(({body:s,...e})=>new t(s,{request:this,...e}))}} | ||
import t from"../GraphResponse/index.js";export default class e extends Request{static{this.DEFAULT_GRAPH_API_BASE_URL="https://graph.facebook.com"}static{this.DEFAULT_GRAPH_VERSION="v18.0"}constructor(t,{logger:s,version:i=e.DEFAULT_GRAPH_VERSION,baseUrl:r=e.DEFAULT_GRAPH_API_BASE_URL,...h}={}){let n=new URL([i?"/":"",i,t].join(""),r);super(n,h),this.version=i,this.endpoint=t,this.baseUrl=r,s?.http(`${n.toString()} ${JSON.stringify(h)}`)}async send({fetch:e=fetch,...s}={}){if(s.headers)for(let[t,e]of new Headers(s.headers))this.headers.set(t,e);return await e(this,s).then(({body:e,...s})=>new t(e,{request:this,...s}))}} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@great-detail/whatsapp", | ||
"version": "6.5.0", | ||
"version": "6.5.1", | ||
"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.", |
@@ -32,3 +32,5 @@ <!-- Copyright (c) Meta Platforms, Inc. and affiliates. | ||
const sdk = new CloudAPI({ businessID }); | ||
const message = sdk.message.text({ body: "Hello" }, { toNumber: "1234567890" }); | ||
const message = sdk | ||
.message() | ||
.text({ body: "Hello" }, { toNumber: "1234567890" }); | ||
const sendReceipt = await message.send(); | ||
@@ -35,0 +37,0 @@ ``` |
@@ -21,3 +21,3 @@ /** | ||
export interface GraphRequestSendParams extends RequestInit { | ||
export interface GraphRequestSendParams { | ||
/** | ||
@@ -31,2 +31,11 @@ * Fetch provider. | ||
fetch?: typeof fetch; | ||
/** | ||
* Request headers. | ||
* Used to override the default request headers or set sensitive headers that | ||
* shouldn't be included in debug log outputs. | ||
* | ||
* @since 6.5.1 | ||
*/ | ||
headers?: HeadersInit; | ||
} | ||
@@ -110,2 +119,9 @@ | ||
}: GraphRequestSendParams = {}): Promise<GraphResponse<T>> { | ||
if (requestInit.headers) { | ||
const parsedHeaders = new Headers(requestInit.headers); | ||
for (const [key, value] of parsedHeaders) { | ||
this.headers.set(key, value); | ||
} | ||
} | ||
return await fetchAlternative(this, requestInit).then( | ||
@@ -112,0 +128,0 @@ ({ body, ...responseInit }) => |
Sorry, the diff of this file is not supported yet
285448
6648
86
272
1
38