ws-cloud-api
Version:
WhatsApp Cloud API for NodeJS
217 lines (211 loc) • 5.6 kB
TypeScript
import { a as MessageStatus } from './ws-cloud-api.fba8aa2f.js';
type MediaMessage = ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage;
interface ImageMessage extends MessageBase {
type: 'image';
image: ImageMedia;
}
interface ImageMedia {
id: string;
caption: string;
mime_type: string;
sha256: string;
}
interface VideoMessage extends MessageBase {
type: 'video';
video: VideoMedia;
}
interface VideoMedia {
id: string;
caption: string;
filename: string;
sha256: string;
mime_type: string;
}
interface AudioMessage extends MessageBase {
type: 'audio';
audio: AudioMedia;
}
interface AudioMedia {
id: string;
mime_type: string;
sha256: string;
voice: boolean;
}
interface DocumentMessage extends MessageBase {
type: 'document';
document: DocumentMedia;
}
interface DocumentMedia {
id: string;
caption: string;
filename: string;
sha256: string;
mime_type: string;
}
interface StickerMessage extends MessageBase {
type: 'sticker';
sticker: StickerMedia;
}
interface StickerMedia {
id: string;
mime_type: string;
sha256: string;
animated: boolean;
}
interface MessageValue {
contacts: Contact[];
messages: Message[];
}
interface Contact {
profile: Profile;
wa_id: string;
}
interface Profile {
name: string;
}
type Message = TextMessage | InteractiveMessage | ReactionMessage | MediaMessage | ButtonMessage;
interface MessageBase {
from: string;
id: string;
timestamp: string;
context?: MessageContext;
errors?: Error[];
}
interface MessageContext {
id: string;
from: string;
forwarded: boolean;
frequently_forwarded: boolean;
referred_product: ReferredProduct;
}
interface ReferredProduct {
catalog_id: string;
product_retailer_id: string;
}
interface TextMessage extends MessageBase {
type: 'text';
text: Text;
}
interface Text {
body: string;
}
interface ReactionMessage extends MessageBase {
type: 'reaction';
reaction: Reaction;
}
interface Reaction {
message_id: string;
emoji: string;
}
interface InteractiveMessage extends MessageBase {
type: 'interactive';
interactive: InteractiveButton | InteractiveList | InteractiveFlow;
}
interface InteractiveButton {
type: 'button_reply';
button_reply: ButtonReply;
}
interface ButtonReply {
id: string;
title: string;
}
interface InteractiveList {
type: 'list_reply';
list_reply: ListRowReply;
}
interface ListRowReply {
id: string;
title: string;
description: string;
}
interface InteractiveFlow {
type: 'nfm_reply';
nfm_reply: {
response_json: string;
body: 'Sent';
name: 'flow';
};
}
interface ButtonMessage extends MessageBase {
type: 'button';
button: ButtonContent;
}
interface ButtonContent {
payload: string;
text: string;
}
interface StatusValue {
statuses: Status[];
}
type Status = SentStatus | DeliveredStatus | ReadStatus | FailedStatus;
interface StatusBase {
id: string;
timestamp: string;
recipient_id: string;
}
interface SentStatus extends StatusBase {
status: MessageStatus.Sent;
conversation: Conversation;
pricing: Pricing;
}
interface DeliveredStatus extends StatusBase {
status: MessageStatus.Delivered;
conversation: Conversation;
pricing: Pricing;
}
interface ReadStatus extends StatusBase {
status: MessageStatus.Read;
}
interface FailedStatus extends StatusBase {
status: MessageStatus.Failed;
errors: Error[];
}
interface Conversation {
id: string;
expiration_timestamp: string;
origin: ConversationOrigin;
}
type ConversationCategory = 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
interface ConversationOrigin {
type: ConversationCategory;
}
interface Pricing {
pricing_model: 'CBP';
category: ConversationCategory;
}
interface WebhookSubscribeQuery {
'hub.mode': 'subscribe';
'hub.challenge': string;
'hub.verify_token': string;
}
interface WsRequest {
object: 'whatsapp_business_account';
entry: Entry[];
}
interface Entry {
id: string;
changes: Change[];
}
interface Change {
value: Value;
field: 'messages';
}
type Value = ValueBase & (StatusValue | MessageValue);
interface ValueBase {
messaging_product: 'whatsapp';
metadata: Metadata;
}
interface Metadata {
display_phone_number: string;
phone_number_id: string;
}
interface Error$1 {
code: number;
title: string;
message: string;
error_data: ErrorData;
}
interface ErrorData {
details: string;
}
export type { AudioMessage as A, ButtonReply as B, Change as C, DocumentMessage as D, Entry as E, Status as F, StatusBase as G, SentStatus as H, ImageMessage as I, DeliveredStatus as J, ReadStatus as K, ListRowReply as L, Metadata as M, FailedStatus as N, Conversation as O, Profile as P, ConversationCategory as Q, ReferredProduct as R, StickerMessage as S, TextMessage as T, ConversationOrigin as U, Value as V, WebhookSubscribeQuery as W, Pricing as X, WsRequest as a, ValueBase as b, Error$1 as c, ErrorData as d, MediaMessage as e, ImageMedia as f, VideoMessage as g, VideoMedia as h, AudioMedia as i, DocumentMedia as j, StickerMedia as k, MessageValue as l, Contact as m, Message as n, MessageBase as o, MessageContext as p, Text as q, ReactionMessage as r, Reaction as s, InteractiveMessage as t, InteractiveButton as u, InteractiveList as v, InteractiveFlow as w, ButtonMessage as x, ButtonContent as y, StatusValue as z };