meta-cloud-api 0.2.12 → 0.2.13
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/README.md +5 -2
- package/dist/api/index.d.mts +495 -27
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/chunk-KZQQJAPX.mjs +2 -0
- package/dist/chunk-KZQQJAPX.mjs.map +1 -0
- package/dist/chunk-N7A7DQDX.mjs +2 -0
- package/dist/chunk-N7A7DQDX.mjs.map +1 -0
- package/dist/chunk-QE4PKOSW.mjs +2 -0
- package/dist/chunk-QE4PKOSW.mjs.map +1 -0
- package/dist/chunk-R4CFE2XP.mjs +2 -0
- package/dist/chunk-R4CFE2XP.mjs.map +1 -0
- package/dist/chunk-XVYL7ZTG.mjs +2 -0
- package/dist/chunk-XVYL7ZTG.mjs.map +1 -0
- package/dist/index.d.mts +142 -43
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +512 -19
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +70 -21
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/waba-RRlZTQUG.d.mts +2229 -0
- package/dist/{types/whatsapp.d.ts → whatsapp-BNHXjrds.d.mts} +2 -17
- package/package.json +52 -18
- package/dist/api/base.d.mts +0 -15
- package/dist/api/base.d.ts +0 -15
- package/dist/api/base.js +0 -2
- package/dist/api/base.js.map +0 -1
- package/dist/api/base.mjs +0 -2
- package/dist/api/base.mjs.map +0 -1
- package/dist/api/businessProfile.d.mts +0 -145
- package/dist/api/businessProfile.d.ts +0 -145
- package/dist/api/businessProfile.js +0 -2
- package/dist/api/businessProfile.js.map +0 -1
- package/dist/api/businessProfile.mjs +0 -2
- package/dist/api/businessProfile.mjs.map +0 -1
- package/dist/api/encryption.d.mts +0 -15
- package/dist/api/encryption.d.ts +0 -15
- package/dist/api/encryption.js +0 -2
- package/dist/api/encryption.js.map +0 -1
- package/dist/api/encryption.mjs +0 -2
- package/dist/api/encryption.mjs.map +0 -1
- package/dist/api/flow.d.mts +0 -126
- package/dist/api/flow.d.ts +0 -126
- package/dist/api/flow.js +0 -2
- package/dist/api/flow.js.map +0 -1
- package/dist/api/flow.mjs +0 -2
- package/dist/api/flow.mjs.map +0 -1
- package/dist/api/index.d.ts +0 -28
- package/dist/api/index.js +0 -2
- package/dist/api/index.js.map +0 -1
- package/dist/api/media.d.mts +0 -17
- package/dist/api/media.d.ts +0 -17
- package/dist/api/media.js +0 -2
- package/dist/api/media.js.map +0 -1
- package/dist/api/media.mjs +0 -2
- package/dist/api/media.mjs.map +0 -1
- package/dist/api/messages.d.mts +0 -193
- package/dist/api/messages.d.ts +0 -193
- package/dist/api/messages.js +0 -2
- package/dist/api/messages.js.map +0 -1
- package/dist/api/messages.mjs +0 -2
- package/dist/api/messages.mjs.map +0 -1
- package/dist/api/phoneNumber.d.mts +0 -17
- package/dist/api/phoneNumber.d.ts +0 -17
- package/dist/api/phoneNumber.js +0 -2
- package/dist/api/phoneNumber.js.map +0 -1
- package/dist/api/phoneNumber.mjs +0 -2
- package/dist/api/phoneNumber.mjs.map +0 -1
- package/dist/api/qrCode.d.mts +0 -18
- package/dist/api/qrCode.d.ts +0 -18
- package/dist/api/qrCode.js +0 -2
- package/dist/api/qrCode.js.map +0 -1
- package/dist/api/qrCode.mjs +0 -2
- package/dist/api/qrCode.mjs.map +0 -1
- package/dist/api/registration.d.mts +0 -14
- package/dist/api/registration.d.ts +0 -14
- package/dist/api/registration.js +0 -2
- package/dist/api/registration.js.map +0 -1
- package/dist/api/registration.mjs +0 -2
- package/dist/api/registration.mjs.map +0 -1
- package/dist/api/template.d.mts +0 -18
- package/dist/api/template.d.ts +0 -18
- package/dist/api/template.js +0 -2
- package/dist/api/template.js.map +0 -1
- package/dist/api/template.mjs +0 -2
- package/dist/api/template.mjs.map +0 -1
- package/dist/api/twoStepVerification.d.mts +0 -13
- package/dist/api/twoStepVerification.d.ts +0 -13
- package/dist/api/twoStepVerification.js +0 -2
- package/dist/api/twoStepVerification.js.map +0 -1
- package/dist/api/twoStepVerification.mjs +0 -2
- package/dist/api/twoStepVerification.mjs.map +0 -1
- package/dist/api/waba.d.mts +0 -16
- package/dist/api/waba.d.ts +0 -16
- package/dist/api/waba.js +0 -2
- package/dist/api/waba.js.map +0 -1
- package/dist/api/waba.mjs +0 -2
- package/dist/api/waba.mjs.map +0 -1
- package/dist/enums-CI7vzKhn.d.mts +0 -687
- package/dist/enums-CI7vzKhn.d.ts +0 -687
- package/dist/httpsClient.d.mts +0 -22
- package/dist/httpsClient.d.ts +0 -22
- package/dist/httpsClient.js +0 -2
- package/dist/httpsClient.js.map +0 -1
- package/dist/httpsClient.mjs +0 -2
- package/dist/httpsClient.mjs.map +0 -1
- package/dist/index.d.ts +0 -46
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/request.d.mts +0 -25
- package/dist/request.d.ts +0 -25
- package/dist/request.js +0 -2
- package/dist/request.js.map +0 -1
- package/dist/request.mjs +0 -2
- package/dist/request.mjs.map +0 -1
- package/dist/types/base.d.mts +0 -8
- package/dist/types/base.d.ts +0 -8
- package/dist/types/base.js +0 -2
- package/dist/types/base.js.map +0 -1
- package/dist/types/base.mjs +0 -1
- package/dist/types/base.mjs.map +0 -1
- package/dist/types/businessProfile.d.mts +0 -153
- package/dist/types/businessProfile.d.ts +0 -153
- package/dist/types/businessProfile.js +0 -2
- package/dist/types/businessProfile.js.map +0 -1
- package/dist/types/businessProfile.mjs +0 -1
- package/dist/types/businessProfile.mjs.map +0 -1
- package/dist/types/config.d.mts +0 -62
- package/dist/types/config.d.ts +0 -62
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +0 -1
- package/dist/types/config.mjs +0 -1
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/encryption.d.mts +0 -13
- package/dist/types/encryption.d.ts +0 -13
- package/dist/types/encryption.js +0 -2
- package/dist/types/encryption.js.map +0 -1
- package/dist/types/encryption.mjs +0 -1
- package/dist/types/encryption.mjs.map +0 -1
- package/dist/types/enums.d.mts +0 -1
- package/dist/types/enums.d.ts +0 -1
- package/dist/types/enums.js +0 -2
- package/dist/types/enums.js.map +0 -1
- package/dist/types/enums.mjs +0 -2
- package/dist/types/enums.mjs.map +0 -1
- package/dist/types/flow.d.mts +0 -404
- package/dist/types/flow.d.ts +0 -404
- package/dist/types/flow.js +0 -2
- package/dist/types/flow.js.map +0 -1
- package/dist/types/flow.mjs +0 -2
- package/dist/types/flow.mjs.map +0 -1
- package/dist/types/httpsClient.d.mts +0 -19
- package/dist/types/httpsClient.d.ts +0 -19
- package/dist/types/httpsClient.js +0 -2
- package/dist/types/httpsClient.js.map +0 -1
- package/dist/types/httpsClient.mjs +0 -1
- package/dist/types/httpsClient.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -20
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/logger.d.mts +0 -9
- package/dist/types/logger.d.ts +0 -9
- package/dist/types/logger.js +0 -2
- package/dist/types/logger.js.map +0 -1
- package/dist/types/logger.mjs +0 -1
- package/dist/types/logger.mjs.map +0 -1
- package/dist/types/media.d.mts +0 -31
- package/dist/types/media.d.ts +0 -31
- package/dist/types/media.js +0 -2
- package/dist/types/media.js.map +0 -1
- package/dist/types/media.mjs +0 -1
- package/dist/types/media.mjs.map +0 -1
- package/dist/types/messages.d.mts +0 -558
- package/dist/types/messages.d.ts +0 -558
- package/dist/types/messages.js +0 -2
- package/dist/types/messages.js.map +0 -1
- package/dist/types/messages.mjs +0 -1
- package/dist/types/messages.mjs.map +0 -1
- package/dist/types/phoneNumber.d.mts +0 -82
- package/dist/types/phoneNumber.d.ts +0 -82
- package/dist/types/phoneNumber.js +0 -2
- package/dist/types/phoneNumber.js.map +0 -1
- package/dist/types/phoneNumber.mjs +0 -1
- package/dist/types/phoneNumber.mjs.map +0 -1
- package/dist/types/qrCode.d.mts +0 -27
- package/dist/types/qrCode.d.ts +0 -27
- package/dist/types/qrCode.js +0 -2
- package/dist/types/qrCode.js.map +0 -1
- package/dist/types/qrCode.mjs +0 -1
- package/dist/types/qrCode.mjs.map +0 -1
- package/dist/types/registration.d.mts +0 -14
- package/dist/types/registration.d.ts +0 -14
- package/dist/types/registration.js +0 -2
- package/dist/types/registration.js.map +0 -1
- package/dist/types/registration.mjs +0 -1
- package/dist/types/registration.mjs.map +0 -1
- package/dist/types/request.d.mts +0 -50
- package/dist/types/request.d.ts +0 -50
- package/dist/types/request.js +0 -2
- package/dist/types/request.js.map +0 -1
- package/dist/types/request.mjs +0 -1
- package/dist/types/request.mjs.map +0 -1
- package/dist/types/template.d.mts +0 -106
- package/dist/types/template.d.ts +0 -106
- package/dist/types/template.js +0 -2
- package/dist/types/template.js.map +0 -1
- package/dist/types/template.mjs +0 -1
- package/dist/types/template.mjs.map +0 -1
- package/dist/types/twoStepVerification.d.mts +0 -11
- package/dist/types/twoStepVerification.d.ts +0 -11
- package/dist/types/twoStepVerification.js +0 -2
- package/dist/types/twoStepVerification.js.map +0 -1
- package/dist/types/twoStepVerification.mjs +0 -1
- package/dist/types/twoStepVerification.mjs.map +0 -1
- package/dist/types/waba.d.mts +0 -78
- package/dist/types/waba.d.ts +0 -78
- package/dist/types/waba.js +0 -2
- package/dist/types/waba.js.map +0 -1
- package/dist/types/waba.mjs +0 -2
- package/dist/types/waba.mjs.map +0 -1
- package/dist/types/webhook.d.mts +0 -486
- package/dist/types/webhook.d.ts +0 -486
- package/dist/types/webhook.js +0 -2
- package/dist/types/webhook.js.map +0 -1
- package/dist/types/webhook.mjs +0 -2
- package/dist/types/webhook.mjs.map +0 -1
- package/dist/types/whatsapp.d.mts +0 -61
- package/dist/types/whatsapp.js +0 -2
- package/dist/types/whatsapp.js.map +0 -1
- package/dist/types/whatsapp.mjs +0 -1
- package/dist/types/whatsapp.mjs.map +0 -1
- package/dist/utils/buildFieldsQueryString.d.mts +0 -3
- package/dist/utils/buildFieldsQueryString.d.ts +0 -3
- package/dist/utils/buildFieldsQueryString.js +0 -2
- package/dist/utils/buildFieldsQueryString.js.map +0 -1
- package/dist/utils/buildFieldsQueryString.mjs +0 -2
- package/dist/utils/buildFieldsQueryString.mjs.map +0 -1
- package/dist/utils/filters.d.mts +0 -144
- package/dist/utils/filters.d.ts +0 -144
- package/dist/utils/filters.js +0 -2
- package/dist/utils/filters.js.map +0 -1
- package/dist/utils/filters.mjs +0 -2
- package/dist/utils/filters.mjs.map +0 -1
- package/dist/utils/flowTypeGuards.d.mts +0 -46
- package/dist/utils/flowTypeGuards.d.ts +0 -46
- package/dist/utils/flowTypeGuards.js +0 -2
- package/dist/utils/flowTypeGuards.js.map +0 -1
- package/dist/utils/flowTypeGuards.mjs +0 -2
- package/dist/utils/flowTypeGuards.mjs.map +0 -1
- package/dist/utils/generateXHub256Sig.d.mts +0 -3
- package/dist/utils/generateXHub256Sig.d.ts +0 -3
- package/dist/utils/generateXHub256Sig.js +0 -2
- package/dist/utils/generateXHub256Sig.js.map +0 -1
- package/dist/utils/generateXHub256Sig.mjs +0 -2
- package/dist/utils/generateXHub256Sig.mjs.map +0 -1
- package/dist/utils/importConfig.d.mts +0 -21
- package/dist/utils/importConfig.d.ts +0 -21
- package/dist/utils/importConfig.js +0 -2
- package/dist/utils/importConfig.js.map +0 -1
- package/dist/utils/importConfig.mjs +0 -2
- package/dist/utils/importConfig.mjs.map +0 -1
- package/dist/utils/index.d.ts +0 -22
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/isMetaError.d.mts +0 -21
- package/dist/utils/isMetaError.d.ts +0 -21
- package/dist/utils/isMetaError.js +0 -2
- package/dist/utils/isMetaError.js.map +0 -1
- package/dist/utils/isMetaError.mjs +0 -2
- package/dist/utils/isMetaError.mjs.map +0 -1
- package/dist/utils/logger.d.mts +0 -13
- package/dist/utils/logger.d.ts +0 -13
- package/dist/utils/logger.js +0 -2
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/logger.mjs +0 -2
- package/dist/utils/logger.mjs.map +0 -1
- package/dist/utils/objectToQueryString.d.mts +0 -3
- package/dist/utils/objectToQueryString.d.ts +0 -3
- package/dist/utils/objectToQueryString.js +0 -2
- package/dist/utils/objectToQueryString.js.map +0 -1
- package/dist/utils/objectToQueryString.mjs +0 -2
- package/dist/utils/objectToQueryString.mjs.map +0 -1
- package/dist/webhook.d.mts +0 -123
- package/dist/webhook.d.ts +0 -123
- package/dist/webhook.js +0 -3
- package/dist/webhook.js.map +0 -1
- package/dist/webhook.mjs +0 -3
- package/dist/webhook.mjs.map +0 -1
- package/dist/whatsapp.d.mts +0 -58
- package/dist/whatsapp.d.ts +0 -58
- package/dist/whatsapp.js +0 -2
- package/dist/whatsapp.js.map +0 -1
- package/dist/whatsapp.mjs +0 -2
- package/dist/whatsapp.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# Meta Cloud API
|
|
2
2
|
|
|
3
3
|
<div style="display: flex; align-items: center;">
|
|
4
|
-
<img src="
|
|
4
|
+
<img src="public/README.svg" alt="Meta Cloud API" style="flex: 1; width: 100px;">
|
|
5
5
|
<div style="flex: 1; padding-left: 20px;">
|
|
6
6
|
<p>Meta Cloud API - A powerful TypeScript wrapper for Meta's Cloud API, providing a clean and type-safe interface for WhatsApp Business Platform integration.</p>
|
|
7
7
|
</div>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
|
+
[](https://www.npmjs.com/package/meta-cloud-api)
|
|
11
|
+
[](https://www.npmjs.com/package/meta-cloud-api)
|
|
12
|
+
[](https://github.com/froggy1014/meta-cloud-api/blob/main/LICENSE)
|
|
13
|
+
|
|
10
14
|
## Resources
|
|
11
15
|
|
|
12
16
|
- [Documentation](https://www.meta-cloud-api.xyz/)
|
|
13
|
-
- [API Reference (Swagger)](https://meta-cloud-api-swagger.vercel.app/api-docs/)
|
|
14
17
|
|
|
15
18
|
## Features
|
|
16
19
|
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,28 +1,496 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as BusinessProfileAPI } from './businessProfile.mjs';
|
|
3
|
-
export { default as EncryptionAPI } from './encryption.mjs';
|
|
4
|
-
export { default as FlowAPI } from './flow.mjs';
|
|
5
|
-
export { default as MediaAPI } from './media.mjs';
|
|
6
|
-
export { default as MessagesAPI } from './messages.mjs';
|
|
7
|
-
export { default as PhoneNumberAPI } from './phoneNumber.mjs';
|
|
8
|
-
export { default as QrCodeAPI } from './qrCode.mjs';
|
|
9
|
-
export { default as RegistrationAPI } from './registration.mjs';
|
|
10
|
-
export { default as TemplateAPI } from './template.mjs';
|
|
11
|
-
export { default as TwoStepVerificationAPI } from './twoStepVerification.mjs';
|
|
12
|
-
export { default as WabaAPI } from './waba.mjs';
|
|
13
|
-
import '../enums-CI7vzKhn.mjs';
|
|
14
|
-
import '../types/base.mjs';
|
|
15
|
-
import '../types/config.mjs';
|
|
16
|
-
import '../types/request.mjs';
|
|
17
|
-
import '../types/businessProfile.mjs';
|
|
18
|
-
import '../types/encryption.mjs';
|
|
19
|
-
import '../types/flow.mjs';
|
|
1
|
+
import { h as BaseClass, d as WabaConfigType, c as RequesterClass, H as HttpMethodsEnum, B as BusinessProfileClass, j as BusinessProfileFieldsParam, l as BusinessProfileResponse, U as UpdateBusinessProfileRequest, bm as ResponseSuccess, n as UploadSessionResponse, o as UploadBusinessProfileResponse, p as UploadHandle, E as EncryptionClass, q as EncryptionPublicKeyResponse, F as FlowClass, a6 as FlowsListResponse, $ as FlowCategoryEnum, ad as CreateFlowResponse, a3 as Flow, aa as FlowPreviewResponse, a8 as FlowAssetsResponse, ae as UpdateFlowResponse, ag as ValidateFlowJsonResponse, af as FlowMigrationResponse, b as MediaClass, as as MediaResponse, au as UploadMediaResponse, M as MessagesClass, e as MessageTypesEnum, aA as AudioMediaObject, aC as ContactObject, aE as DocumentMediaObject, aG as ImageMediaObject, aI as InteractiveObject, aT as LocationObject, aR as MessageTemplateObject, v as ComponentTypesEnum, aK as StickerMediaObject, aN as TextObject, aP as VideoMediaObject, az as MessageRequestBody, aW as MessageRequestParams, aV as MessagesResponse, aX as TextMessageParams, aZ as StatusParams, I as InteractiveTypesEnum, aY as ReactionParams, P as PhoneNumberClass, b8 as PhoneNumberResponse, ba as PhoneNumbersResponse, bb as RequestVerificationCodeRequest, bc as VerifyCodeRequest, Q as QrCodeClass, bg as CreateQrCodeRequest, be as QrCodeResponse, bf as QrCodesResponse, bh as UpdateQrCodeRequest, R as RegistrationClass, Y as DataLocalizationRegionEnum, T as TemplateClass, bG as TemplateResponse, bF as TemplateRequestBody, bH as TemplateGetParams, bo as ResponsePagination, bI as TemplateDeleteParams, a as TwoStepVerificationClass, W as WABAClass, bW as WabaAccountFieldsParam, bU as WabaAccount, bM as WabaSubscriptions, bL as UpdateWabaSubscription } from '../waba-RRlZTQUG.mjs';
|
|
20
2
|
import 'http';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
|
|
4
|
+
declare class BaseAPI implements BaseClass {
|
|
5
|
+
protected config: WabaConfigType;
|
|
6
|
+
protected client: RequesterClass;
|
|
7
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
8
|
+
protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
9
|
+
protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
10
|
+
protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* API for managing WhatsApp Business Profiles and profile pictures.
|
|
15
|
+
*
|
|
16
|
+
* This API allows you to:
|
|
17
|
+
* - Get business profile information
|
|
18
|
+
* - Update business profile details
|
|
19
|
+
* - Upload profile pictures using a three-step process:
|
|
20
|
+
* 1. Create an upload session
|
|
21
|
+
* 2. Upload the image binary data
|
|
22
|
+
* 3. Get the upload handle to use when updating the profile
|
|
23
|
+
*/
|
|
24
|
+
declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {
|
|
25
|
+
private readonly endpoint;
|
|
26
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
27
|
+
/**
|
|
28
|
+
* Get your business profile information.
|
|
29
|
+
*
|
|
30
|
+
* Use this method to retrieve details about your WhatsApp business profile, including
|
|
31
|
+
* about text, address, description, email, profile picture URL, websites, and vertical.
|
|
32
|
+
*
|
|
33
|
+
* @param fields Fields to be returned in the response. If not specified, all fields will be returned.
|
|
34
|
+
* Possible values: about, address, description, email, profile_picture_url, websites, vertical
|
|
35
|
+
* @returns The business profile information.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Get all business profile fields
|
|
39
|
+
* const profile = await whatsappClient.businessProfile.getBusinessProfile();
|
|
40
|
+
*
|
|
41
|
+
* // Get specific business profile fields
|
|
42
|
+
* const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
|
|
43
|
+
*
|
|
44
|
+
* // Using the BusinessProfileFieldsParam type
|
|
45
|
+
* const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);
|
|
46
|
+
*/
|
|
47
|
+
getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Update your business profile.
|
|
50
|
+
*
|
|
51
|
+
* Use this method to update one or more fields of your WhatsApp business profile.
|
|
52
|
+
*
|
|
53
|
+
* @param updateRequest The request object containing the fields to update.
|
|
54
|
+
* - messaging_product: Required. Always set to "whatsapp".
|
|
55
|
+
* - about: Optional. Business's About text (1-139 characters).
|
|
56
|
+
* - address: Optional. Business address (max 256 characters).
|
|
57
|
+
* - description: Optional. Business description (max 512 characters).
|
|
58
|
+
* - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).
|
|
59
|
+
* - email: Optional. Contact email (valid format, max 128 characters).
|
|
60
|
+
* - websites: Optional. Up to 2 URLs (max 256 characters each).
|
|
61
|
+
* - profile_picture_handle: Optional. Handle from upload process.
|
|
62
|
+
* @returns Response indicating success or failure.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Update business profile with multiple fields including vertical using enum
|
|
66
|
+
* await whatsappClient.businessProfile.updateBusinessProfile({
|
|
67
|
+
* messaging_product: 'whatsapp',
|
|
68
|
+
* about: 'We provide excellent service',
|
|
69
|
+
* email: 'contact@example.com',
|
|
70
|
+
* websites: ['https://example.com'],
|
|
71
|
+
* vertical: BusinessVerticalEnum.RETAIL
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
|
|
75
|
+
/**
|
|
76
|
+
* Create an upload session for a profile picture.
|
|
77
|
+
*
|
|
78
|
+
* This is the first step in the profile picture upload process.
|
|
79
|
+
*
|
|
80
|
+
* @param fileLength Length of the file to be uploaded in bytes.
|
|
81
|
+
* @param fileType MIME type of the file (e.g., 'image/jpeg').
|
|
82
|
+
* @param fileName Name of the file with extension.
|
|
83
|
+
* @returns Response containing the upload session ID needed for the next step.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // Create upload session for profile picture
|
|
87
|
+
* const session = await whatsappClient.businessProfile.createUploadSession(
|
|
88
|
+
* fileBuffer.length,
|
|
89
|
+
* 'image/jpeg',
|
|
90
|
+
* 'profile.jpg'
|
|
91
|
+
* );
|
|
92
|
+
* const uploadSessionId = session.upload_session_id;
|
|
93
|
+
*/
|
|
94
|
+
createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Upload media file to the upload session.
|
|
97
|
+
*
|
|
98
|
+
* This is the second step in the profile picture upload process.
|
|
99
|
+
* Upload the binary content of the file to the previously created upload session.
|
|
100
|
+
*
|
|
101
|
+
* @param uploadId The upload session ID from createUploadSession response.
|
|
102
|
+
* @param file The binary data of the file (Buffer).
|
|
103
|
+
* @returns Response indicating success or failure.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Upload the actual file content
|
|
107
|
+
* await whatsappClient.businessProfile.uploadMedia(
|
|
108
|
+
* uploadSessionId,
|
|
109
|
+
* fileBuffer
|
|
110
|
+
* );
|
|
111
|
+
*/
|
|
112
|
+
uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Get the upload handle information.
|
|
115
|
+
*
|
|
116
|
+
* This is the third step in the profile picture upload process.
|
|
117
|
+
* After uploading the file, get the handle to use when updating the profile.
|
|
118
|
+
*
|
|
119
|
+
* @param uploadId The upload session ID from createUploadSession response.
|
|
120
|
+
* @returns Response containing the upload handle information.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // Complete profile picture update process
|
|
124
|
+
* // 1. Create upload session
|
|
125
|
+
* const session = await whatsappClient.businessProfile.createUploadSession(
|
|
126
|
+
* fileBuffer.length, 'image/jpeg', 'profile.jpg'
|
|
127
|
+
* );
|
|
128
|
+
*
|
|
129
|
+
* // 2. Upload the image data
|
|
130
|
+
* await whatsappClient.businessProfile.uploadMedia(
|
|
131
|
+
* session.upload_session_id, fileBuffer
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* // 3. Get the handle for the uploaded file
|
|
135
|
+
* const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
|
|
136
|
+
* session.upload_session_id
|
|
137
|
+
* );
|
|
138
|
+
*
|
|
139
|
+
* // 4. Update profile with new picture and business information
|
|
140
|
+
* await whatsappClient.businessProfile.updateBusinessProfile({
|
|
141
|
+
* messaging_product: 'whatsapp',
|
|
142
|
+
* profile_picture_handle: handleInfo.handle,
|
|
143
|
+
* vertical: BusinessVerticalEnum.RESTAURANT,
|
|
144
|
+
* about: 'Delicious food served daily'
|
|
145
|
+
* });
|
|
146
|
+
*/
|
|
147
|
+
getUploadHandle(uploadId: string): Promise<UploadHandle>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
|
|
151
|
+
private readonly endpoint;
|
|
152
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
153
|
+
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
154
|
+
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare class FlowAPI extends BaseAPI implements FlowClass {
|
|
158
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
159
|
+
/**
|
|
160
|
+
* List Flows
|
|
161
|
+
*
|
|
162
|
+
* @param wabaId - The WABA ID
|
|
163
|
+
* @returns Promise with the list of flows
|
|
164
|
+
*/
|
|
165
|
+
listFlows(wabaId: string): Promise<FlowsListResponse>;
|
|
166
|
+
/**
|
|
167
|
+
* Create Flow
|
|
168
|
+
*
|
|
169
|
+
* @param wabaId - The WABA ID
|
|
170
|
+
* @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
|
|
171
|
+
* @returns Promise with the created flow ID and validation errors if any
|
|
172
|
+
*/
|
|
173
|
+
createFlow(wabaId: string, data: {
|
|
174
|
+
name: string;
|
|
175
|
+
categories?: FlowCategoryEnum[];
|
|
176
|
+
endpoint_uri?: string;
|
|
177
|
+
clone_flow_id?: string;
|
|
178
|
+
flow_json?: string;
|
|
179
|
+
publish?: boolean;
|
|
180
|
+
}): Promise<CreateFlowResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Get Flow details
|
|
183
|
+
*
|
|
184
|
+
* @param flowId - The flow ID
|
|
185
|
+
* @param fields - Optional fields to return (e.g., 'name,status,preview.invalidate(false)')
|
|
186
|
+
* @param dateFormat - Optional date format
|
|
187
|
+
* @returns Promise with the flow details or preview response
|
|
188
|
+
*/
|
|
189
|
+
getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
|
|
190
|
+
/**
|
|
191
|
+
* Get Flow Preview URL
|
|
192
|
+
*
|
|
193
|
+
* @param flowId - The flow ID
|
|
194
|
+
* @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.
|
|
195
|
+
* @returns Promise with the flow preview details
|
|
196
|
+
*/
|
|
197
|
+
getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
|
|
198
|
+
/**
|
|
199
|
+
* Update Flow Metadata
|
|
200
|
+
*
|
|
201
|
+
* @param flowId - The flow ID
|
|
202
|
+
* @param data - The flow metadata to update (name, categories, endpoint_uri, application_id)
|
|
203
|
+
* @returns Promise with the success status
|
|
204
|
+
*/
|
|
205
|
+
updateFlowMetadata(flowId: string, data: {
|
|
206
|
+
name?: string;
|
|
207
|
+
categories?: FlowCategoryEnum[];
|
|
208
|
+
endpoint_uri?: string;
|
|
209
|
+
application_id?: string;
|
|
210
|
+
}): Promise<ResponseSuccess>;
|
|
211
|
+
/**
|
|
212
|
+
* Delete Flow (only works if the Flow is in DRAFT status)
|
|
213
|
+
*
|
|
214
|
+
* @param flowId - The flow ID
|
|
215
|
+
* @returns Promise with the success status
|
|
216
|
+
*/
|
|
217
|
+
deleteFlow(flowId: string): Promise<ResponseSuccess>;
|
|
218
|
+
/**
|
|
219
|
+
* List Assets (e.g., get Flow JSON download URL)
|
|
220
|
+
*
|
|
221
|
+
* @param flowId - The flow ID
|
|
222
|
+
* @returns Promise with the list of assets
|
|
223
|
+
*/
|
|
224
|
+
listAssets(flowId: string): Promise<FlowAssetsResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Update Flow JSON by uploading a file, buffer, JSON object, or Blob.
|
|
227
|
+
*
|
|
228
|
+
* @param flowId - The flow ID
|
|
229
|
+
* @param data - Object containing the file data and optional name.
|
|
230
|
+
* @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.
|
|
231
|
+
* @param data.name - Optional name for the asset, defaults to 'flow.json'.
|
|
232
|
+
* @returns Promise with the success status and validation errors, if any.
|
|
233
|
+
*/
|
|
234
|
+
updateFlowJson(flowId: string, data: {
|
|
235
|
+
file: Blob | Buffer | object;
|
|
236
|
+
name?: string;
|
|
237
|
+
}): Promise<UpdateFlowResponse>;
|
|
238
|
+
/**
|
|
239
|
+
* Validate Flow JSON by attempting an update without publishing.
|
|
240
|
+
* This is a convenience method; the API doesn't have a dedicated validation endpoint.
|
|
241
|
+
*
|
|
242
|
+
* @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
|
|
243
|
+
* @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob.
|
|
244
|
+
* @returns Promise indicating if the JSON is valid and includes validation errors if any.
|
|
245
|
+
*/
|
|
246
|
+
validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
|
|
247
|
+
/**
|
|
248
|
+
* Publish Flow
|
|
249
|
+
*
|
|
250
|
+
* @param flowId - The flow ID
|
|
251
|
+
* @returns Promise with the success status
|
|
252
|
+
*/
|
|
253
|
+
publishFlow(flowId: string): Promise<ResponseSuccess>;
|
|
254
|
+
/**
|
|
255
|
+
* Deprecate Flow
|
|
256
|
+
*
|
|
257
|
+
* @param flowId - The flow ID
|
|
258
|
+
* @returns Promise with the success status
|
|
259
|
+
*/
|
|
260
|
+
deprecateFlow(flowId: string): Promise<ResponseSuccess>;
|
|
261
|
+
/**
|
|
262
|
+
* Migrate Flows between WABAs
|
|
263
|
+
*
|
|
264
|
+
* @param destinationWabaId - The destination WABA ID
|
|
265
|
+
* @param data - The migration data including source_waba_id and optional source_flow_names
|
|
266
|
+
* @returns Promise with migration results (successes and failures)
|
|
267
|
+
*/
|
|
268
|
+
migrateFlows(destinationWabaId: string, data: {
|
|
269
|
+
source_waba_id: string;
|
|
270
|
+
source_flow_names?: string[];
|
|
271
|
+
}): Promise<FlowMigrationResponse>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare class MediaAPI extends BaseAPI implements MediaClass {
|
|
275
|
+
private readonly endpoint;
|
|
276
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
277
|
+
getMediaById(mediaId: string): Promise<MediaResponse>;
|
|
278
|
+
uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
|
|
279
|
+
deleteMedia(mediaId: string): Promise<ResponseSuccess>;
|
|
280
|
+
downloadMedia(mediaUrl: string): Promise<Blob>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Maps each message type to its appropriate payload type
|
|
285
|
+
*/
|
|
286
|
+
type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
|
|
287
|
+
message_id: string;
|
|
288
|
+
emoji: string;
|
|
289
|
+
} : never;
|
|
290
|
+
declare class MessagesApi extends BaseAPI implements MessagesClass {
|
|
291
|
+
private readonly commonMethod;
|
|
292
|
+
private readonly commonEndpoint;
|
|
293
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
294
|
+
/**
|
|
295
|
+
* Builds the request body for WhatsApp API messages
|
|
296
|
+
* @param type The type of message to send
|
|
297
|
+
* @param payload The message payload object
|
|
298
|
+
* @param to The recipient's phone number
|
|
299
|
+
* @param replyMessageId Optional message ID to reply to
|
|
300
|
+
* @returns The formatted request body
|
|
301
|
+
*/
|
|
302
|
+
bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
|
|
303
|
+
/**
|
|
304
|
+
* Sends a request to the WhatsApp API
|
|
305
|
+
* @param body The request body to send
|
|
306
|
+
* @returns Promise with the API response
|
|
307
|
+
*/
|
|
308
|
+
private send;
|
|
309
|
+
/**
|
|
310
|
+
* Sends an audio message via WhatsApp
|
|
311
|
+
* @param params The audio message parameter object
|
|
312
|
+
* @returns Promise with the message response
|
|
313
|
+
*/
|
|
314
|
+
audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
|
|
315
|
+
/**
|
|
316
|
+
* Sends a contact card via WhatsApp
|
|
317
|
+
* @param params The contact message parameter object
|
|
318
|
+
* @returns Promise with the message response
|
|
319
|
+
*/
|
|
320
|
+
contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
|
|
321
|
+
/**
|
|
322
|
+
* Sends a document via WhatsApp
|
|
323
|
+
* @param params The document message parameter object
|
|
324
|
+
* @returns Promise with the message response
|
|
325
|
+
*/
|
|
326
|
+
document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
|
|
327
|
+
/**
|
|
328
|
+
* Sends an image via WhatsApp
|
|
329
|
+
* @param params The image message parameter object
|
|
330
|
+
* @returns Promise with the message response
|
|
331
|
+
*/
|
|
332
|
+
image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
|
|
333
|
+
/**
|
|
334
|
+
* Sends an interactive message via WhatsApp
|
|
335
|
+
* @param params The interactive message parameter object
|
|
336
|
+
* @returns Promise with the message response
|
|
337
|
+
*/
|
|
338
|
+
interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
|
|
339
|
+
/**
|
|
340
|
+
* Sends a location via WhatsApp
|
|
341
|
+
* @param params The location message parameter object
|
|
342
|
+
* @returns Promise with the message response
|
|
343
|
+
*/
|
|
344
|
+
location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
|
|
345
|
+
/**
|
|
346
|
+
* Sends a sticker via WhatsApp
|
|
347
|
+
* @param params The sticker message parameter object
|
|
348
|
+
* @returns Promise with the message response
|
|
349
|
+
*/
|
|
350
|
+
sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
|
|
351
|
+
/**
|
|
352
|
+
* Sends a template message via WhatsApp
|
|
353
|
+
* @param params The template message parameter object
|
|
354
|
+
* @returns Promise with the message response
|
|
355
|
+
*/
|
|
356
|
+
template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
|
|
357
|
+
/**
|
|
358
|
+
* Sends a text message via WhatsApp
|
|
359
|
+
* @param params The text message parameter object
|
|
360
|
+
* @returns Promise with the message response
|
|
361
|
+
*/
|
|
362
|
+
text(params: TextMessageParams): Promise<MessagesResponse>;
|
|
363
|
+
/**
|
|
364
|
+
* Sends a video via WhatsApp
|
|
365
|
+
* @param params The video message parameter object
|
|
366
|
+
* @returns Promise with the message response
|
|
367
|
+
*/
|
|
368
|
+
video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
|
|
369
|
+
/**
|
|
370
|
+
* Updates message status (used for read receipts and typing indicators)
|
|
371
|
+
* @param params The status update parameter object
|
|
372
|
+
* @returns Promise with the response
|
|
373
|
+
*/
|
|
374
|
+
status(params: StatusParams): Promise<MessagesResponse>;
|
|
375
|
+
/**
|
|
376
|
+
* Marks a message as read in WhatsApp
|
|
377
|
+
* @param params The parameter object to mark message as read
|
|
378
|
+
* @returns Promise with the response
|
|
379
|
+
*/
|
|
380
|
+
markAsRead(params: {
|
|
381
|
+
messageId: string;
|
|
382
|
+
}): Promise<MessagesResponse>;
|
|
383
|
+
/**
|
|
384
|
+
* Marks a message as read and shows a typing indicator in WhatsApp
|
|
385
|
+
* @param params The typing indicator parameter object
|
|
386
|
+
* @returns Promise with the response
|
|
387
|
+
*/
|
|
388
|
+
showTypingIndicator(params: {
|
|
389
|
+
messageId: string;
|
|
390
|
+
}): Promise<MessagesResponse>;
|
|
391
|
+
/**
|
|
392
|
+
* Sends an interactive list message
|
|
393
|
+
* @param params The list message parameter object
|
|
394
|
+
* @returns Promise with the response
|
|
395
|
+
*/
|
|
396
|
+
interactiveList(params: MessageRequestParams<InteractiveObject & {
|
|
397
|
+
type: InteractiveTypesEnum.List;
|
|
398
|
+
}>): Promise<MessagesResponse>;
|
|
399
|
+
/**
|
|
400
|
+
* Sends an interactive CTA URL message
|
|
401
|
+
* @param params The CTA URL message parameter object
|
|
402
|
+
* @returns Promise with the response
|
|
403
|
+
*/
|
|
404
|
+
interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
|
|
405
|
+
type: InteractiveTypesEnum.CtaUrl;
|
|
406
|
+
}>): Promise<MessagesResponse>;
|
|
407
|
+
/**
|
|
408
|
+
* Sends a location request message
|
|
409
|
+
* @param params The location request message parameter object
|
|
410
|
+
* @returns Promise with the response
|
|
411
|
+
*/
|
|
412
|
+
interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
|
|
413
|
+
type: InteractiveTypesEnum.LocationRequest;
|
|
414
|
+
}>): Promise<MessagesResponse>;
|
|
415
|
+
/**
|
|
416
|
+
* Sends an address message to request shipping address from the user
|
|
417
|
+
* Note: This feature is only available for businesses based in India and their India customers
|
|
418
|
+
* @param params The address message parameter object
|
|
419
|
+
* @returns Promise with the response
|
|
420
|
+
*/
|
|
421
|
+
interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
|
|
422
|
+
type: InteractiveTypesEnum.AddressMessage;
|
|
423
|
+
}>): Promise<MessagesResponse>;
|
|
424
|
+
/**
|
|
425
|
+
* Sends an interactive reply buttons message
|
|
426
|
+
* @param params The reply buttons message parameter object
|
|
427
|
+
* @returns Promise with the response
|
|
428
|
+
*/
|
|
429
|
+
interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
|
|
430
|
+
type: InteractiveTypesEnum.Button;
|
|
431
|
+
}>): Promise<MessagesResponse>;
|
|
432
|
+
/**
|
|
433
|
+
* Sends an interactive Flow message
|
|
434
|
+
* @param params The Flow message parameter object
|
|
435
|
+
* @returns Promise with the response
|
|
436
|
+
*/
|
|
437
|
+
interactiveFlow(params: MessageRequestParams<InteractiveObject & {
|
|
438
|
+
type: InteractiveTypesEnum.Flow;
|
|
439
|
+
}>): Promise<MessagesResponse>;
|
|
440
|
+
/**
|
|
441
|
+
* Sends a reaction to a message (emoji response)
|
|
442
|
+
* @param params The reaction message parameter object
|
|
443
|
+
* @returns Promise with the response
|
|
444
|
+
*/
|
|
445
|
+
reaction(params: ReactionParams): Promise<MessagesResponse>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
|
|
449
|
+
private readonly endpoint;
|
|
450
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
451
|
+
getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>;
|
|
452
|
+
getPhoneNumbers(): Promise<PhoneNumbersResponse>;
|
|
453
|
+
requestVerificationCode(requestVerificationCodeRequest: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
|
|
454
|
+
verifyCode(verifyCodeRequest: VerifyCodeRequest): Promise<ResponseSuccess>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
declare class QrCodeAPI extends BaseAPI implements QrCodeClass {
|
|
458
|
+
private readonly endpoint;
|
|
459
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
460
|
+
createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
|
|
461
|
+
getQrCodes(): Promise<QrCodesResponse>;
|
|
462
|
+
getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
|
|
463
|
+
updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
|
|
464
|
+
deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
declare class RegistrationAPI extends BaseAPI implements RegistrationClass {
|
|
468
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
469
|
+
register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
|
|
470
|
+
deregister(): Promise<ResponseSuccess>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
declare class TemplateApi extends BaseAPI implements TemplateClass {
|
|
474
|
+
private readonly endpoint;
|
|
475
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
476
|
+
getTemplate(templateId: string): Promise<TemplateResponse>;
|
|
477
|
+
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
|
|
478
|
+
getTemplates(params: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
|
|
479
|
+
createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
|
|
480
|
+
deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class TwoStepVerificationAPI extends BaseAPI implements TwoStepVerificationClass {
|
|
484
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
485
|
+
setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
declare class WabaAPI extends BaseAPI implements WABAClass {
|
|
489
|
+
constructor(config: WabaConfigType, client: RequesterClass);
|
|
490
|
+
getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
|
|
491
|
+
getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
|
|
492
|
+
updateWabaSubscription({ override_callback_uri, verify_token, }: UpdateWabaSubscription): Promise<ResponseSuccess>;
|
|
493
|
+
unsubscribeFromWaba(): Promise<ResponseSuccess>;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export { BaseAPI, BusinessProfileAPI, EncryptionAPI, FlowAPI, MediaAPI, MessagesApi as MessagesAPI, PhoneNumberApi as PhoneNumberAPI, QrCodeAPI, RegistrationAPI, TemplateApi as TemplateAPI, TwoStepVerificationAPI, WabaAPI };
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var O="BaseAPI",_=!1,D=new n(O,process.env.DEBUG==="true"||_),o=class{config;client;constructor(t,e){this.config=t,this.client=e,D.log("Initialized with HTTPSClient")}sendJson(t,e,s,i){return this.client.getJson(t,e,s,i)}sendFormData(t,e,s,i){return this.client.sendFormData(t,e,s,i)}sendUrlEncodedForm(t,e,s,i){return this.client.sendUrlEncodedForm(t,e,s,i)}};function f(a){if(!a)return"";let t="";return Array.isArray(a)?t=a.join(","):t=Object.entries(a).filter(([e,s])=>s).map(([e])=>e).join(","),t?`?fields=${t}`:""}var R=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[s,i]of Object.entries(a))i!==void 0&&t.append(s,String(i));let e=t.toString();return e?`?${e}`:""};var P=class extends o{endpoint="whatsapp_business_profile";constructor(t,e){super(t,e)}async getBusinessProfile(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${f(t)}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,e,s){let i=R({file_length:t,file_type:e,file_name:s});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,e)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var h=class extends o{endpoint="whatsapp_business_encryption";constructor(t,e){super(t,e)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let e=new FormData;return e.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,e)}};var m="FlowAPI",U=!1,B=new n(m,process.env.DEBUG==="true"||U),c=class extends o{constructor(t,e){super(t,e),B.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,e){let s={name:e.name,categories:e.categories,...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.clone_flow_id&&{clone_flow_id:e.clone_flow_id},...e.flow_json&&{flow_json:e.flow_json},...e.publish!==void 0&&{publish:e.publish}};return this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getFlow(t,e,s){let i=new URLSearchParams;e&&i.append("fields",e),s&&i.append("date_format",s);let p=i.toString()?`?${i.toString()}`:"";return this.sendJson("GET",`/${t}${p}`,this.config.REQUEST_TIMEOUT,null)}async getFlowPreview(t,e=!1){let s=`preview.invalidate(${e})`;return this.getFlow(t,s)}async updateFlowMetadata(t,e){let s={...e.name&&{name:e.name},...e.categories&&{categories:e.categories},...e.endpoint_uri&&{endpoint_uri:e.endpoint_uri},...e.application_id&&{application_id:e.application_id}};return this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,e){let s=new FormData,i;if(e.file instanceof Buffer)i=new globalThis.Blob([e.file]),s.append("file",i);else if(typeof e.file=="object"&&!(e.file instanceof Blob))try{i=new globalThis.Blob([JSON.stringify(e.file,null,2)],{type:"application/json"}),s.append("file",i)}catch{throw new Error("Failed to stringify JSON object for Flow JSON update.")}else if(e.file instanceof Blob)i=e.file,s.append("file",i);else throw new Error("Invalid file type provided for Flow JSON update. Must be a Buffer, JSON object, or Blob.");return s.append("asset_type","FLOW_JSON"),s.append("name",e.name||"flow.json"),this.sendFormData("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,s)}async validateFlowJson(t,e){try{let s=await this.updateFlowJson(t,{file:e}),i=!s.validation_errors||s.validation_errors.length===0;return{...s,valid:i}}catch(s){throw B.error("Error during Flow JSON validation attempt:",s),s}}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,e){let s={source_waba_id:e.source_waba_id,...e.source_flow_names&&{source_flow_names:e.source_flow_names}};return this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var g=class extends o{endpoint="media";constructor(t,e){super(t,e)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,e="whatsapp"){let s=new FormData;return s.append("file",t),s.append("messaging_product",e),s.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var S=class extends o{commonMethod="POST";commonEndpoint="messages";constructor(t,e){super(t,e)}bodyBuilder(t,e,s,i){let p={messaging_product:"whatsapp",recipient_type:"individual",to:s,type:t,[t]:e};return i&&(p.context={message_id:i}),p}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",e,s,i)))}async contacts(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",e,s,i)))}async document(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("document",e,s,i)))}async image(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("image",e,s,i)))}async interactive(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async location(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("location",e,s,i)))}async sticker(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",e,s,i)))}async template(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("template",e,s,i)))}async text(t){let{body:e,previewUrl:s,to:i,replyMessageId:p}=t,M;return typeof e=="string"?M={body:e,preview_url:s}:M=e,this.send(JSON.stringify(this.bodyBuilder("text",M,i,p)))}async video(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("video",e,s,i)))}async status(t){let{status:e,messageId:s,typingIndicator:i}=t,p={messaging_product:"whatsapp",status:e,message_id:s,...i&&{typing_indicator:i}};return this.send(JSON.stringify(p))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveCtaUrl(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveLocationRequest(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveAddressMessage(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveReplyButtons(t){let{body:e,to:s,replyMessageId:i}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async interactiveFlow(t){let{body:e,to:s,replyMessageId:i}=t;return e.action.parameters.flow_message_version===void 0&&(e.action.parameters.flow_message_version="3"),e.action.parameters.mode===void 0&&(e.action.parameters.mode="published"),e.action.parameters.flow_action===void 0&&(e.action.parameters.flow_action="navigate"),e.action.parameters.flow_action==="navigate"?e.action.parameters.flow_action_payload?.screen===void 0&&(e.action.parameters.flow_action_payload={...e.action.parameters.flow_action_payload,screen:"INIT"}):e.action.parameters.flow_action==="data_exchange"&&delete e.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",e,s,i)))}async reaction(t){let{messageId:e,emoji:s,to:i}=t,p={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:"reaction",reaction:{message_id:e,emoji:s}};return this.send(JSON.stringify(p))}};var T=class extends o{endpoint="phone_numbers";constructor(t,e){super(t,e)}async getPhoneNumberById(t){let e=t?R({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var d=class extends o{endpoint="message_qrdls";constructor(t,e){super(t,e)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var A=class extends o{constructor(t,e){super(t,e)}async register(t,e){let s={messaging_product:"whatsapp",pin:t,...e&&{data_localization_region:e}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends o{endpoint="message_templates";constructor(t,e){super(t,e)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,e){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${R(t)}`,this.config.REQUEST_TIMEOUT,null)}};var I=class extends o{constructor(t,e){super(t,e)}async setTwoStepVerificationCode(t){let e={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(e))}};var N=class extends o{constructor(t,e){super(t,e)}async getWabaAccount(t){let e=f(t)?.replace(/,/g,"%2C");return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}${e}`,this.config.REQUEST_TIMEOUT,null)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:e}){let s={override_callback_uri:t,verify_token:e};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};export{o as BaseAPI,P as BusinessProfileAPI,h as EncryptionAPI,c as FlowAPI,g as MediaAPI,S as MessagesAPI,T as PhoneNumberAPI,d as QrCodeAPI,A as RegistrationAPI,b as TemplateAPI,I as TwoStepVerificationAPI,N as WabaAPI};
|
|
1
|
+
export{a as BaseAPI,b as BusinessProfileAPI,c as EncryptionAPI,d as FlowAPI,e as MediaAPI,f as MessagesAPI,g as PhoneNumberAPI,h as QrCodeAPI,i as RegistrationAPI,j as TemplateAPI,k as TwoStepVerificationAPI,l as WabaAPI}from'../chunk-R4CFE2XP.mjs';import'../chunk-QE4PKOSW.mjs';import'../chunk-XVYL7ZTG.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|