UNPKG

meta-cloud-api

Version:
143 lines (139 loc) 5.41 kB
import { B as BaseAPI } from './base-CdGDdVEl.js'; import { WabaConfigType } from './types/config.js'; import { P as Paging, e as ResponseSuccess, R as RequesterClass } from './request-vYMaEfk5.js'; type QualityRating = 'GREEN' | 'YELLOW' | 'RED' | 'NA'; type AccountMode = 'LIVE' | 'SANDBOX'; type CodeVerificationStatus = 'NOT_VERIFIED' | 'VERIFIED' | 'EXPIRED' | 'PENDING' | 'DELETED' | 'MIGRATED' | 'BANNED' | 'RESTRICTED' | 'RATE_LIMITED' | 'FLAGGED' | 'CONNECTED' | 'DISCONNECTED' | 'UNKNOWN' | 'UNVERIFIED'; type MessagingLimitTier = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED'; type PlatformType = 'CLOUD_API' | 'ON_PREMISE' | 'NOT_APPLICABLE'; type ThroughputLevel = 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE'; type HealthStatusEntity = { entity_type: string; id: string; can_send_message: string; additional_info?: string[]; errors?: Array<{ error_code: number; error_description: string; possible_solution: string; }>; }; type HealthStatus = { can_send_message: string; entities: HealthStatusEntity[]; }; type QualityScore = { score: QualityRating; }; type Throughput = { level: ThroughputLevel; }; type PhoneNumberResponse = { display_phone_number: string; id: string; quality_rating: QualityRating; verified_name: string; account_mode?: AccountMode; certificate?: string; code_verification_status?: CodeVerificationStatus; conversational_automation?: Record<string, unknown>; eligibility_for_api_business_global_search?: string; health_status?: HealthStatus; is_official_business_account?: boolean; is_on_biz_app?: boolean; is_pin_enabled?: boolean; is_preverified_number?: boolean; last_onboarded_time?: string; messaging_limit_tier?: MessagingLimitTier; name_status?: string; new_certificate?: string; new_name_status?: string; platform_type?: PlatformType; quality_score?: QualityScore; search_visibility?: string; status?: CodeVerificationStatus; throughput?: Throughput; }; type Cursors = { before: string; after: string; }; type PhoneNumbersResponse = { data: PhoneNumberResponse[]; paging: Paging; }; type RequestVerificationCodeRequest = { code_method: 'SMS' | 'VOICE'; language: string; }; type VerifyCodeRequest = { code: string; }; type TwoStepVerificationParams = { pin: string; }; interface PhoneNumberClass { getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>; getPhoneNumbers(): Promise<PhoneNumbersResponse>; requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>; verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>; } /** * API for managing WhatsApp Phone Numb ers. * * This API allows you to: * - Get phone number information by ID * - Get all phone numbers for a business account * - Request verification codes for phone numbers * - Verify phone numbers with codes */ declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass { private readonly endpoint; constructor(config: WabaConfigType, client: RequesterClass); /** * Get phone number information by ID. * * @param fields Optional comma-separated list of fields to include in the response * @returns Phone number information including verification status, quality rating, etc. * * @example * const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById(); * const phoneNumberWithFields = await whatsappClient.phoneNumber.getPhoneNumberById('display_phone_number,verified_name'); */ getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>; /** * Get all phone numbers for the business account. * * @returns List of phone numbers associated with the business account * * @example * const phoneNumbers = await whatsappClient.phoneNumber.getPhoneNumbers(); */ getPhoneNumbers(): Promise<PhoneNumbersResponse>; /** * Request a verification code for the phone number. * * @param request Verification code request containing method and language * @returns Response indicating success or failure * * @example * await whatsappClient.phoneNumber.requestVerificationCode({ * code_method: 'SMS', * language: 'en_US' * }); */ requestVerificationCode(request: RequestVerificationCodeRequest): Promise<ResponseSuccess>; /** * Verify the phone number with the received code. * * @param request Verification request containing the code * @returns Response indicating success or failure * * @example * await whatsappClient.phoneNumber.verifyCode({ * code: '123456' * }); */ verifyCode(request: VerifyCodeRequest): Promise<ResponseSuccess>; } export { type AccountMode as A, type CodeVerificationStatus as C, type HealthStatus as H, type MessagingLimitTier as M, PhoneNumberApi as P, type QualityRating as Q, type RequestVerificationCodeRequest as R, type Throughput as T, type VerifyCodeRequest as V, type Cursors as a, type HealthStatusEntity as b, type PhoneNumberClass as c, type PhoneNumberResponse as d, type PhoneNumbersResponse as e, type PlatformType as f, type QualityScore as g, type ThroughputLevel as h, type TwoStepVerificationParams as i };