UNPKG

evolution-api-sdk

Version:

Unofficial SDK for the Evolution Whatsapp API v2

273 lines (270 loc) 8.37 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/modules/messages/index.ts var messages_exports = {}; __export(messages_exports, { MessagesModule: () => MessagesModule }); module.exports = __toCommonJS(messages_exports); // src/api/routes.ts var Routes = { Message: { SendText: "message/sendText", SendMedia: "message/sendMedia", SendVoice: "message/sendWhatsAppAudio", SendSticker: "message/sendSticker", SendLocation: "message/sendLocation", SendContact: "message/sendContact", SendPoll: "message/sendPoll", SendReaction: "message/sendReaction", SendTemplate: "message/sendTemplate", SendStatus: "message/sendStatus", SendList: "message/sendList" }, Chats: { Check: "chat/whatsappNumbers", FindAll: "chat/findChats", SendPresence: "chat/sendPresence", MarkAsRead: "chat/markMessageAsRead", MarkAsUnread: "chat/markChatUnread", Archive: "chat/archive", DeleteMessage: "chat/deleteMessageForEveryone", FetchProfilePicture: "chat/fetchProfilePictureUrl", FindContacts: "chat/findContacts", FindMessages: "chat/findMessages", FindStatusMessage: "chat/findStatusMessage", UpdateMessage: "chat/updateMessage" }, Groups: { FindAll: "group/fetchAllGroups", FindByJid: "group/findGroupInfos", FindByInviteCode: "group/inviteInfo", Create: "group/create", UpdatePicture: "group/updateGroupPicture", UpdateSubject: "group/updateGroupSubject", UpdateDescription: "group/updateGroupDescription", FetchInviteCode: "group/fetchInviteCode", AcceptInviteCode: "group/acceptInviteCode", RevokeInviteCode: "group/revokeInviteCode", SendGroupInvite: "group/sendGroupInvite", FindMembers: "group/findGroupMembers", UpdateMembers: "group/updateGroupMembers", UpdateSetting: "group/updateGroupSetting", ToggleEphemeral: "group/toggleEphemeral", Leave: "group/leaveGroup" }, Profile: { FetchBusinessProfile: "chat/fetchBusinessProfile", FetchProfile: "chat/fetchProfile", UpdateName: "chat/updateProfileName", UpdateStatus: "chat/updateProfileStatus", UpdatePicture: "chat/updateProfilePicture", RemovePicture: "chat/removeProfilePicture", FetchPrivacySettings: "chat/fetchPrivacySettings", UpdatePrivacySettings: "chat/updatePrivacySettings" }, Webhook: { Set: "webhook/set", Find: "webhook/find" }, Settings: { Set: "settings/set", Find: "settings/find" }, Instance: { Create: "instance/create", FetchAll: "instance/fetchInstances", Connect: "instance/connect", Restart: "instance/restart", ConnectionState: "instance/connectionState", Logout: "instance/logout", Delete: "instance/delete", SetPresence: "instance/setPresence" } }; // src/modules/messages/index.ts var MessagesModule = class { constructor(api) { this.api = api; } /** * Sends a text message * @param options - Text message options * @param methodOptions - Method-specific options (instance override) */ async sendText(options, methodOptions) { const response = await this.api.post(Routes.Message.SendText, { body: options, ...methodOptions }); return response; } /** * Sends an image * @param options - Image message options * @param methodOptions - Method-specific options (instance override) */ async sendImage(options, methodOptions) { options.mediatype = "image"; const response = await this.api.post(Routes.Message.SendMedia, { body: options, ...methodOptions }); return response; } /** * Sends a video * @param options - Video message options * @param methodOptions - Method-specific options (instance override) */ async sendVideo(options, methodOptions) { options.mediatype = "video"; const response = await this.api.post(Routes.Message.SendMedia, { body: options, ...methodOptions }); return response; } /** * Sends a document * @param options - Document message options * @param methodOptions - Method-specific options (instance override) */ async sendDocument(options, methodOptions) { options.mediatype = "document"; const response = await this.api.post(Routes.Message.SendMedia, { body: options, ...methodOptions }); return response; } /** * Sends an audio * @param options - Audio message options * @param methodOptions - Method-specific options (instance override) */ async sendAudio(options, methodOptions) { options.mediatype = "audio"; const response = await this.api.post(Routes.Message.SendMedia, { body: options, ...methodOptions }); return response; } /** * Sends a voice message * @param options - Voice message options * @param methodOptions - Method-specific options (instance override) */ async sendVoice(options, methodOptions) { const response = await this.api.post(Routes.Message.SendVoice, { body: options, ...methodOptions }); return response; } /** * Sends a sticker * @param options - Sticker message options * @param methodOptions - Method-specific options (instance override) */ async sendSticker(options, methodOptions) { const response = await this.api.post(Routes.Message.SendSticker, { body: options, ...methodOptions }); return response; } /** * Sends a location * @param options - Location message options * @param methodOptions - Method-specific options (instance override) */ async sendLocation(options, methodOptions) { const response = await this.api.post(Routes.Message.SendLocation, { body: options, ...methodOptions }); return response; } /** * Sends a contact * @param options - Contact message options * @param methodOptions - Method-specific options (instance override) */ async sendContact(options, methodOptions) { const response = await this.api.post(Routes.Message.SendContact, { body: options, ...methodOptions }); return response; } /** * Sends a reaction * @param options - Reaction message options * @param methodOptions - Method-specific options (instance override) */ async sendReaction(options, methodOptions) { const response = await this.api.post(Routes.Message.SendReaction, { body: options, ...methodOptions }); return response; } /** * Sends a template * @param options - Template message options * @param methodOptions - Method-specific options (instance override) */ async sendTemplate(options, methodOptions) { const response = await this.api.post(Routes.Message.SendTemplate, { body: options, ...methodOptions }); return response; } /** * Sends a status * @param options - Status message options * @param methodOptions - Method-specific options (instance override) */ async sendStatus(options, methodOptions) { const response = await this.api.post(Routes.Message.SendStatus, { body: options, ...methodOptions }); return response; } /** * Sends a list * @param options - List message options * @param methodOptions - Method-specific options (instance override) */ async sendList(options, methodOptions) { const response = await this.api.post(Routes.Message.SendList, { body: options, ...methodOptions }); return response; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MessagesModule }); //# sourceMappingURL=index.js.map