UNPKG

kufuli-whatsapp

Version:

Official Kufuli whatsapp API package

241 lines (234 loc) 5.46 kB
type ContactData = { pkId: number; sessionId: string; id: string; name: string; notify: string | null; verifiedName: string | null; imgUrl: string | null; status: string | null; }; type ContactsType = { data: ContactData[]; cursor: number; }; interface IContact { getContacts(sessionId: string, cursor?: number, limit?: number, search?: string): Promise<ContactsType>; getBlockList(sessionId: string): Promise<string[]>; updateBlockList(sessionId: string, data: { jid: string; action: "block" | "unblock"; }): Promise<{ message: string; }>; check(sessionId: string, jid: string): Promise<{ exist: boolean; }>; photo(sessionId: string, jid: string): Promise<{ url: boolean; }>; } type environmentType = "test" | "live"; interface IKufuliWhatsappApi { } type MessageData = { sessionId: string; message: string | null; pkId: number; remoteJid: string; id: string; agentId: string | null; bizPrivacyStatus: number; reportingTokenInfo: string | null; }; type MessagesType = { data: MessageData[]; cursor: number; }; declare enum FontType$1 { CALISTOGA_REGULAR = 8, COURIERPRIME_BOLD = 10, EXO2_EXTRABOLD = 9, FB_SCRIPT = 2, MORNINGBREEZE_REGULAR = 7, SYSTEM = 0, SYSTEM_BOLD = 6, SYSTEM_TEXT = 1 } type messageType = "group" | "number"; type SendTextMessage = { jid: string; type: messageType; message: { text: string; }; }; type SendImageMessage = { jid: string; type: messageType; message: { image: { url: string; }; caption?: string; }; }; type SendVideoMessage = { jid: string; type: messageType; message: { video: { url: string; }; caption?: string; gifPlayback?: boolean; ptv?: boolean; }; }; type SendAudioMessage = { jid: string; type: messageType; message: { audio: { url: string; }; ptt?: boolean; }; }; type SendDocumentMessage = { jid: string; type: messageType; message: { document: { url: string; }; }; options: { mimetype: string; }; }; interface IMessage { getMessages(sessionId: string, cursor?: number, limit?: number, search?: string): Promise<MessagesType>; sendTextMessage(sessionId: string, { jid, type, message }: SendTextMessage): Promise<{ message: string; }>; sendImageMessage(sessionId: string, data: SendImageMessage): Promise<{ message: string; }>; sendVideoMessage(sessionId: string, data: SendVideoMessage): Promise<{ message: string; }>; sendAudioMessage(sessionId: string, data: SendAudioMessage): Promise<{ message: string; }>; sendDocumentMessage(sessionId: string, data: SendDocumentMessage): Promise<{ message: string; }>; } type connectType = "qr" | "phoneNumber"; type connectResponseType = { data: { qr: string; }; } | { data: { code: string; }; } | { error: string; }; interface ISession { connect(id: string, type: connectType, phoneNumber?: string): Promise<connectResponseType>; connectSSE(id: string, type: connectType): Promise<connectResponseType>; getSession(sessionId: string): Promise<{ message: string; }>; deleteSession(sessionId: string): Promise<void>; getSessionStatus(sessionId: string): Promise<{ status: string; }>; getSessions(): Promise<{ id: string; status: string; }[]>; } declare enum FontType { CALISTOGA_REGULAR = 8, COURIERPRIME_BOLD = 10, EXO2_EXTRABOLD = 9, FB_SCRIPT = 2, MORNINGBREEZE_REGULAR = 7, SYSTEM = 0, SYSTEM_BOLD = 6, SYSTEM_TEXT = 1 } type SendTextStoryData = { message: { text: string; }; options: { contactList: string[]; font: FontType; backgroundColor: string; }; }; type SendImageStoryData = { message: { image: { url: string; }; caption?: string; }; options: { contactList: string[]; }; }; type SendVideoStoryData = { message: { video: { url: string; }; caption?: string; }; options: { contactList: string[]; }; }; type SendAudioStoryData = { message: { audio: { url: string; }; }; options: { contactList: string[]; backgroundColor?: string; }; }; interface IStory { sendTextStory(sessionId: string, data: SendTextStoryData): Promise<{ story: string; }>; sendImageStory(sessionId: string, data: SendImageStoryData): Promise<{ story: string; }>; sendVideoStory(sessionId: string, data: SendVideoStoryData): Promise<{ story: string; }>; sendAudioStory(sessionId: string, data: SendAudioStoryData): Promise<{ story: string; }>; } declare class KufuliWhatsappApi implements IKufuliWhatsappApi { private apiKey; private apiSecret; private environment; private axiosClient; FontType: typeof FontType$1; session: ISession; contact: IContact; message: IMessage; story: IStory; constructor(apiKey: string, apiSecret: string, environment: environmentType); } export { KufuliWhatsappApi };