meta-cloud-api 1.1.3 → 1.1.4
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/dist/WebhookProcessor-BUZFeZD_.js +3 -0
- package/dist/WebhookProcessor-BUZFeZD_.js.map +1 -0
- package/dist/WebhookProcessor-Dq2Pa2cY.d.ts +718 -0
- package/dist/WebhookProcessor-Dq2Pa2cY.d.ts.map +1 -0
- package/dist/api/encryption/index.d.ts +3 -10
- package/dist/api/encryption/index.js +1 -2
- package/dist/api/flow/index.d.ts +5 -11
- package/dist/api/flow/index.js +1 -2
- package/dist/api/index.d.ts +17 -18
- package/dist/api/index.js +1 -2
- package/dist/api/media/index.d.ts +3 -10
- package/dist/api/media/index.js +1 -2
- package/dist/api/messages/builders/index.d.ts +442 -439
- package/dist/api/messages/builders/index.d.ts.map +1 -0
- package/dist/api/messages/builders/index.js +1 -3
- package/dist/api/messages/builders/index.js.map +1 -1
- package/dist/api/messages/index.d.ts +4 -10
- package/dist/api/messages/index.js +1 -2
- package/dist/api/phone/index.d.ts +3 -10
- package/dist/api/phone/index.js +1 -2
- package/dist/api/profile/index.d.ts +3 -10
- package/dist/api/profile/index.js +1 -2
- package/dist/api/qrCode/index.d.ts +3 -10
- package/dist/api/qrCode/index.js +1 -2
- package/dist/api/registration/index.d.ts +3 -10
- package/dist/api/registration/index.js +1 -2
- package/dist/api/template/index.d.ts +3 -21
- package/dist/api/template/index.js +1 -2
- package/dist/api/twoStepVerification/index.d.ts +3 -10
- package/dist/api/twoStepVerification/index.js +1 -2
- package/dist/api/waba/index.d.ts +3 -10
- package/dist/api/waba/index.js +1 -2
- package/dist/api-8hRAOyaL.js +1 -0
- package/dist/base-CfDkvT1x.d.ts +807 -0
- package/dist/base-CfDkvT1x.d.ts.map +1 -0
- package/dist/base-D-cXu_lA.js +2 -0
- package/dist/base-D-cXu_lA.js.map +1 -0
- package/dist/buildFieldsQueryString-Cr-jz3p0.js +2 -0
- package/dist/buildFieldsQueryString-Cr-jz3p0.js.map +1 -0
- package/dist/chunk-CTAAG5j7.js +1 -0
- package/dist/common-C6FXBDm7.js +2 -0
- package/dist/common-C6FXBDm7.js.map +1 -0
- package/dist/common-CVbsmD26.d.ts +426 -0
- package/dist/common-CVbsmD26.d.ts.map +1 -0
- package/dist/common-CvPVD1o6.d.ts +406 -0
- package/dist/common-CvPVD1o6.d.ts.map +1 -0
- package/dist/core/webhook/frameworks/express.d.ts +20 -53
- package/dist/core/webhook/frameworks/express.js +1 -2
- package/dist/core/webhook/frameworks/nextjs-app.d.ts +36 -39
- package/dist/core/webhook/frameworks/nextjs-app.d.ts.map +1 -0
- package/dist/core/webhook/frameworks/nextjs-app.js +1 -1
- package/dist/core/webhook/frameworks/nextjs-app.js.map +1 -1
- package/dist/core/webhook/frameworks/nextjs.d.ts +20 -49
- package/dist/core/webhook/frameworks/nextjs.js +1 -2
- package/dist/core/webhook/index.d.ts +20 -29
- package/dist/core/webhook/index.js +1 -2
- package/dist/core/whatsapp/index.d.ts +18 -42
- package/dist/core/whatsapp/index.js +1 -2
- package/dist/encryption-Cwc0xcVL.js +2 -0
- package/dist/encryption-Cwc0xcVL.js.map +1 -0
- package/dist/enums-CSUpFXb8.js +2 -0
- package/dist/enums-CSUpFXb8.js.map +1 -0
- package/dist/express-B6fQdflY.d.ts +78 -0
- package/dist/express-B6fQdflY.d.ts.map +1 -0
- package/dist/express-CrfNLYMM.js +2 -0
- package/dist/express-CrfNLYMM.js.map +1 -0
- package/dist/flow-CVes0Qus.js +2 -0
- package/dist/flow-CVes0Qus.js.map +1 -0
- package/dist/flowTypeGuards-Gn3-slCW.js +2 -0
- package/dist/flowTypeGuards-Gn3-slCW.js.map +1 -0
- package/dist/handler-BGqjZ0xg.js +2 -0
- package/dist/handler-BGqjZ0xg.js.map +1 -0
- package/dist/index-3KglHVAg.d.ts +354 -0
- package/dist/index-3KglHVAg.d.ts.map +1 -0
- package/dist/index-BNeg6hHx.d.ts +99 -0
- package/dist/index-BNeg6hHx.d.ts.map +1 -0
- package/dist/index-BiTq23oi.d.ts +34 -0
- package/dist/index-BiTq23oi.d.ts.map +1 -0
- package/dist/index-BmfnREgM.d.ts +47 -0
- package/dist/index-BmfnREgM.d.ts.map +1 -0
- package/dist/index-CaGffSja.d.ts +24 -0
- package/dist/index-CaGffSja.d.ts.map +1 -0
- package/dist/index-CeTmbIXi.d.ts +180 -0
- package/dist/index-CeTmbIXi.d.ts.map +1 -0
- package/dist/index-CoyByMuM.d.ts +137 -0
- package/dist/index-CoyByMuM.d.ts.map +1 -0
- package/dist/index-CwujtcvH.d.ts +370 -0
- package/dist/index-CwujtcvH.d.ts.map +1 -0
- package/dist/index-DQ7z58xp.d.ts +104 -0
- package/dist/index-DQ7z58xp.d.ts.map +1 -0
- package/dist/index-DQkgkiB6.d.ts +30 -0
- package/dist/index-DQkgkiB6.d.ts.map +1 -0
- package/dist/index-LKrIp3Oo.d.ts +1 -0
- package/dist/index-_-06JPan.d.ts +143 -0
- package/dist/index-_-06JPan.d.ts.map +1 -0
- package/dist/index-a_YS40Iv.d.ts +91 -0
- package/dist/index-a_YS40Iv.d.ts.map +1 -0
- package/dist/index-d7TLqtYh.d.ts +171 -0
- package/dist/index-d7TLqtYh.d.ts.map +1 -0
- package/dist/index.d.ts +21 -27
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{isMetaError-CQLXyEL4.d.ts → isMetaError-B3AglYeY.d.ts} +28 -25
- package/dist/isMetaError-B3AglYeY.d.ts.map +1 -0
- package/dist/media-Dw5OGzDD.js +2 -0
- package/dist/media-Dw5OGzDD.js.map +1 -0
- package/dist/messages-h5-NW8QO.js +2 -0
- package/dist/messages-h5-NW8QO.js.map +1 -0
- package/dist/nextjs-DxRCL4t3.js +2 -0
- package/dist/nextjs-DxRCL4t3.js.map +1 -0
- package/dist/objectToQueryString-CAHI0qTs.js +2 -0
- package/dist/objectToQueryString-CAHI0qTs.js.map +1 -0
- package/dist/phone-CZyWLyWB.js +2 -0
- package/dist/phone-CZyWLyWB.js.map +1 -0
- package/dist/profile-Bb7GDP0n.js +2 -0
- package/dist/profile-Bb7GDP0n.js.map +1 -0
- package/dist/qrCode-CeZEtX9J.js +2 -0
- package/dist/qrCode-CeZEtX9J.js.map +1 -0
- package/dist/registration-BkjhC3xw.js +2 -0
- package/dist/registration-BkjhC3xw.js.map +1 -0
- package/dist/template-Bgy-BCXJ.js +2 -0
- package/dist/template-Bgy-BCXJ.js.map +1 -0
- package/dist/twoStepVerification-DYlYF_P5.js +2 -0
- package/dist/twoStepVerification-DYlYF_P5.js.map +1 -0
- package/dist/types/index.d.ts +3 -6
- package/dist/types/index.js +1 -2
- package/dist/utils/index.d.ts +23 -20
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1 -2
- package/dist/version-BUuqrHc6.js +3 -0
- package/dist/version-BUuqrHc6.js.map +1 -0
- package/dist/waba-SF2W3z2U.js +2 -0
- package/dist/waba-SF2W3z2U.js.map +1 -0
- package/dist/webhook-D4DQ01Xq.js +2 -0
- package/dist/webhook-D4DQ01Xq.js.map +1 -0
- package/dist/whatsapp-B85mxH5f.js +10 -0
- package/dist/whatsapp-B85mxH5f.js.map +1 -0
- package/package.json +27 -125
- package/dist/BusinessProfileApi-C_sEOrWM.d.ts +0 -353
- package/dist/EncryptionApi-CcCfeK2b.d.ts +0 -22
- package/dist/FlowApi-DDHrFT_Q.d.ts +0 -136
- package/dist/MediaApi-CY9RVo7u.d.ts +0 -90
- package/dist/MessageApi-CX_jN8da.d.ts +0 -171
- package/dist/PhoneNumberApi-B-hY7g1M.d.ts +0 -142
- package/dist/QrCodeApi-DRICKN04.d.ts +0 -98
- package/dist/RegistrationApi-CFPzU1Vw.d.ts +0 -47
- package/dist/TemplateApi-fCIlzBtK.d.ts +0 -161
- package/dist/TwoStepVerificationApi-C0jpAKfu.d.ts +0 -33
- package/dist/WabaApi-x5PhsLT3.d.ts +0 -175
- package/dist/WebhookProcessor-DEIZ2PRU.d.ts +0 -707
- package/dist/WhatsApp-BFsBgjJO.d.ts +0 -82
- package/dist/api/encryption/index.js.map +0 -1
- package/dist/api/flow/index.js.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/media/index.js.map +0 -1
- package/dist/api/messages/index.js.map +0 -1
- package/dist/api/phone/index.js.map +0 -1
- package/dist/api/profile/index.js.map +0 -1
- package/dist/api/qrCode/index.js.map +0 -1
- package/dist/api/registration/index.js.map +0 -1
- package/dist/api/template/index.js.map +0 -1
- package/dist/api/twoStepVerification/index.js.map +0 -1
- package/dist/api/waba/index.js.map +0 -1
- package/dist/base-BV6DyzGS.d.ts +0 -18
- package/dist/chunk-5577QQ7V.js +0 -2
- package/dist/chunk-5577QQ7V.js.map +0 -1
- package/dist/chunk-6DFC5L3X.js +0 -2
- package/dist/chunk-6DFC5L3X.js.map +0 -1
- package/dist/chunk-7QBIZCJ4.js +0 -2
- package/dist/chunk-7QBIZCJ4.js.map +0 -1
- package/dist/chunk-AMHQGG6Z.js +0 -2
- package/dist/chunk-AMHQGG6Z.js.map +0 -1
- package/dist/chunk-BAOZ4U74.js +0 -10
- package/dist/chunk-BAOZ4U74.js.map +0 -1
- package/dist/chunk-CRZ7EUYR.js +0 -2
- package/dist/chunk-CRZ7EUYR.js.map +0 -1
- package/dist/chunk-FKXSL2JK.js +0 -3
- package/dist/chunk-FKXSL2JK.js.map +0 -1
- package/dist/chunk-FSKBLPGE.js +0 -2
- package/dist/chunk-FSKBLPGE.js.map +0 -1
- package/dist/chunk-GM63NGNV.js +0 -2
- package/dist/chunk-GM63NGNV.js.map +0 -1
- package/dist/chunk-IYSR44P6.js +0 -2
- package/dist/chunk-IYSR44P6.js.map +0 -1
- package/dist/chunk-J2JPTKU6.js +0 -2
- package/dist/chunk-J2JPTKU6.js.map +0 -1
- package/dist/chunk-JC6YMVID.js +0 -2
- package/dist/chunk-JC6YMVID.js.map +0 -1
- package/dist/chunk-JPAV644F.js +0 -2
- package/dist/chunk-JPAV644F.js.map +0 -1
- package/dist/chunk-JXCLRKQ7.js +0 -2
- package/dist/chunk-JXCLRKQ7.js.map +0 -1
- package/dist/chunk-KMAH6636.js +0 -2
- package/dist/chunk-KMAH6636.js.map +0 -1
- package/dist/chunk-L4ESAO2S.js +0 -2
- package/dist/chunk-L4ESAO2S.js.map +0 -1
- package/dist/chunk-LV3TULSI.js +0 -2
- package/dist/chunk-LV3TULSI.js.map +0 -1
- package/dist/chunk-MJEG3K4V.js +0 -2
- package/dist/chunk-MJEG3K4V.js.map +0 -1
- package/dist/chunk-PHPQ5HP3.js +0 -2
- package/dist/chunk-PHPQ5HP3.js.map +0 -1
- package/dist/chunk-RIL6QABY.js +0 -2
- package/dist/chunk-RIL6QABY.js.map +0 -1
- package/dist/chunk-RWCVPWRC.js +0 -2
- package/dist/chunk-RWCVPWRC.js.map +0 -1
- package/dist/chunk-SNNRWNGZ.js +0 -2
- package/dist/chunk-SNNRWNGZ.js.map +0 -1
- package/dist/chunk-U5FBZ6UB.js +0 -3
- package/dist/chunk-U5FBZ6UB.js.map +0 -1
- package/dist/chunk-VHAODWCN.js +0 -2
- package/dist/chunk-VHAODWCN.js.map +0 -1
- package/dist/chunk-ZMNXRMWK.js +0 -2
- package/dist/chunk-ZMNXRMWK.js.map +0 -1
- package/dist/common-B8kp4RdL.d.ts +0 -403
- package/dist/common-CGbls9Y8.d.ts +0 -425
- package/dist/core/webhook/frameworks/express.js.map +0 -1
- package/dist/core/webhook/frameworks/nextjs.js.map +0 -1
- package/dist/core/webhook/index.js.map +0 -1
- package/dist/core/whatsapp/index.js.map +0 -1
- package/dist/enums-DIimUG6s.d.ts +0 -707
- package/dist/factory-kNha6WaY.d.ts +0 -200
- package/dist/handler-DbySwF0E.d.ts +0 -20
- package/dist/httpsClient-Cbd2Y6mg.d.ts +0 -19
- package/dist/logger-BdE0Vyim.d.ts +0 -9
- package/dist/request-CUjrMn8R.d.ts +0 -50
- package/dist/types/config.d.ts +0 -78
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +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/index.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export { webhookHandler as ExpressWebhook
|
|
22
|
-
export { webhookHandler as NextJsWebhook } from './core/webhook/frameworks/nextjs.js';
|
|
23
|
-
import './httpsClient-Cbd2Y6mg.js';
|
|
24
|
-
import 'https';
|
|
25
|
-
import './base-BV6DyzGS.js';
|
|
26
|
-
import 'http';
|
|
27
|
-
import './handler-DbySwF0E.js';
|
|
1
|
+
import { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, GeneralHeaderInterface, GeneralRequestBody, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, Paging, ParametersTypesEnum, RequestCodeMethodsEnum, RequesterResponseInterface, ResponseData, ResponsePagination, ResponseSuccess, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WabaConfigType, WebhookTypesEnum, WhatsAppConfig } from "./base-CfDkvT1x.js";
|
|
2
|
+
import { EncryptionApi, EncryptionPublicKeyResponse } from "./index-CaGffSja.js";
|
|
3
|
+
import "./index-DQkgkiB6.js";
|
|
4
|
+
import { Flow, FlowActionEnum, FlowAsset, FlowAssetsResponse, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, Pagination, PaginationCursors, UpdateFlowResponse, ValidateFlowJsonResponse } from "./common-CvPVD1o6.js";
|
|
5
|
+
import { FlowApi } from "./index-CoyByMuM.js";
|
|
6
|
+
import { MediaApi, MediaClass, MediaResponse, MediasResponse, UploadMediaResponse } from "./index-a_YS40Iv.js";
|
|
7
|
+
import { AudioMediaObject, ContactObject, DocumentMediaObject, GeneralMessageBody, ImageMediaObject, InteractiveObject, LocationObject, MessageRequestBody, MessageRequestParams, MessageTemplateObject, MessagesClass, MessagesResponse, ReactionParams, StatusParams, StickerMediaObject, TextMessageParams, TextObject, VideoMediaObject } from "./common-CVbsmD26.js";
|
|
8
|
+
import { MessagesApi } from "./index-d7TLqtYh.js";
|
|
9
|
+
import { AccountMode, CodeVerificationStatus, Cursors, HealthStatus, HealthStatusEntity, MessagingLimitTier, PhoneNumberApi, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, QualityRating, QualityScore, RequestVerificationCodeRequest, Throughput, ThroughputLevel, TwoStepVerificationParams, VerifyCodeRequest } from "./index-_-06JPan.js";
|
|
10
|
+
import { BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, UpdateBusinessProfileRequest } from "./index-3KglHVAg.js";
|
|
11
|
+
import { CreateQrCodeRequest, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, UpdateQrCodeRequest } from "./index-BNeg6hHx.js";
|
|
12
|
+
import { RegistrationApi, RegistrationClass, RegistrationRequest } from "./index-BmfnREgM.js";
|
|
13
|
+
import { AuthenticationTemplateOptions, BodyOptions, ButtonOptions, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, ComponentTypes, CopyCodeButton, CouponTemplateOptions, CurrencyParameter, DateTimeParameter, FlowButton, FooterOptions, HeaderOptions, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, LocationParameter, MPMButton, MPMTemplateOptions, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaParameter, OTPButton, OTPTemplateOptions, PhoneNumberButton, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QuickReplyButton, SPMButton, SPMTemplateOptions, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TextParameter, URLButton } from "./index-CwujtcvH.js";
|
|
14
|
+
import { TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationRequest } from "./index-BiTq23oi.js";
|
|
15
|
+
import { UpdateWabaSubscription, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions } from "./index-CeTmbIXi.js";
|
|
16
|
+
import "./index-LKrIp3Oo.js";
|
|
17
|
+
import { WhatsApp } from "./index-DQ7z58xp.js";
|
|
18
|
+
import { WebhookContact, WebhookEvent, WebhookMessage } from "./WebhookProcessor-Dq2Pa2cY.js";
|
|
19
|
+
import { webhookHandler, webhookHandler$1 } from "./express-B6fQdflY.js";
|
|
20
|
+
import { MetaError, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError } from "./isMetaError-B3AglYeY.js";
|
|
21
|
+
export { type AccountMode, type AudioMediaObject, AudioMediaTypesEnum, type AuthenticationTemplateOptions, type BodyOptions, BusinessProfileApi, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, BusinessVerticalEnum, type ButtonOptions, ButtonPositionEnum, type CarouselCard, type CarouselOptions, type CatalogButton, type CatalogTemplateOptions, CategoryEnum, type CodeVerificationStatus, type ComponentTypes, ComponentTypesEnum, type ContactObject, ConversationTypesEnum, type CopyCodeButton, type CouponTemplateOptions, type CreateQrCodeRequest, CurrencyCodesEnum, type CurrencyParameter, type Cursors, DataLocalizationRegionEnum, type DateTimeParameter, type DocumentMediaObject, DocumentMediaTypesEnum, EncryptionApi, type EncryptionPublicKeyResponse, webhookHandler as ExpressWebhook, type Flow, FlowActionEnum, FlowApi, type FlowAsset, type FlowAssetsResponse, type FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type HeaderOptions, type HealthStatus, type HealthStatusEntity, HttpMethodsEnum, type ImageMediaObject, ImageMediaTypesEnum, type InteractiveObject, InteractiveTypesEnum, LanguagesEnum, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, type LocationObject, type LocationParameter, type MPMButton, type MPMTemplateOptions, MediaApi, type MediaCardCarouselTemplateOptions, type MediaCarouselCard, type MediaClass, type MediaParameter, type MediaResponse, type MediasResponse, type MessageRequestBody, type MessageRequestParams, type MessageTemplateObject, MessageTypesEnum, MessagesApi, type MessagesClass, type MessagesResponse, type MessagingLimitTier, type MetaError, webhookHandler$1 as NextJsWebhook, type OTPButton, type OTPTemplateOptions, type Pagination, type PaginationCursors, type Paging, ParametersTypesEnum, PhoneNumberApi, type PhoneNumberButton, type PhoneNumberClass, type PhoneNumberResponse, type PhoneNumbersResponse, type PlatformType, type ProductCardCarouselTemplateOptions, type ProductCarouselCard, type ProductParameter, type ProductSection, QrCodeApi, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, type QualityRating, type QualityScore, type QuickReplyButton, type ReactionParams, RegistrationApi, type RegistrationClass, type RegistrationRequest, RequestCodeMethodsEnum, type RequestVerificationCodeRequest, type RequesterResponseInterface, type ResponseData, type ResponsePagination, type ResponseSuccess, type SPMButton, type SPMTemplateOptions, StatusEnum, type StatusParams, type StickerMediaObject, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateApi, type TemplateBody, type TemplateButton, type TemplateButtons, type TemplateCarousel, type TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateLimitedTimeOffer, type TemplateOptions, type TemplateParameter, type TemplateRequestBody, type TemplateResponse, TemplateStatusEnum, type TextMessageParams, type TextObject, type TextParameter, type Throughput, type ThroughputLevel, TwoStepVerificationApi, type TwoStepVerificationClass, type TwoStepVerificationParams, type TwoStepVerificationRequest, type URLButton, type UpdateBusinessProfileRequest, type UpdateFlowResponse, type UpdateQrCodeRequest, type UpdateWabaSubscription, type UploadMediaResponse, type ValidateFlowJsonResponse, type VerifyCodeRequest, type VideoMediaObject, VideoMediaTypesEnum, type WABAClass, type WabaAccount, type WabaAccountFields, type WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, type WabaHealthStatus, WabaHealthStatusCanSendMessage, type WabaHealthStatusEntity, type WabaHealthStatusError, type WabaSubscription, type WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookMessage, WebhookTypesEnum, WhatsApp, type WhatsAppConfig, WhatsApp as WhatsAppLegacy, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{AudioMediaTypesEnum as e,BusinessVerticalEnum as t,ButtonPositionEnum as n,CategoryEnum as r,ComponentTypesEnum as i,ConversationTypesEnum as a,CurrencyCodesEnum as o,DataLocalizationRegionEnum as s,DocumentMediaTypesEnum as c,HttpMethodsEnum as l,ImageMediaTypesEnum as u,InteractiveTypesEnum as d,LanguagesEnum as f,MessageTypesEnum as p,ParametersTypesEnum as m,RequestCodeMethodsEnum as h,StatusEnum as g,StickerMediaTypesEnum as _,SubTypeEnum as v,SystemChangeTypesEnum as y,TemplateStatusEnum as b,VideoMediaTypesEnum as x,WabaConfigEnum as S,WebhookTypesEnum as C}from"./enums-CSUpFXb8.js";import{isMetaError as w}from"./version-BUuqrHc6.js";import{WhatsApp as T}from"./whatsapp-B85mxH5f.js";import"./base-D-cXu_lA.js";import{encryption_default as E}from"./encryption-Cwc0xcVL.js";import{flow_default as D}from"./flow-CVes0Qus.js";import{FlowActionEnum as O,FlowCategoryEnum as k,FlowStatusEnum as A,FlowTypeEnum as j}from"./common-C6FXBDm7.js";import{media_default as M}from"./media-Dw5OGzDD.js";import{messages_default as N}from"./messages-h5-NW8QO.js";import"./objectToQueryString-CAHI0qTs.js";import{phone_default as P}from"./phone-CZyWLyWB.js";import"./buildFieldsQueryString-Cr-jz3p0.js";import{profile_default as F}from"./profile-Bb7GDP0n.js";import{qrCode_default as I}from"./qrCode-CeZEtX9J.js";import{registration_default as L}from"./registration-BkjhC3xw.js";import{TemplateApi as R}from"./template-Bgy-BCXJ.js";import{twoStepVerification_default as z}from"./twoStepVerification-DYlYF_P5.js";import{waba_default as B}from"./waba-SF2W3z2U.js";import"./api-8hRAOyaL.js";import{isFlowDataExchangeRequest as V,isFlowErrorRequest as H,isFlowPingRequest as U}from"./flowTypeGuards-Gn3-slCW.js";import"./WebhookProcessor-BUZFeZD_.js";import"./handler-BGqjZ0xg.js";import{webhookHandler as W}from"./express-CrfNLYMM.js";import{webhookHandler as G}from"./nextjs-DxRCL4t3.js";import"./webhook-D4DQ01Xq.js";let K=function(e){return e.Approved=`APPROVED`,e.Active=`ACTIVE`,e.Inactive=`INACTIVE`,e.Disabled=`DISABLED`,e}({}),q=function(e){return e.Blocked=`BLOCKED`,e.Limited=`LIMITED`,e.Available=`AVAILABLE`,e}({}),J=function(e){return e.Approved=`APPROVED`,e.Active=`ACTIVE`,e.Inactive=`INACTIVE`,e.Disabled=`DISABLED`,e}({}),Y=function(e){return e.Verified=`verified`,e.PendingSubmission=`pending_submission`,e.Unverified=`unverified`,e.Rejected=`rejected`,e}({});export{e as AudioMediaTypesEnum,F as BusinessProfileApi,t as BusinessVerticalEnum,n as ButtonPositionEnum,r as CategoryEnum,i as ComponentTypesEnum,a as ConversationTypesEnum,o as CurrencyCodesEnum,s as DataLocalizationRegionEnum,c as DocumentMediaTypesEnum,E as EncryptionApi,W as ExpressWebhook,O as FlowActionEnum,D as FlowApi,k as FlowCategoryEnum,A as FlowStatusEnum,j as FlowTypeEnum,l as HttpMethodsEnum,u as ImageMediaTypesEnum,d as InteractiveTypesEnum,f as LanguagesEnum,M as MediaApi,p as MessageTypesEnum,N as MessagesApi,G as NextJsWebhook,m as ParametersTypesEnum,P as PhoneNumberApi,I as QrCodeApi,L as RegistrationApi,h as RequestCodeMethodsEnum,g as StatusEnum,_ as StickerMediaTypesEnum,v as SubTypeEnum,y as SystemChangeTypesEnum,R as TemplateApi,b as TemplateStatusEnum,z as TwoStepVerificationApi,x as VideoMediaTypesEnum,K as WabaAccountReviewStatus,J as WabaAccountStatus,B as WabaApi,Y as WabaBusinessVerificationStatus,S as WabaConfigEnum,q as WabaHealthStatusCanSendMessage,C as WebhookTypesEnum,T as WhatsApp,T as WhatsAppLegacy,V as isFlowDataExchangeRequest,H as isFlowErrorRequest,U as isFlowPingRequest,w as isMetaError};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/waba/types/common.ts"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/api/waba/types/common.ts"],"sourcesContent":["import type { ResponseSuccess } from '../../../types/request';\n\n/**\n * WhatsApp Business Account subscription configuration\n */\nexport type WabaSubscription = {\n whatsapp_business_api_data: {\n id: string;\n link: string;\n name: string;\n category: string;\n };\n override_callback_uri?: string;\n};\n\n/**\n * Parameters for updating WABA subscription\n */\nexport interface UpdateWabaSubscription {\n override_callback_uri: string;\n verify_token: string;\n}\n\n/**\n * Response containing all WABA subscriptions\n */\nexport interface WabaSubscriptions {\n data: Array<WabaSubscription>;\n}\n\n/**\n * WABA account review status enumeration\n */\nexport enum WabaAccountReviewStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * WABA health status for message sending capability\n */\nexport enum WabaHealthStatusCanSendMessage {\n Blocked = 'BLOCKED',\n Limited = 'LIMITED',\n Available = 'AVAILABLE',\n}\n\n/**\n * WABA account status enumeration\n */\nexport enum WabaAccountStatus {\n Approved = 'APPROVED',\n Active = 'ACTIVE',\n Inactive = 'INACTIVE',\n Disabled = 'DISABLED',\n}\n\n/**\n * Business verification status enumeration\n */\nexport enum WabaBusinessVerificationStatus {\n Verified = 'verified',\n PendingSubmission = 'pending_submission',\n Unverified = 'unverified',\n Rejected = 'rejected',\n}\n\n/**\n * WABA health status error details\n */\nexport interface WabaHealthStatusError {\n error_code?: number;\n error_description?: string;\n possible_solution?: string;\n}\n\n/**\n * WABA health status entity information\n */\nexport interface WabaHealthStatusEntity {\n entity_type?: string;\n id?: string;\n can_send_message?: string;\n errors?: WabaHealthStatusError[];\n}\n\n/**\n * Overall WABA health status\n */\nexport interface WabaHealthStatus {\n can_send_message?: WabaHealthStatusCanSendMessage;\n entities?: WabaHealthStatusEntity[];\n}\n\n/**\n * WhatsApp Business Account information\n */\nexport interface WabaAccount {\n account_review_status?: WabaAccountReviewStatus;\n id?: string;\n health_status?: WabaHealthStatus;\n status?: WabaAccountStatus;\n business_verification_status?: WabaBusinessVerificationStatus;\n message_template_namespace?: string;\n name?: string;\n ownership_type?: string;\n currency?: string;\n}\n\n/**\n * Available fields for WABA account queries\n */\nexport type WabaAccountFields =\n | 'id'\n | 'name'\n | 'account_review_status'\n | 'auth_international_rate_eligibility'\n | 'business_verification_status'\n | 'country'\n | 'currency'\n | 'health_status'\n | 'status'\n | 'ownership_type'\n | 'message_template_namespace';\n\n/**\n * Parameter type for specifying which WABA account fields to retrieve\n */\nexport type WabaAccountFieldsParam = WabaAccountFields[];\n\n/**\n * Interface defining all WABA API methods\n */\nexport interface WABAClass {\n getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;\n getAllWabaSubscriptions(): Promise<WabaSubscriptions>;\n updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;\n unsubscribeFromWaba(): Promise<ResponseSuccess>;\n}\n"],"mappings":"i4DAiCA,IAAY,EAAA,SAAA,EAAL,OACH,GAAA,SAAA,WACA,EAAA,OAAA,SACA,EAAA,SAAA,WACA,EAAA,SAAA,kBAMQ,EAAA,SAAA,EAAL,OACH,GAAA,QAAA,UACA,EAAA,QAAA,UACA,EAAA,UAAA,mBAMQ,EAAA,SAAA,EAAL,OACH,GAAA,SAAA,WACA,EAAA,OAAA,SACA,EAAA,SAAA,WACA,EAAA,SAAA,kBAMQ,EAAA,SAAA,EAAL,OACH,GAAA,SAAA,WACA,EAAA,kBAAA,qBACA,EAAA,WAAA,aACA,EAAA,SAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FlowActionEnum, FlowDataExchangeRequest, FlowEndpointRequest, FlowErrorNotificationRequest, FlowHealthCheckRequest } from "./common-CvPVD1o6.js";
|
|
2
2
|
|
|
3
|
+
//#region src/utils/flowTypeGuards.d.ts
|
|
3
4
|
declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
|
|
4
5
|
declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
|
|
5
6
|
/**
|
|
@@ -10,10 +11,10 @@ declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionE
|
|
|
10
11
|
* @returns True if the request is a valid Data Exchange request, false otherwise
|
|
11
12
|
*/
|
|
12
13
|
declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
action: (typeof DATA_EXCHANGE_ACTIONS)[number];
|
|
15
|
+
screen?: string;
|
|
16
|
+
flow_token: string;
|
|
17
|
+
data?: Record<string, any>;
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* Type guard to check if a request is an Error Notification request
|
|
@@ -23,13 +24,13 @@ declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): reques
|
|
|
23
24
|
* @returns True if the request is a valid Error Notification request, false otherwise
|
|
24
25
|
*/
|
|
25
26
|
declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
action: (typeof ERROR_ACTIONS)[number];
|
|
28
|
+
screen: string;
|
|
29
|
+
flow_token: string;
|
|
30
|
+
data: {
|
|
31
|
+
error: string;
|
|
32
|
+
error_message: string;
|
|
33
|
+
};
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Type guard to check if a request is a Ping (health check) request
|
|
@@ -39,19 +40,20 @@ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is Fl
|
|
|
39
40
|
* @returns True if the request is a Ping request, false otherwise
|
|
40
41
|
*/
|
|
41
42
|
declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
|
|
42
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/utils/isMetaError.d.ts
|
|
43
45
|
interface MetaError extends Error {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
error_subcode?: number;
|
|
53
|
-
fbtrace_id: string;
|
|
46
|
+
error: {
|
|
47
|
+
message: string;
|
|
48
|
+
type: string;
|
|
49
|
+
code: number;
|
|
50
|
+
error_data?: {
|
|
51
|
+
messaging_product: 'whatsapp';
|
|
52
|
+
details: string;
|
|
54
53
|
};
|
|
54
|
+
error_subcode?: number;
|
|
55
|
+
fbtrace_id: string;
|
|
56
|
+
};
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Determines if the error is a Meta API error response
|
|
@@ -59,5 +61,6 @@ interface MetaError extends Error {
|
|
|
59
61
|
* @returns Type guard indicating if error is a Meta API error
|
|
60
62
|
*/
|
|
61
63
|
declare function isMetaError(error: any): error is MetaError;
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
+
//#endregion
|
|
65
|
+
export { MetaError, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError };
|
|
66
|
+
//# sourceMappingURL=isMetaError-B3AglYeY.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isMetaError-B3AglYeY.d.ts","names":[],"sources":["../src/utils/flowTypeGuards.ts","../src/utils/isMetaError.ts"],"sourcesContent":[],"mappings":";;;cA2BM,iCAAqB,cAAA,CAAA,eAAA,cAAA,CAAA,MAAA,cAAA,CAAA;cAGrB,yBAAa,cAAA,CAAA,eAAA,cAAA,CAAA;AAxBQ;;;;;;AAqBA;AAGuD,iBASlE,yBAAA,CATkE,OAAA,EAS/B,mBAT+B,CAAA,EAAA,OAAA,IASE,uBATF,GAAA;QAA/D,EAAA,CAAA,OAUC,qBAVD,CAAA,CAAA,MAAA,CAAA;QAAA,CAAA,EAAA,MAAA;EAAA,UAAA,EAAA,MAAA;EASH,IAAA,CAAA,EAIL,MAJK,CAAA,MAAA,EAAA,GAAA,CAAA;CAAyB;;;;;;AAoCzC;;AAA4C,iBAA5B,kBAAA,CAA4B,OAAA,EAAA,mBAAA,CAAA,EAAA,OAAA,IAAiC,4BAAjC,GAAA;QAAiC,EAAA,CAAA,OACzD,aADyD,CAAA,CAAA,MAAA,CAAA;QACzD,EAAA,MAAA;EAAa,UAAA,EAAA,MAAA;EAwCjB,IAAA,EAAA;IAAiB,KAAA,EAAA,MAAA;IAAU,aAAA,EAAA,MAAA;;CAAuD;;;;ACpHlG;AAmBA;;;iBDiGgB,iBAAA,UAA2B,iCAAiC;;;UCpH3D,SAAA,SAAkB;;;ID2B7B,IAAA,EAAA,MAAA;IAAyG,IAAA,EAAA,MAAA;IAApF,UAAA,CAAA,EAAA;MAAA,iBAAA,EAAA,UAAA;MAAA,OAAA,EAAA,MAAA;IAAA,CAAA;IAGrB,aAA4E,CAAA,EAAA,MAAA;IAAA,UAAA,EAAA,MAAA;;;;AASlF;;;;AACoB,iBCrBJ,WAAA,CDqBI,KAAA,EAAA,GAAA,CAAA,EAAA,KAAA,ICrB8B,SDqB9B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{endpoint=`media`;constructor(e,t){super(e,t)}async getMediaById(n,r){return this.sendJson(e.Get,`${n}`,this.config[t.RequestTimeout],null)}async uploadMedia(n,r=`whatsapp`){let i=new FormData;return i.append(`file`,n),i.append(`messaging_product`,r),i.append(`type`,n.type),this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],i)}async deleteMedia(n,r){return this.sendJson(e.Delete,`${n}`,this.config[t.RequestTimeout],null)}async downloadMedia(n){return this.sendJson(e.Get,n,this.config[t.RequestTimeout],null)}},i=r;export{r as MediaApi,i as media_default};
|
|
2
|
+
//# sourceMappingURL=media-Dw5OGzDD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-Dw5OGzDD.js","names":[],"sources":["../src/api/media/MediaApi.ts","../src/api/media/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as media from './types';\n\n/**\n * API for managing WhatsApp Media.\n *\n * This API allows you to:\n * - Get media information by ID\n * - Upload media files\n * - Delete media files\n * - Download media files from URLs\n */\nexport default class MediaApi extends BaseAPI implements media.MediaClass {\n private readonly endpoint = 'media';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Retrieve media information by media ID.\n *\n * @param mediaId The media ID to retrieve information for\n * @param phone_number_id Optional phone number ID (defaults to configured one)\n * @returns Media information including URL, mime type, file size, etc.\n *\n * @example\n * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');\n */\n async getMediaById(mediaId: string, phone_number_id?: string): Promise<media.MediaResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * Upload a media file to WhatsApp.\n *\n * @param file The file to upload\n * @param messagingProduct The messaging product (default: 'whatsapp')\n * @returns Upload response containing the media ID\n *\n * @example\n * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });\n * const result = await whatsappClient.media.uploadMedia(file);\n */\n async uploadMedia(file: File, messagingProduct: string = 'whatsapp'): Promise<media.UploadMediaResponse> {\n const formData = new FormData();\n formData.append('file', file);\n formData.append('messaging_product', messagingProduct);\n formData.append('type', file.type);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Delete a media file.\n *\n * @param mediaId The media ID to delete\n * @param phone_number_id Optional phone number ID (defaults to configured one)\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.media.deleteMedia('media_id_123');\n */\n async deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess> {\n return this.sendJson(HttpMethodsEnum.Delete, `${mediaId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * Download media from a URL.\n *\n * @param mediaUrl The URL to download media from\n * @returns Blob containing the media data\n *\n * @example\n * const blob = await whatsappClient.media.downloadMedia('https://...');\n */\n async downloadMedia(mediaUrl: string): Promise<Blob> {\n return this.sendJson(HttpMethodsEnum.Get, mediaUrl, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import MediaApi from './MediaApi';\n\nexport default MediaApi;\n\nexport { MediaApi };\n\nexport type { MediaClass, MediaResponse, MediasResponse, UploadMediaResponse } from './types';\n"],"mappings":"uHAgBA,IAAqB,EAArB,cAAsC,CAAoC,CACtE,SAA4B,QAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,aAAa,EAAiB,EAAwD,CACxF,OAAO,KAAK,SAAS,EAAgB,IAAK,GAAG,IAAW,KAAK,OAAO,EAAe,gBAAiB,KAAK,CAc7G,MAAM,YAAY,EAAY,EAA2B,WAAgD,CACrG,IAAM,EAAW,IAAI,SAKrB,OAJA,EAAS,OAAO,OAAQ,EAAK,CAC7B,EAAS,OAAO,oBAAqB,EAAiB,CACtD,EAAS,OAAO,OAAQ,EAAK,KAAK,CAE3B,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,EACH,CAaL,MAAM,YAAY,EAAiB,EAAoD,CACnF,OAAO,KAAK,SAAS,EAAgB,OAAQ,GAAG,IAAW,KAAK,OAAO,EAAe,gBAAiB,KAAK,CAYhH,MAAM,cAAc,EAAiC,CACjD,OAAO,KAAK,SAAS,EAAgB,IAAK,EAAU,KAAK,OAAO,EAAe,gBAAiB,KAAK,GCpF7G,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,MessageTypesEnum as t,WabaConfigEnum as n}from"./enums-CSUpFXb8.js";import{BaseAPI as r}from"./base-D-cXu_lA.js";var i=class extends r{commonMethod=e.Post;commonEndpoint=`messages`;constructor(e,t){super(e,t)}bodyBuilder(e,t,n,r){let i={messaging_product:`whatsapp`,recipient_type:`individual`,to:n,type:e,[e]:t};return r&&(i.context={message_id:r}),i}send(e){return this.sendJson(this.commonMethod,`${this.config[n.PhoneNumberId]}/${this.commonEndpoint}`,this.config[n.RequestTimeout],e)}async audio(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Audio,n,r,i)))}async contacts(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Contacts,n,r,i)))}async document(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Document,n,r,i)))}async image(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Image,n,r,i)))}async interactive(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Interactive,n,r,i)))}async location(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Location,n,r,i)))}async sticker(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Sticker,n,r,i)))}async template(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Template,n,r,i)))}async text(e){let{body:n,to:r,replyMessageId:i,previewUrl:a}=e,o=typeof n==`string`?{body:n,preview_url:a??!0}:{...n,preview_url:a??n.preview_url??!0};return this.send(JSON.stringify(this.bodyBuilder(t.Text,o,r,i)))}async video(e){let{body:n,to:r,replyMessageId:i}=e;return this.send(JSON.stringify(this.bodyBuilder(t.Video,n,r,i)))}async status(e){let t={messaging_product:`whatsapp`,status:e.status,message_id:e.messageId,...e.typingIndicator&&{typing_indicator:e.typingIndicator}};return this.send(JSON.stringify(t))}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 n={message_id:e.messageId,emoji:e.emoji};return this.send(JSON.stringify(this.bodyBuilder(t.Reaction,n,e.to)))}},a=i;export{i as MessagesApi,a as messages_default};
|
|
2
|
+
//# sourceMappingURL=messages-h5-NW8QO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages-h5-NW8QO.js","names":["body: m.MessageRequestBody<T>","textPayload: m.TextObject","MessageApi"],"sources":["../src/api/messages/MessageApi.ts","../src/api/messages/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport {\n type ComponentTypesEnum,\n HttpMethodsEnum,\n type InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../../types/enums';\nimport type { RequesterClass } from '../../types/request';\n\nimport type * as m from './types';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param to The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<m.MessagesResponse> {\n return this.sendJson(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param params The audio message parameter object\n * @returns Promise with the message response\n */\n async audio(params: m.MessageRequestParams<m.AudioMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param params The contact message parameter object\n * @returns Promise with the message response\n */\n async contacts(params: m.MessageRequestParams<[m.ContactObject]>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param params The document message parameter object\n * @returns Promise with the message response\n */\n async document(params: m.MessageRequestParams<m.DocumentMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param params The image message parameter object\n * @returns Promise with the message response\n */\n async image(params: m.MessageRequestParams<m.ImageMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param params The interactive message parameter object\n * @returns Promise with the message response\n */\n async interactive(params: m.MessageRequestParams<m.InteractiveObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param params The location message parameter object\n * @returns Promise with the message response\n */\n async location(params: m.MessageRequestParams<m.LocationObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param params The sticker message parameter object\n * @returns Promise with the message response\n */\n async sticker(params: m.MessageRequestParams<m.StickerMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param params The template message parameter object\n * @returns Promise with the message response\n */\n async template(\n params: m.MessageRequestParams<m.MessageTemplateObject<ComponentTypesEnum>>,\n ): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param params The text message parameter object\n * @returns Promise with the message response\n */\n async text(params: m.TextMessageParams): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId, previewUrl } = params;\n\n // Handle both string and TextObject types\n const textPayload: m.TextObject =\n typeof body === 'string'\n ? { body, preview_url: previewUrl ?? true }\n : { ...body, preview_url: previewUrl ?? body.preview_url ?? true };\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, textPayload, to, replyMessageId)));\n }\n\n /**\n * Sends a video message via WhatsApp\n * @param params The video message parameter object\n * @returns Promise with the message response\n */\n async video(params: m.MessageRequestParams<m.VideoMediaObject>): Promise<m.MessagesResponse> {\n const { body, to, replyMessageId } = params;\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (mark as read, etc.)\n * @param params The status update parameters\n * @returns Promise with the API response\n */\n async status(params: m.StatusParams): Promise<m.MessagesResponse> {\n const body = {\n messaging_product: 'whatsapp',\n status: params.status,\n message_id: params.messageId,\n ...(params.typingIndicator && { typing_indicator: params.typingIndicator }),\n };\n\n return this.send(JSON.stringify(body));\n }\n\n /**\n * Marks a message as read\n * @param params Object containing messageId\n * @returns Promise with the API response\n */\n async markAsRead(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n });\n }\n\n /**\n * Shows typing indicator\n * @param params Object containing messageId\n * @returns Promise with the API response\n */\n async showTypingIndicator(params: { messageId: string }): Promise<m.MessagesResponse> {\n return this.status({\n status: 'read',\n messageId: params.messageId,\n typingIndicator: { type: 'text' },\n });\n }\n\n /**\n * Sends a list interactive message\n * @param params The list interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveList(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.List }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a CTA URL interactive message\n * @param params The CTA URL interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveCtaUrl(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a location request interactive message\n * @param params The location request interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveLocationRequest(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends an address message interactive message\n * @param params The address message interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveAddressMessage(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a reply buttons interactive message\n * @param params The reply buttons interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveReplyButtons(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Button }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a flow interactive message\n * @param params The flow interactive message parameters\n * @returns Promise with the message response\n */\n async interactiveFlow(\n params: m.MessageRequestParams<m.InteractiveObject & { type: InteractiveTypesEnum.Flow }>,\n ): Promise<m.MessagesResponse> {\n return this.interactive(params);\n }\n\n /**\n * Sends a reaction to a message\n * @param params The reaction parameters\n * @returns Promise with the message response\n */\n async reaction(params: m.ReactionParams): Promise<m.MessagesResponse> {\n const reactionPayload = {\n message_id: params.messageId,\n emoji: params.emoji,\n };\n\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Reaction, reactionPayload, params.to)));\n }\n}\n","import MessageApi from './MessageApi';\n\nexport default MessageApi;\n\nexport { MessageApi };\n\nexport type {\n AudioMediaObject,\n ContactObject,\n DocumentMediaObject,\n ImageMediaObject,\n InteractiveObject,\n LocationObject,\n MessageRequestParams,\n MessageTemplateObject,\n MessagesResponse,\n ReactionParams,\n StatusParams,\n StickerMediaObject,\n TextMessageParams,\n TextObject,\n VideoMediaObject,\n} from './types';\n"],"mappings":"6IAwCA,IAAqB,EAArB,cAAyC,CAAmC,CACxE,aAAgC,EAAgB,KAChD,eAAkC,WAElC,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAWzB,YACI,EACA,EACA,EACA,EACF,CACE,IAAMA,EAAgC,CAClC,kBAAmB,WACnB,eAAgB,aAChB,KACA,QACC,GAAO,EACX,CAID,OAFI,IAAgB,EAAK,QAAa,CAAE,WAAY,EAAgB,EAE7D,EAQX,KAAa,EAAoD,CAC7D,OAAO,KAAK,SACR,KAAK,aACL,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,iBACrD,KAAK,OAAO,EAAe,gBAC3B,EACH,CAQL,MAAM,MAAM,EAAiF,CACzF,GAAM,CAAE,OAAM,KAAI,kBAAmB,EACrC,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,YAAY,EAAiB,MAAO,EAAM,EAAI,EAAe,CAAC,CAAC,CAQxG,MAAM,SAAS,EAAgF,CAC3F,GAAM,CAAE,OAAM,KAAI,kBAAmB,EACrC,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,YAAY,EAAiB,SAAU,EAAM,E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ructor(e){super(e)}async parseRequestBody(e){if(e.method===`POST`&&!e.body){let t=[];if(typeof e[Symbol.asyncIterator]==`function`){for await(let n of e)t.push(n);let n=Buffer.concat(t).toString();if(n.trim())try{e.body=JSON.parse(n)}catch{throw Error(`Invalid JSON in request body`)}else e.body={}}}}async handleGet(e,t){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body)}catch(e){return console.error(`Webhook verification error:`,e),t.status(500).json({error:`Internal Server Error`})}}async handlePost(e,t){try{await this.parseRequestBody(e)}catch(e){return console.error(`Webhook processing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?t.status(400).json({error:`Invalid JSON`}):t.status(500).json({error:`Internal Server Error`})}try{let n=this.constructFullUrl(e.headers,e.url),r=new Request(n,{method:`POST`,headers:e.headers,body:JSON.stringify(e.body)}),i=await this.processWebhook(r);return this.applyHeaders(i,t),t.status(i.status).send(i.body)}catch(e){return console.error(`Webhook processing error:`,e),t.status(500).json({error:`Internal Server Error`})}}async handleFlow(e,t){try{let n=this.constructFullUrl(e.headers,e.url),r=new Request(n,{method:e.method,headers:e.headers,body:e.method===`POST`?JSON.stringify(e.body):void 0}),i=await this.processFlow(r);return this.applyHeaders(i,t),t.status(i.status).send(i.body)}catch(e){return console.error(`Flow error:`,e),t.status(500).json({error:`Internal Server Error`})}}getHandlers(){return{GET:(e,t)=>this.handleGet(e,t),POST:(e,t)=>this.handlePost(e,t),webhook:(e,t)=>this.autoRoute(e,t),flow:(e,t)=>this.handleFlow(e,t),processor:this.webhookProcessor}}};function n(e){return new t(e).getHandlers()}export{n as webhookHandler};
|
|
2
|
+
//# sourceMappingURL=nextjs-DxRCL4t3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs-DxRCL4t3.js","names":["chunks: Buffer[]"],"sources":["../src/core/webhook/frameworks/nextjs.ts"],"sourcesContent":["import { BaseRequest, BaseResponse, BaseWebhookConfig, BaseWebhookHandler } from './handler';\n\n// Next.js specific interfaces\nexport interface BaseApiRequest extends BaseRequest {\n method?: string;\n url?: string;\n headers: Record<string, string | string[] | undefined>;\n body?: any;\n query: Partial<Record<string, string | string[]>>;\n rawBody?: any;\n}\n\nexport interface BaseApiResponse extends BaseResponse {\n status(code: number): any;\n json(data: any): void | any;\n send(data?: any): void | any;\n setHeader(name: string, value: string): void;\n}\n\nexport interface NextJsWebhookConfig extends BaseWebhookConfig {\n // Next.js specific config can be added here\n}\n\n/**\n * Next.js Page Router webhook handler extending the base handler\n */\nclass NextJsWebhookHandler<\n TRequest extends BaseApiRequest,\n TResponse extends BaseApiResponse,\n> extends BaseWebhookHandler<TRequest, TResponse> {\n constructor(config: NextJsWebhookConfig) {\n super(config);\n }\n\n // Helper function to parse request body for POST requests\n private async parseRequestBody(req: TRequest): Promise<void> {\n if (req.method === 'POST' && !req.body) {\n const chunks: Buffer[] = [];\n\n // Check if req is a stream (has Symbol.asyncIterator)\n if (typeof (req as any)[Symbol.asyncIterator] === 'function') {\n for await (const chunk of req as any) {\n chunks.push(chunk);\n }\n\n const body = Buffer.concat(chunks).toString();\n\n // Only attempt to parse if there's actual content\n if (body.trim()) {\n try {\n req.body = JSON.parse(body);\n } catch (error) {\n throw new Error('Invalid JSON in request body');\n }\n } else {\n req.body = {};\n }\n }\n }\n }\n\n protected async handleGet(req: TRequest, res: TResponse): Promise<any> {\n try {\n const { 'hub.mode': mode, 'hub.verify_token': token, 'hub.challenge': challenge } = req.query;\n\n const result = await this.processVerification(\n (mode as string) || null,\n (token as string) || null,\n (challenge as string) || null,\n );\n\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Webhook verification error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n protected async handlePost(req: TRequest, res: TResponse): Promise<any> {\n try {\n // Auto-parse body if needed\n await this.parseRequestBody(req);\n } catch (error) {\n console.error('Webhook processing error:', error);\n\n // Handle JSON parsing errors specifically\n if (error instanceof Error && error.message === 'Invalid JSON in request body') {\n return res.status(400).json({ error: 'Invalid JSON' });\n }\n\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: 'POST',\n headers: req.headers as HeadersInit,\n body: JSON.stringify(req.body),\n });\n\n const result = await this.processWebhook(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Webhook processing error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n protected async handleFlow(req: TRequest, res: TResponse): Promise<any> {\n try {\n const fullUrl = this.constructFullUrl(req.headers, req.url);\n\n const webRequest = new Request(fullUrl, {\n method: req.method,\n headers: req.headers as HeadersInit,\n body: req.method === 'POST' ? JSON.stringify(req.body) : undefined,\n });\n\n const result = await this.processFlow(webRequest);\n this.applyHeaders(result, res);\n return res.status(result.status).send(result.body);\n } catch (error) {\n console.error('Flow error:', error);\n return res.status(500).json({ error: 'Internal Server Error' });\n }\n }\n\n getHandlers() {\n return {\n // Method handlers for clean destructuring\n GET: (req: TRequest, res: TResponse) => this.handleGet(req, res),\n POST: (req: TRequest, res: TResponse) => this.handlePost(req, res),\n\n // Auto-routing webhook handler\n webhook: (req: TRequest, res: TResponse) => this.autoRoute(req, res),\n\n // Flow handler\n flow: (req: TRequest, res: TResponse) => this.handleFlow(req, res),\n\n // Expose processor for handler registration\n processor: this.webhookProcessor,\n };\n }\n}\n\n// Generic webhook handler that accepts any compatible request/response types\nexport function webhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(\n config: NextJsWebhookConfig,\n) {\n const handler = new NextJsWebhookHandler<TRequest, TResponse>(config);\n return handler.getHandlers();\n}\n"],"mappings":"2DA0BA,IAAM,EAAN,cAGU,CAAwC,CAC9C,YAAY,EAA6B,CACrC,MAAM,EAAO,CAIjB,MAAc,iBAA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,KAAK,eAAe,EAAW,CAEpD,OADA,KAAK,aAAa,EAAQ,EAAI,CACvB,EAAI,OAAO,EAAO,OAAO,CAAC,KAAK,EAAO,KAAK,OAC7C,EAAO,CAEZ,OADA,QAAQ,MAAM,4BAA6B,EAAM,CAC1C,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,EAIvE,MAAgB,WAAW,EAAe,EAA8B,CACpE,GAAI,CACA,IAAM,EAAU,KAAK,iBAAiB,EAAI,QAAS,EAAI,IAAI,CAErD,EAAa,IAAI,QAAQ,EAAS,CACpC,OAAQ,EAAI,OACZ,QAAS,EAAI,QACb,KAAM,EAAI,SAAW,OAAS,KAAK,UAAU,EAAI,KAAK,CAAG,IAAA,GAC5D,CAAC,CAEI,EAAS,MAAM,KAAK,YAAY,EAAW,CAEjD,OADA,KAAK,aAAa,EAAQ,EAAI,CACvB,EAAI,OAAO,EAAO,OAAO,CAAC,KAAK,EAAO,KAAK,OAC7C,EAAO,CAEZ,OADA,QAAQ,MAAM,cAAe,EAAM,CAC5B,EAAI,OAAO,IAAI,CAAC,KAAK,CAAE,MAAO,wBAAyB,CAAC,EAIvE,aAAc,CACV,MAAO,CAEH,KAAM,EAAe,IAAmB,KAAK,UAAU,EAAK,EAAI,CAChE,MAAO,EAAe,IAAmB,KAAK,WAAW,EAAK,EAAI,CAGlE,SAAU,EAAe,IAAmB,KAAK,UAAU,EAAK,EAAI,CAGpE,MAAO,EAAe,IAAmB,KAAK,WAAW,EAAK,EAAI,CAGlE,UAAW,KAAK,iBACnB,GAKT,SAAgB,EACZ,EACF,CAEE,OADgB,IAAI,EAA0C,EAAO,CACtD,aAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=e=>{if(!e||Object.keys(e).length===0)return``;let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0){let e=encodeURIComponent(n),i=encodeURIComponent(String(r));t.push(`${e}=${i}`)}return t.length>0?`?${t.join(`&`)}`:``};export{e as objectToQueryString};
|
|
2
|
+
//# sourceMappingURL=objectToQueryString-CAHI0qTs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectToQueryString-CAHI0qTs.js","names":["queryParts: string[]"],"sources":["../src/utils/objectToQueryString.ts"],"sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const queryParts: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n const encodedKey = encodeURIComponent(key);\n const encodedValue = encodeURIComponent(String(value));\n queryParts.push(`${encodedKey}=${encodedValue}`);\n }\n }\n\n return queryParts.length > 0 ? `?${queryParts.join('&')}` : '';\n};\n"],"mappings":"AAAA,MAAa,EAAuB,GAAwC,CACxE,GAAI,CAAC,GAAU,OAAO,KAAK,EAAO,CAAC,SAAW,EAC1C,MAAO,GAGX,IAAMA,EAAuB,EAAE,CAE/B,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAO,CAC7C,GAAI,IAAU,IAAA,GAAW,CACrB,IAAM,EAAa,mBAAmB,EAAI,CACpC,EAAe,mBAAmB,OAAO,EAAM,CAAC,CACtD,EAAW,KAAK,GAAG,EAAW,GAAG,IAAe,CAIxD,OAAO,EAAW,OAAS,EAAI,IAAI,EAAW,KAAK,IAAI,GAAK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";import{objectToQueryString as r}from"./objectToQueryString-CAHI0qTs.js";var i=class extends n{endpoint=`phone_numbers`;constructor(e,t){super(e,t)}async getPhoneNumberById(n){let i=n?r({fields:n}):``;return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}${i}`,this.config[t.RequestTimeout],null)}async getPhoneNumbers(){return this.sendJson(e.Get,`${this.config[t.BusinessAcctId]}/${this.endpoint}`,this.config[t.RequestTimeout],null)}async requestVerificationCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/request_code`,this.config[t.RequestTimeout],JSON.stringify(n))}async verifyCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/verify_code`,this.config[t.RequestTimeout],JSON.stringify(n))}},a=i;export{i as PhoneNumberApi,a as phone_default};
|
|
2
|
+
//# sourceMappingURL=phone-CZyWLyWB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-CZyWLyWB.js","names":[],"sources":["../src/api/phone/PhoneNumberApi.ts","../src/api/phone/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\n\nimport type * as phoneNumber from './types';\n\n/**\n * API for managing WhatsApp Phone Numb ers.\n *\n * This API allows you to:\n * - Get phone number information by ID\n * - Get all phone numbers for a business account\n * - Request verification codes for phone numbers\n * - Verify phone numbers with codes\n */\nexport default class PhoneNumberApi extends BaseAPI implements phoneNumber.PhoneNumberClass {\n private readonly endpoint = 'phone_numbers';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get phone number information by ID.\n *\n * @param fields Optional comma-separated list of fields to include in the response\n * @returns Phone number information including verification status, quality rating, etc.\n *\n * @example\n * const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById();\n * const phoneNumberWithFields = await whatsappClient.phoneNumber.getPhoneNumberById('display_phone_number,verified_name');\n */\n async getPhoneNumberById(fields?: string): Promise<phoneNumber.PhoneNumberResponse> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get all phone numbers for the business account.\n *\n * @returns List of phone numbers associated with the business account\n *\n * @example\n * const phoneNumbers = await whatsappClient.phoneNumber.getPhoneNumbers();\n */\n async getPhoneNumbers(): Promise<phoneNumber.PhoneNumbersResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Request a verification code for the phone number.\n *\n * @param request Verification code request containing method and language\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.phoneNumber.requestVerificationCode({\n * code_method: 'SMS',\n * language: 'en_US'\n * });\n */\n async requestVerificationCode(request: phoneNumber.RequestVerificationCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/request_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Verify the phone number with the received code.\n *\n * @param request Verification request containing the code\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.phoneNumber.verifyCode({\n * code: '123456'\n * });\n */\n async verifyCode(request: phoneNumber.VerifyCodeRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/verify_code`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n}\n","import PhoneNumberApi from './PhoneNumberApi';\n\nexport default PhoneNumberApi;\n\nexport { PhoneNumberApi };\n\nexport type {\n AccountMode,\n CodeVerificationStatus,\n Cursors,\n HealthStatus,\n HealthStatusEntity,\n MessagingLimitTier,\n PhoneNumberClass,\n PhoneNumberResponse,\n PhoneNumbersResponse,\n PlatformType,\n QualityRating,\n QualityScore,\n RequestVerificationCodeRequest,\n Throughput,\n ThroughputLevel,\n TwoStepVerificationParams,\n VerifyCodeRequest,\n} from './types';\n"],"mappings":"+LAiBA,IAAqB,EAArB,cAA4C,CAAgD,CACxF,SAA4B,gBAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,mBAAmB,EAA2D,CAChF,IAAM,EAAc,EAAS,EAAoB,CAAE,SAAQ,CAAC,CAAG,GAC/D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,iBAAiB,IAC/C,KAAK,OAAO,EAAe,gBAC3B,KACH,CAWL,MAAM,iBAA6D,CAC/D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,GAAG,KAAK,WACtD,KAAK,OAAO,EAAe,gBAC3B,KACH,CAeL,MAAM,wBAAwB,EAA+E,CACzG,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,eAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAcL,MAAM,WAAW,EAAkE,CAC/E,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,cAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,GCjGT,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";import{objectToQueryString as r}from"./objectToQueryString-CAHI0qTs.js";import{buildFieldsQueryString as i}from"./buildFieldsQueryString-Cr-jz3p0.js";var a=class extends n{endpoint=`whatsapp_business_profile`;constructor(e,t){super(e,t)}async getBusinessProfile(n){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}${i(n)}`,this.config[t.RequestTimeout],null)}async updateBusinessProfile(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async createUploadSession(n,i,a){let o=r({file_length:n,file_type:i,file_name:a});return this.sendJson(e.Post,`app/uploads/${o}`,this.config[t.RequestTimeout],null)}async uploadMedia(n,r){return this.sendJson(e.Post,`${n}`,this.config[t.RequestTimeout],r)}async getUploadHandle(n){return this.sendJson(e.Get,`${n}`,this.config[t.RequestTimeout],null)}},o=a;export{a as BusinessProfileApi,o as profile_default};
|
|
2
|
+
//# sourceMappingURL=profile-Bb7GDP0n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-Bb7GDP0n.js","names":[],"sources":["../src/api/profile/BusinessProfileApi.ts","../src/api/profile/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\nimport { buildFieldsQueryString } from '../../utils/buildFieldsQueryString';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\n\nimport type * as bp from './types';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileApi extends BaseAPI implements bp.BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n *\n * // Using the BusinessProfileFieldsParam type\n * const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);\n */\n async getBusinessProfile(fields?: bp.BusinessProfileFieldsParam): Promise<bp.BusinessProfileResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${buildFieldsQueryString(fields)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(updateRequest: bp.UpdateBusinessProfileRequest): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<bp.UploadSessionResponse> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(uploadId: string, file: Buffer): Promise<bp.UploadBusinessProfileResponse> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<bp.UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","import BusinessProfileApi from './BusinessProfileApi';\n\nexport default BusinessProfileApi;\n\nexport { BusinessProfileApi };\n\nexport type {\n BusinessProfileClass,\n BusinessProfileData,\n BusinessProfileField,\n BusinessProfileFieldsParam,\n BusinessProfileResponse,\n CreateUploadSessionParams,\n GetUploadHandleParams,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadMediaParams,\n UploadSession,\n UploadSessionResponse,\n} from './types';\n"],"mappings":"6QAoBA,IAAqB,EAArB,cAAgD,CAA2C,CACvF,SAA4B,4BAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAuBzB,MAAM,mBAAmB,EAA6E,CAClG,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WAAW,EAAuB,EAAO,GAC9F,KAAK,OAAO,EAAe,gBAC3B,KACH,CA6BL,MAAM,sBAAsB,EAA0E,CAClG,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAc,CAChC,CAsBL,MAAM,oBACF,EACA,EACA,EACiC,CACjC,IAAM,EAAc,EAAoB,CACpC,YAAa,EACb,UAAW,EACX,UAAW,EACd,CAAC,CAEF,OAAO,KAAK,SACR,EAAgB,KAChB,eAAe,IACf,KAAK,OAAO,EAAe,gBAC3B,KACH,CAoBL,MAAM,YAAY,EAAkB,EAAyD,CACzF,OAAO,KAAK,SAAS,EAAgB,KAAM,GAAG,IAAY,KAAK,OAAO,EAAe,gBAAiB,EAAK,CAqC/G,MAAM,gBAAgB,EAA4C,CAC9D,OAAO,KAAK,SAAS,EAAgB,IAAK,GAAG,IAAY,KAAK,OAAO,EAAe,gBAAiB,KAAK,GCvLlH,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{endpoint=`message_qrdls`;constructor(e,t){super(e,t)}async createQrCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async getQrCodes(){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],null)}async getQrCode(n){return this.sendJson(e.Get,`${this.config[t.PhoneNumberId]}/${this.endpoint}/${n}`,this.config[t.RequestTimeout],null)}async updateQrCode(n){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/${this.endpoint}`,this.config[t.RequestTimeout],JSON.stringify(n))}async deleteQrCode(n){return this.sendJson(e.Delete,`${this.config[t.PhoneNumberId]}/${this.endpoint}/${n}`,this.config[t.RequestTimeout],null)}},i=r;export{r as QrCodeApi,i as qrCode_default};
|
|
2
|
+
//# sourceMappingURL=qrCode-CeZEtX9J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qrCode-CeZEtX9J.js","names":[],"sources":["../src/api/qrCode/QrCodeApi.ts","../src/api/qrCode/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as qrCode from './types';\n\n/**\n * API for managing WhatsApp QR Codes.\n *\n * This API allows you to:\n * - Create QR codes with prefilled messages\n * - Get all QR codes\n * - Get specific QR code details\n * - Update QR code messages\n * - Delete QR codes\n */\nexport default class QrCodeApi extends BaseAPI implements qrCode.QrCodeClass {\n private readonly endpoint = 'message_qrdls';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Create a new QR code with a prefilled message.\n *\n * @param request The QR code creation request\n * @returns QR code information including code, deep link URL, and optional image URL\n *\n * @example\n * const qrCode = await whatsappClient.qrCode.createQrCode({\n * prefilled_message: 'Hello from WhatsApp!',\n * generate_qr_image: 'PNG'\n * });\n */\n async createQrCode(request: qrCode.CreateQrCodeRequest): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Get all QR codes for the current phone number.\n *\n * @returns List of all QR codes\n *\n * @example\n * const qrCodes = await whatsappClient.qrCode.getQrCodes();\n */\n async getQrCodes(): Promise<qrCode.QrCodesResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Get a specific QR code by ID.\n *\n * @param qrCodeId The QR code ID to retrieve\n * @returns QR code information\n *\n * @example\n * const qrCode = await whatsappClient.qrCode.getQrCode('qr_code_123');\n */\n async getQrCode(qrCodeId: string): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update an existing QR code's prefilled message.\n *\n * @param request The QR code update request containing code and new message\n * @returns Updated QR code information\n *\n * @example\n * const updatedQrCode = await whatsappClient.qrCode.updateQrCode({\n * code: 'existing_qr_code',\n * prefilled_message: 'Updated message!'\n * });\n */\n async updateQrCode(request: qrCode.UpdateQrCodeRequest): Promise<qrCode.QrCodeResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(request),\n );\n }\n\n /**\n * Delete a QR code.\n *\n * @param qrCodeId The QR code ID to delete\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.qrCode.deleteQrCode('qr_code_123');\n */\n async deleteQrCode(qrCodeId: string): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}/${qrCodeId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import QrCodeApi from './QrCodeApi';\n\nexport default QrCodeApi;\n\nexport { QrCodeApi };\n\nexport type { CreateQrCodeRequest, QrCodeClass, QrCodeResponse, QrCodesResponse, UpdateQrCodeRequest } from './types';\n"],"mappings":"uHAiBA,IAAqB,EAArB,cAAuC,CAAsC,CACzE,SAA4B,gBAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAezB,MAAM,aAAa,EAAqE,CACpF,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAWL,MAAM,YAA8C,CAChD,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KACH,CAYL,MAAM,UAAU,EAAkD,CAC9D,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,SAAS,GAAG,IACjE,KAAK,OAAO,EAAe,gBAC3B,KACH,CAeL,MAAM,aAAa,EAAqE,CACpF,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,WACrD,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAQ,CAC1B,CAYL,MAAM,aAAa,EAA4C,CAC3D,OAAO,KAAK,SACR,EAAgB,OAChB,GAAG,KAAK,OAAO,EAAe,eAAe,GAAG,KAAK,SAAS,GAAG,IACjE,KAAK,OAAO,EAAe,gBAC3B,KACH,GClHT,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{constructor(e,t){super(e,t)}async register(n,r){let i={messaging_product:`whatsapp`,pin:n,...r&&{data_localization_region:r}};return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/register`,this.config[t.RequestTimeout],JSON.stringify(i))}async deregister(){return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}/deregister`,this.config[t.RequestTimeout],null)}},i=r;export{r as RegistrationApi,i as registration_default};
|
|
2
|
+
//# sourceMappingURL=registration-BkjhC3xw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-BkjhC3xw.js","names":["body: registration.RegistrationRequest"],"sources":["../src/api/registration/RegistrationApi.ts","../src/api/registration/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { DataLocalizationRegionEnum, HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as registration from './types';\n\n/**\n * API for managing WhatsApp Business Account registration.\n *\n * This API allows you to:\n * - Register a WhatsApp Business Account with a PIN\n * - Deregister a WhatsApp Business Account\n */\nexport default class RegistrationApi extends BaseAPI implements registration.RegistrationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Register a WhatsApp Business Account using a PIN.\n *\n * @param pin The registration PIN received via SMS or voice call\n * @param dataLocalizationRegion Optional data localization region\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.register('123456', DataLocalizationRegionEnum.Asia);\n */\n async register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess> {\n const body: registration.RegistrationRequest = {\n messaging_product: 'whatsapp',\n pin,\n ...(dataLocalizationRegion && { data_localization_region: dataLocalizationRegion }),\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/register`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n\n /**\n * Deregister a WhatsApp Business Account.\n *\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.registration.deregister();\n */\n async deregister(): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/deregister`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import RegistrationApi from './RegistrationApi';\n\nexport default RegistrationApi;\n\nexport { RegistrationApi };\n\nexport type { RegistrationClass, RegistrationRequest } from './types';\n"],"mappings":"uHAcA,IAAqB,EAArB,cAA6C,CAAkD,CAC3F,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAazB,MAAM,SAAS,EAAa,EAA+E,CACvG,IAAMA,EAAyC,CAC3C,kBAAmB,WACnB,MACA,GAAI,GAA0B,CAAE,yBAA0B,EAAwB,CACrF,CAED,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,WAC7C,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAK,CACvB,CAWL,MAAM,YAAuC,CACzC,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,eAAe,aAC7C,KAAK,OAAO,EAAe,gBAC3B,KACH,GCxDT,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{CategoryEnum as e,HttpMethodsEnum as t,WabaConfigEnum as n}from"./enums-CSUpFXb8.js";import{BaseAPI as r}from"./base-D-cXu_lA.js";import{objectToQueryString as i}from"./objectToQueryString-CAHI0qTs.js";var a=class extends r{endpoint=`message_templates`;constructor(e,t){super(e,t)}async getTemplate(e){return this.sendJson(t.Get,`${e}`,this.config[n.RequestTimeout],null)}async updateTemplate(e,r){return this.sendJson(t.Post,`${e}`,this.config[n.RequestTimeout],JSON.stringify(r))}async getTemplates(e){return this.sendJson(t.Get,`${this.config[n.BusinessAcctId]}/${this.endpoint}${i(e??{})}`,this.config[n.RequestTimeout],null)}async createTemplate(e){return this.sendJson(t.Post,`${this.config[n.BusinessAcctId]}/${this.endpoint}`,this.config[n.RequestTimeout],JSON.stringify(e))}async deleteTemplate(e){return this.sendJson(t.Delete,`${this.config[n.BusinessAcctId]}/${this.endpoint}${i(e)}`,this.config[n.RequestTimeout],null)}};function o(e){let t={type:`HEADER`,format:e.format};return e.text&&(t.text=e.text),e.example&&(t.example=e.example),t}function s(e){let t={type:`BODY`,text:e.text};return e.example&&(t.example=e.example),t}function c(e){return{type:`FOOTER`,text:e.text}}function l(e){let t=[];if(e.phone_number&&t.push({type:`PHONE_NUMBER`,text:e.phone_number.text,phone_number:e.phone_number.phone_number}),e.url){let n={type:`URL`,text:e.url.text,url:e.url.url};e.url.example&&(n.example=[e.url.example]),t.push(n)}if(e.quick_reply&&e.quick_reply.forEach(e=>{t.push({type:`QUICK_REPLY`,text:e.text})}),e.copy_code&&t.push({type:`COPY_CODE`,example:e.copy_code.example}),e.flow){let n={type:`FLOW`,text:e.flow.text};e.flow.flow_id&&(n.flow_id=e.flow.flow_id),e.flow.flow_name&&(n.flow_name=e.flow.flow_name),e.flow.flow_json&&(n.flow_json=e.flow.flow_json),e.flow.flow_action&&(n.flow_action=e.flow.flow_action),e.flow.navigate_screen&&(n.navigate_screen=e.flow.navigate_screen),t.push(n)}return e.mpm&&t.push({type:`MPM`}),e.otp&&t.push({type:`OTP`}),e.spm&&t.push({type:`SPM`}),t.length>0?[{type:`BUTTONS`,buttons:t}]:[]}function u(e){return e.map(e=>{switch(e.type){case`text`:return e.value;case`currency`:return e.fallback_value;case`date_time`:return e.fallback_value;case`image`:case`video`:case`document`:return e.handle||e.link||``;case`location`:return e.name||``;case`product`:return e.product_retailer_id;default:return``}})}function d(e){let t=[];if(e.header&&t.push(o(e.header)),e.body&&t.push(s(e.body)),e.footer&&t.push(c(e.footer)),e.buttons&&t.push(...l(e.buttons)),e.carousel){let n=[];e.carousel.cards.forEach((e,t)=>{if(e.image||e.video||e.product){let t=e.image?`IMAGE`:e.video?`VIDEO`:`DOCUMENT`,r=e.image||e.video||e.product||``;n.push({type:`HEADER`,format:t,example:{header_handle:[r]}})}e.body&&n.push({type:`BODY`,text:e.body,example:e.bodyParameters?{body_text:[u(e.bodyParameters)]}:void 0}),e.buttons&&n.push(...l(e.buttons))}),t.push(...n)}return e.limitedTimeOffer&&t.push({type:`LIMITED_TIME_OFFER`,limited_time_offer:{expiration_time_ms:e.limitedTimeOffer.expiration_time_ms}}),{name:e.name,language:e.language,category:e.category,components:t.length>0?t:void 0}}function f(t){let n=[],r=`*{{1}}* is your verification code.`;return t.add_security_recommendation&&(r+=` For your security, do not share this code.`),t.code_expiration_minutes&&(r+=` This code expires in ${t.code_expiration_minutes} minutes.`),n.push({type:`BODY`,text:r,example:{body_text:[[`123456`]]}}),n.push({type:`BUTTONS`,buttons:[{type:`OTP`}]}),{name:t.name,language:t.language,category:e.Authentication,components:n}}function p(t){let n=[],r=`Your security code is *{{1}}*.`;return t.add_security_recommendation&&(r+=` Do not share this code with anyone.`),t.code_expiration_minutes&&(r+=` This code expires in ${t.code_expiration_minutes} minutes.`),n.push({type:`BODY`,text:r,example:{body_text:[[`ABCD1234`]]}}),t.copy_code_button&&n.push({type:`BUTTONS`,buttons:[{type:`COPY_CODE`,example:`ABCD1234`}]}),{name:t.name,language:t.language,category:e.Authentication,components:n}}function m(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`CATALOG`,action:{thumbnail_product_retailer_id:t.thumbnail_product_retailer_id}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function h(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`COPY_CODE`,example:t.coupon_code}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function g(t){let n=[];return n.push({type:`LIMITED_TIME_OFFER`,limited_time_offer:{expiration_time_ms:t.expiration_time_ms}}),t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),{name:t.name,language:t.language,category:e.Marketing,components:n}}function _(t){let n=[],r=[];return t.cards.forEach((e,t)=>{let n=[];n.push({type:`HEADER`,format:e.header.format,example:e.header.example}),n.push(s(e.body)),e.buttons&&n.push(...l(e.buttons)),r.push({card_index:t,components:n})}),n.push({type:`CAROUSEL`,cards:r}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function v(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`MPM`,action:{thumbnail_product_retailer_id:t.thumbnail_product_retailer_id,sections:t.sections}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function y(t){let n=[];t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer));let r=t.cards.map((e,t)=>({card_index:t,components:[{type:`HEADER`,format:`PRODUCT`,example:{header_handle:[e.product_retailer_id]}}]}));return n.push({type:`CAROUSEL`,cards:r}),{name:t.name,language:t.language,category:e.Marketing,components:n}}function b(t){let n=[];return t.header&&n.push(o({...t.header,format:`TEXT`})),n.push(s(t.body)),t.footer&&n.push(c(t.footer)),n.push({type:`BUTTONS`,buttons:[{type:`SPM`,action:{product_retailer_id:t.product_retailer_id}}]}),{name:t.name,language:t.language,category:e.Marketing,components:n}}export{a as TemplateApi,p as createAuthenticationTemplate,m as createCatalogTemplate,h as createCouponTemplate,g as createLimitedTimeOfferTemplate,v as createMPMTemplate,_ as createMediaCardCarouselTemplate,f as createOTPTemplate,y as createProductCardCarouselTemplate,b as createSPMTemplate,d as createTemplate};
|
|
2
|
+
//# sourceMappingURL=template-Bgy-BCXJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-Bgy-BCXJ.js","names":["header: TemplateHeader","body: TemplateBody","buttons: TemplateButton[]","urlButton: any","flowButton: any","components: ComponentTypes[]","carouselComponents: ComponentTypes[]","carouselCards: MediaCarouselCard[]","cardComponents: (TemplateHeader | TemplateBody | TemplateButtons)[]","carouselCards: ProductCarouselCard[]"],"sources":["../src/api/template/TemplateApi.ts","../src/api/template/factories/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponsePagination, ResponseSuccess } from '../../types/request';\nimport { objectToQueryString } from '../../utils/objectToQueryString';\nimport type {\n TemplateClass,\n TemplateDeleteParams,\n TemplateGetParams,\n TemplateRequestBody,\n TemplateResponse,\n} from './types';\n\nexport default class TemplateApi extends BaseAPI implements TemplateClass {\n private readonly endpoint = 'message_templates';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getTemplate(templateId: string): Promise<TemplateResponse> {\n return this.sendJson(HttpMethodsEnum.Get, `${templateId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n async updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${templateId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async getTemplates(params?: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params ?? {})}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async createTemplate(template: TemplateRequestBody): Promise<TemplateResponse> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(template),\n );\n }\n\n async deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess> {\n return this.sendJson(\n HttpMethodsEnum.Delete,\n `${this.config[WabaConfigEnum.BusinessAcctId]}/${this.endpoint}${objectToQueryString(params)}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","import { CategoryEnum } from '../../../types/enums';\nimport type {\n ComponentTypes,\n MediaCarouselCard,\n ProductCarouselCard,\n TemplateBody,\n TemplateButton,\n TemplateButtons,\n TemplateFooter,\n TemplateHeader,\n TemplateRequestBody,\n} from '../types';\nimport type {\n AuthenticationTemplateOptions,\n BodyOptions,\n ButtonOptions,\n CatalogTemplateOptions,\n CouponTemplateOptions,\n FooterOptions,\n HeaderOptions,\n LimitedTimeOfferTemplateOptions,\n MediaCardCarouselTemplateOptions,\n MPMTemplateOptions,\n OTPTemplateOptions,\n ProductCardCarouselTemplateOptions,\n SPMTemplateOptions,\n TemplateOptions,\n TemplateParameter,\n} from '../types';\n\n// Helper function to create header component\nfunction createHeader(options: HeaderOptions): TemplateHeader {\n const header: TemplateHeader = {\n type: 'HEADER',\n format: options.format,\n };\n\n if (options.text) {\n header.text = options.text;\n }\n\n if (options.example) {\n header.example = options.example;\n }\n\n return header;\n}\n\n// Helper function to create body component\nfunction createBody(options: BodyOptions): TemplateBody {\n const body: TemplateBody = {\n type: 'BODY',\n text: options.text,\n };\n\n if (options.example) {\n body.example = options.example;\n }\n\n return body;\n}\n\n// Helper function to create footer component\nfunction createFooter(options: FooterOptions): TemplateFooter {\n return {\n type: 'FOOTER',\n text: options.text,\n };\n}\n\n// Helper function to create buttons\nfunction createButtons(options: ButtonOptions): ComponentTypes[] {\n const buttons: TemplateButton[] = [];\n\n if (options.phone_number) {\n buttons.push({\n type: 'PHONE_NUMBER',\n text: options.phone_number.text,\n phone_number: options.phone_number.phone_number,\n });\n }\n\n if (options.url) {\n const urlButton: any = {\n type: 'URL',\n text: options.url.text,\n url: options.url.url,\n };\n if (options.url.example) {\n urlButton.example = [options.url.example];\n }\n buttons.push(urlButton);\n }\n\n if (options.quick_reply) {\n options.quick_reply.forEach((qr) => {\n buttons.push({\n type: 'QUICK_REPLY',\n text: qr.text,\n });\n });\n }\n\n if (options.copy_code) {\n buttons.push({\n type: 'COPY_CODE',\n example: options.copy_code.example,\n });\n }\n\n if (options.flow) {\n const flowButton: any = {\n type: 'FLOW',\n text: options.flow.text,\n };\n if (options.flow.flow_id) flowButton.flow_id = options.flow.flow_id;\n if (options.flow.flow_name) flowButton.flow_name = options.flow.flow_name;\n if (options.flow.flow_json) flowButton.flow_json = options.flow.flow_json;\n if (options.flow.flow_action) flowButton.flow_action = options.flow.flow_action;\n if (options.flow.navigate_screen) flowButton.navigate_screen = options.flow.navigate_screen;\n buttons.push(flowButton);\n }\n\n if (options.mpm) {\n buttons.push({ type: 'MPM' });\n }\n\n if (options.otp) {\n buttons.push({ type: 'OTP' });\n }\n\n if (options.spm) {\n buttons.push({ type: 'SPM' });\n }\n\n return buttons.length > 0\n ? [\n {\n type: 'BUTTONS',\n buttons: buttons,\n },\n ]\n : [];\n}\n\n// Helper function to format parameter examples\nfunction formatParameterExamples(parameters: TemplateParameter[]): string[] {\n return parameters.map((param) => {\n switch (param.type) {\n case 'text':\n return param.value;\n case 'currency':\n return param.fallback_value;\n case 'date_time':\n return param.fallback_value;\n case 'image':\n case 'video':\n case 'document':\n return param.handle || param.link || '';\n case 'location':\n return param.name || '';\n case 'product':\n return param.product_retailer_id;\n default:\n return '';\n }\n });\n}\n\n// Generic template factory\nexport function createTemplate(options: TemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader(options.header));\n }\n\n if (options.body) {\n components.push(createBody(options.body));\n }\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n if (options.buttons) {\n components.push(...createButtons(options.buttons));\n }\n\n if (options.carousel) {\n // Handle carousel components\n const carouselComponents: ComponentTypes[] = [];\n options.carousel.cards.forEach((card, index) => {\n if (card.image || card.video || card.product) {\n const format = card.image ? 'IMAGE' : card.video ? 'VIDEO' : 'DOCUMENT';\n const handle = card.image || card.video || card.product || '';\n carouselComponents.push({\n type: 'HEADER',\n format: format,\n example: {\n header_handle: [handle],\n },\n });\n }\n if (card.body) {\n carouselComponents.push({\n type: 'BODY',\n text: card.body,\n example: card.bodyParameters\n ? {\n body_text: [formatParameterExamples(card.bodyParameters)],\n }\n : undefined,\n });\n }\n if (card.buttons) {\n carouselComponents.push(...createButtons(card.buttons));\n }\n });\n components.push(...carouselComponents);\n }\n\n if (options.limitedTimeOffer) {\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.limitedTimeOffer.expiration_time_ms,\n },\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: options.category,\n components: components.length > 0 ? components : undefined,\n };\n}\n\n// OTP Template Factory\nexport function createOTPTemplate(options: OTPTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security recommendation if requested\n let bodyText = '*{{1}}* is your verification code.';\n if (options.add_security_recommendation) {\n bodyText += ' For your security, do not share this code.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['123456']], // Example OTP code\n },\n });\n\n // Add OTP button\n components.push({\n type: 'BUTTONS',\n buttons: [{ type: 'OTP' }],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Authentication Template Factory\nexport function createAuthenticationTemplate(options: AuthenticationTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add security message\n let bodyText = 'Your security code is *{{1}}*.';\n if (options.add_security_recommendation) {\n bodyText += ' Do not share this code with anyone.';\n }\n if (options.code_expiration_minutes) {\n bodyText += ` This code expires in ${options.code_expiration_minutes} minutes.`;\n }\n\n components.push({\n type: 'BODY',\n text: bodyText,\n example: {\n body_text: [['ABCD1234']], // Example auth code\n },\n });\n\n // Add copy code button if requested\n if (options.copy_code_button) {\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: 'ABCD1234',\n },\n ],\n });\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Authentication,\n components,\n };\n}\n\n// Catalog Template Factory\nexport function createCatalogTemplate(options: CatalogTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add catalog button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'CATALOG',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Coupon Template Factory\nexport function createCouponTemplate(options: CouponTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add copy code button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'COPY_CODE',\n example: options.coupon_code,\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Limited Time Offer Template Factory\nexport function createLimitedTimeOfferTemplate(options: LimitedTimeOfferTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add limited time offer component first\n components.push({\n type: 'LIMITED_TIME_OFFER',\n limited_time_offer: {\n expiration_time_ms: options.expiration_time_ms,\n },\n });\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Media Card Carousel Template Factory\nexport function createMediaCardCarouselTemplate(options: MediaCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n // Add carousel component\n const carouselCards: MediaCarouselCard[] = [];\n options.cards.forEach((card, index) => {\n const cardComponents: (TemplateHeader | TemplateBody | TemplateButtons)[] = [];\n\n // Add header (media)\n cardComponents.push({\n type: 'HEADER' as const,\n format: card.header.format,\n example: card.header.example,\n });\n\n // Add body\n cardComponents.push(createBody(card.body));\n\n // Add buttons if any\n if (card.buttons) {\n cardComponents.push(...(createButtons(card.buttons) as TemplateButtons[]));\n }\n\n carouselCards.push({\n card_index: index,\n components: cardComponents,\n });\n });\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// MPM (Multi-Product Message) Template Factory\nexport function createMPMTemplate(options: MPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add MPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'MPM',\n action: {\n thumbnail_product_retailer_id: options.thumbnail_product_retailer_id,\n sections: options.sections,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// Product Card Carousel Template Factory\nexport function createProductCardCarouselTemplate(options: ProductCardCarouselTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add carousel with product cards\n const carouselCards: ProductCarouselCard[] = options.cards.map((card, index) => ({\n card_index: index,\n components: [\n {\n type: 'HEADER' as const,\n format: 'PRODUCT' as const,\n example: {\n header_handle: [card.product_retailer_id],\n },\n },\n ],\n }));\n\n components.push({\n type: 'CAROUSEL',\n cards: carouselCards,\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n\n// SPM (Single-Product Message) Template Factory\nexport function createSPMTemplate(options: SPMTemplateOptions): TemplateRequestBody {\n const components: ComponentTypes[] = [];\n\n if (options.header) {\n components.push(createHeader({ ...options.header, format: 'TEXT' }));\n }\n\n components.push(createBody(options.body));\n\n if (options.footer) {\n components.push(createFooter(options.footer));\n }\n\n // Add SPM button\n components.push({\n type: 'BUTTONS',\n buttons: [\n {\n type: 'SPM',\n action: {\n product_retailer_id: options.product_retailer_id,\n },\n },\n ],\n });\n\n return {\n name: options.name,\n language: options.language,\n category: CategoryEnum.Marketing,\n components,\n };\n}\n"],"mappings":"iNAaA,IAAqB,EAArB,cAAyC,CAAiC,CACtE,SAA4B,oBAE5B,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAGzB,MAAM,YAAY,EAA+C,CAC7D,OAAO,KAAK,SAAS,EAAgB,IAAK,GAAG,IAAc,KAAK,OAAO,EAAe,gBAAiB,KAAK,CAGhH,MAAM,eAAe,EAAoB,EAAkE,CACvG,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,IACH,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAS,CAC3B,CAGL,MAAM,aAAa,EAA2E,CAC1F,OAAO,KAAK,SACR,EAAgB,IAChB,GAAG,KAAK,OAAO,EAAe,gBAAgB,GAAG,KAAK,WAAW,EAAo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Q,oBAChC,CACJ,CACJ,CACJ,CAAC,CAEK,CACH,KAAM,EAAQ,KACd,SAAU,EAAQ,SAClB,SAAU,EAAa,UACvB,aACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{HttpMethodsEnum as e,WabaConfigEnum as t}from"./enums-CSUpFXb8.js";import{BaseAPI as n}from"./base-D-cXu_lA.js";var r=class extends n{constructor(e,t){super(e,t)}async setTwoStepVerificationCode(n){let r={pin:n};return this.sendJson(e.Post,`${this.config[t.PhoneNumberId]}`,this.config[t.RequestTimeout],JSON.stringify(r))}},i=r;export{r as TwoStepVerificationApi,i as twoStepVerification_default};
|
|
2
|
+
//# sourceMappingURL=twoStepVerification-DYlYF_P5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoStepVerification-DYlYF_P5.js","names":[],"sources":["../src/api/twoStepVerification/TwoStepVerificationApi.ts","../src/api/twoStepVerification/index.ts"],"sourcesContent":["import { BaseAPI } from '../../types/base';\nimport type { WabaConfigType } from '../../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../../types/enums';\nimport type { RequesterClass, ResponseSuccess } from '../../types/request';\n\nimport type * as twoStepVerification from './types';\n\n/**\n * API for managing WhatsApp Two-Step Verification.\n *\n * This API allows you to:\n * - Set a two-step verification PIN code\n * - Manage two-step verification settings\n */\nexport default class TwoStepVerificationApi extends BaseAPI implements twoStepVerification.TwoStepVerificationClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Set a two-step verification PIN code.\n *\n * @param pin The PIN code to set for two-step verification (6-digit numeric string)\n * @returns Response indicating success or failure\n *\n * @example\n * await whatsappClient.twoStepVerification.setTwoStepVerificationCode('123456');\n */\n async setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess> {\n const body = {\n pin,\n };\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(body),\n );\n }\n}\n","import TwoStepVerificationApi from './TwoStepVerificationApi';\n\nexport default TwoStepVerificationApi;\n\nexport { TwoStepVerificationApi };\n\nexport type { TwoStepVerificationClass, TwoStepVerificationRequest } from './types';\n"],"mappings":"uHAcA,IAAqB,EAArB,cAAoD,CAAgE,CAChH,YAAY,EAAwB,EAAwB,CACxD,MAAM,EAAQ,EAAO,CAYzB,MAAM,2BAA2B,EAAuC,CACpE,IAAM,EAAO,CACT,MACH,CAED,OAAO,KAAK,SACR,EAAgB,KAChB,GAAG,KAAK,OAAO,EAAe,iBAC9B,KAAK,OAAO,EAAe,gBAC3B,KAAK,UAAU,EAAK,CACvB,GCpCT,EAAe"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export { H as HttpsClientClass, a as HttpsClientResponseClass, b as ResponseHeaderValue, R as ResponseHeaders, c as ResponseJSONBody } from '../httpsClient-Cbd2Y6mg.js';
|
|
5
|
-
export { G as GeneralHeaderInterface, a as GeneralRequestBody, P as Paging, e as RequesterClass, R as RequesterResponseInterface, b as ResponseData, c as ResponsePagination, d as ResponseSuccess } from '../request-CUjrMn8R.js';
|
|
6
|
-
export { A as AudioMediaTypesEnum, B as BusinessVerticalEnum, a as ButtonPositionEnum, C as CategoryEnum, b as ComponentTypesEnum, c as ConversationTypesEnum, d as CurrencyCodesEnum, D as DataLocalizationRegionEnum, e as DocumentMediaTypesEnum, H as HttpMethodsEnum, I as ImageMediaTypesEnum, f as InteractiveTypesEnum, L as LanguagesEnum, M as MessageTypesEnum, P as ParametersTypesEnum, k as ReferralSourceTypesEnum, R as RequestCodeMethodsEnum, S as StatusEnum, g as StickerMediaTypesEnum, h as SubTypeEnum, i as SystemChangeTypesEnum, T as TemplateStatusEnum, V as VideoMediaTypesEnum, W as WabaConfigEnum, j as WebhookTypesEnum } from '../enums-DIimUG6s.js';
|
|
1
|
+
import { AudioMediaTypesEnum, BaseAPI, BaseClass, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, GeneralHeaderInterface, GeneralRequestBody, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, Paging, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, RequesterClass, RequesterResponseInterface, ResponseData, ResponsePagination, ResponseSuccess, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WabaConfigType, WebhookTypesEnum, WhatsAppConfig } from "../base-CfDkvT1x.js";
|
|
2
|
+
import { HttpsClientClass, HttpsClientResponseClass, LoggerInterface, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody } from "../index-DQkgkiB6.js";
|
|
3
|
+
export { AudioMediaTypesEnum, BaseAPI, BaseClass, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, GeneralHeaderInterface, GeneralRequestBody, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, LoggerInterface, MessageTypesEnum, Paging, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WabaConfigType, WebhookTypesEnum, WhatsAppConfig };
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{AudioMediaTypesEnum as e,BusinessVerticalEnum as t,ButtonPositionEnum as n,CategoryEnum as r,ComponentTypesEnum as i,ConversationTypesEnum as a,CurrencyCodesEnum as o,DataLocalizationRegionEnum as s,DocumentMediaTypesEnum as c,HttpMethodsEnum as l,ImageMediaTypesEnum as u,InteractiveTypesEnum as d,LanguagesEnum as f,MessageTypesEnum as p,ParametersTypesEnum as m,ReferralSourceTypesEnum as h,RequestCodeMethodsEnum as g,StatusEnum as _,StickerMediaTypesEnum as v,SubTypeEnum as y,SystemChangeTypesEnum as b,TemplateStatusEnum as x,VideoMediaTypesEnum as S,WabaConfigEnum as C,WebhookTypesEnum as w}from"../enums-CSUpFXb8.js";import{BaseAPI as T}from"../base-D-cXu_lA.js";export{e as AudioMediaTypesEnum,T as BaseAPI,BaseClass,t as BusinessVerticalEnum,n as ButtonPositionEnum,r as CategoryEnum,i as ComponentTypesEnum,a as ConversationTypesEnum,o as CurrencyCodesEnum,s as DataLocalizationRegionEnum,c as DocumentMediaTypesEnum,l as HttpMethodsEnum,u as ImageMediaTypesEnum,d as InteractiveTypesEnum,f as LanguagesEnum,p as MessageTypesEnum,m as ParametersTypesEnum,h as ReferralSourceTypesEnum,g as RequestCodeMethodsEnum,_ as StatusEnum,v as StickerMediaTypesEnum,y as SubTypeEnum,b as SystemChangeTypesEnum,x as TemplateStatusEnum,S as VideoMediaTypesEnum,C as WabaConfigEnum,w as WebhookTypesEnum};
|