whatsapp-business
Version:
Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.
90 lines (89 loc) • 4.56 kB
TypeScript
import { Message, SendMessageResponse, GetBusinessPhoneNumberResponse, RequestPhoneNumberVerificationCodeArgs, VerifyPhoneNumberArgs, RegisterPhoneArgs, SetUpTwoFactorAuthArgs, DefaultResponse, BusinessProfile, BusinessProfileFieldsQuery, UpdateBusinessProfilePayload, GetMediaResponse, UploadMediaPayload, UploadMediaResponse, BusinessPhoneNumber, UpdateIdentityCheckState, HealthStatusResponse } from "./types";
import { createRestClient } from "./utils/restClient";
interface WABAClientArgs {
apiToken: string;
phoneId: string;
accountId: string;
}
/**
* Connector for the Whatsapp Cloud API.
*
* documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/guides
*/
export declare class WABAClient {
restClient: ReturnType<typeof createRestClient>;
phoneId: string;
accountId: string;
constructor({ apiToken, phoneId, accountId }: WABAClientArgs);
/**
*
* Retrieves your business profile. Customers can view your business profile by clicking your business's name or number in a conversation thread.
*
* @param fields you can specify which data you want to get from your business. If not passed, defaults to all fields.
*/
getBusinessProfile(fields?: BusinessProfileFieldsQuery): Promise<BusinessProfile>;
/**
* @param payload provide the fields that you wish to update.
*/
updateBusinessProfile(payload: UpdateBusinessProfilePayload): Promise<DefaultResponse>;
/**
* All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlier.
*
* A successful response returns an object with the uploaded media's ID.
*/
uploadMedia({ file, type }: Omit<UploadMediaPayload, "messaging_product">): Promise<UploadMediaResponse>;
/**
* Retrieves your media’s URL. Use the returned URL to download the media file. Note that clicking this URL (i.e. performing a generic GET) will not return the media; you must include an access token.
*
* A successful response includes an object with a media url. The URL is only valid for 5 minutes.
*/
getMedia(mediaId: string): Promise<GetMediaResponse>;
deleteMedia(mediaId: string): Promise<DefaultResponse>;
/**
* @param mediaUrl your media’s URL
* @param pathToSaveFile the path where you want to store the media
*/
downloadMedia(mediaUrl: string, pathToSaveFile: string): Promise<any>;
/**
* Yu can use the API to send the following free-form messages types:
* Text
* Reaction
* Media
* Location
* Contacts
* Interactive
* Address
* messages
* template
*
* For more information refer here: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages
*
* If you are working with template messages refer here: https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates
*
*/
sendMessage(payload: Omit<Message, "messaging_product">): Promise<SendMessageResponse>;
/**
* When you receive an incoming message from Webhooks,
* you can use the /messages endpoint to mark the message as
* read by changing its status to read. Messages marked as read display two blue check marks alongside their timestamp.
*/
markMessageAsRead(message_id: string): Promise<DefaultResponse>;
getBusinessPhoneNumbers(): Promise<GetBusinessPhoneNumberResponse>;
getSingleBusinessPhoneNumber(phoneNumberId: string): Promise<BusinessPhoneNumber>;
/**
* You may want us to verify a customer's identity before we deliver your message to them.
* You can have us do this by enabling the identity change check setting on your business phone number.
*/
updateIdentityCheckState({ enable_identity_key_check }: UpdateIdentityCheckState): Promise<DefaultResponse>;
requestPhoneNumberVerificationCode({ phoneNumberId, ...payload }: RequestPhoneNumberVerificationCodeArgs): Promise<DefaultResponse>;
verifyPhoneNumberCode({ phoneNumberId, ...payload }: VerifyPhoneNumberArgs): Promise<DefaultResponse>;
registerPhone({ phoneNumberId, ...payload }: RegisterPhoneArgs): Promise<DefaultResponse>;
deregisterPhone(phoneNumber: string): Promise<DefaultResponse>;
setupTwoStepAuth({ phoneNumberId, ...payload }: SetUpTwoFactorAuthArgs): Promise<DefaultResponse>;
/**
*
* @param nodeId is optional, defaults to the account_id
*/
getHealthStatus(nodeId?: string): Promise<HealthStatusResponse>;
}
export {};