UNPKG

evolution-api-sdk

Version:

Unofficial SDK for the Evolution Whatsapp API v2

1 lines 13.8 kB
{"version":3,"sources":["../../../src/api/routes.ts","../../../src/modules/messages/index.ts"],"sourcesContent":["export const Routes = {\n Message: {\n SendText: \"message/sendText\",\n SendMedia: \"message/sendMedia\",\n SendVoice: \"message/sendWhatsAppAudio\",\n SendSticker: \"message/sendSticker\",\n SendLocation: \"message/sendLocation\",\n SendContact: \"message/sendContact\",\n SendPoll: \"message/sendPoll\",\n SendReaction: \"message/sendReaction\",\n SendTemplate: \"message/sendTemplate\",\n SendStatus: \"message/sendStatus\",\n SendList: \"message/sendList\",\n },\n Chats: {\n Check: \"chat/whatsappNumbers\",\n FindAll: \"chat/findChats\",\n SendPresence: \"chat/sendPresence\",\n MarkAsRead: \"chat/markMessageAsRead\",\n MarkAsUnread: \"chat/markChatUnread\",\n Archive: \"chat/archive\",\n DeleteMessage: \"chat/deleteMessageForEveryone\",\n FetchProfilePicture: \"chat/fetchProfilePictureUrl\",\n FindContacts: \"chat/findContacts\",\n FindMessages: \"chat/findMessages\",\n FindStatusMessage: \"chat/findStatusMessage\",\n UpdateMessage: \"chat/updateMessage\",\n },\n Groups: {\n FindAll: \"group/fetchAllGroups\",\n FindByJid: \"group/findGroupInfos\",\n FindByInviteCode: \"group/inviteInfo\",\n Create: \"group/create\",\n UpdatePicture: \"group/updateGroupPicture\",\n UpdateSubject: \"group/updateGroupSubject\",\n UpdateDescription: \"group/updateGroupDescription\",\n FetchInviteCode: \"group/fetchInviteCode\",\n AcceptInviteCode: \"group/acceptInviteCode\",\n RevokeInviteCode: \"group/revokeInviteCode\",\n SendGroupInvite: \"group/sendGroupInvite\",\n FindMembers: \"group/findGroupMembers\",\n UpdateMembers: \"group/updateGroupMembers\",\n UpdateSetting: \"group/updateGroupSetting\",\n ToggleEphemeral: \"group/toggleEphemeral\",\n Leave: \"group/leaveGroup\",\n },\n Profile: {\n FetchBusinessProfile: \"chat/fetchBusinessProfile\",\n FetchProfile: \"chat/fetchProfile\",\n UpdateName: \"chat/updateProfileName\",\n UpdateStatus: \"chat/updateProfileStatus\",\n UpdatePicture: \"chat/updateProfilePicture\",\n RemovePicture: \"chat/removeProfilePicture\",\n FetchPrivacySettings: \"chat/fetchPrivacySettings\",\n UpdatePrivacySettings: \"chat/updatePrivacySettings\",\n },\n Webhook: {\n Set: \"webhook/set\",\n Find: \"webhook/find\",\n },\n Settings: {\n Set: \"settings/set\",\n Find: \"settings/find\",\n },\n Instance: {\n Create: \"instance/create\",\n FetchAll: \"instance/fetchInstances\",\n Connect: \"instance/connect\",\n Restart: \"instance/restart\",\n ConnectionState: \"instance/connectionState\",\n Logout: \"instance/logout\",\n Delete: \"instance/delete\",\n SetPresence: \"instance/setPresence\",\n },\n};\n","import { Routes } from \"@/api/routes\";\nimport type { ApiService } from \"@/api/service\";\nimport type { MethodOptions } from \"@/types/api\";\n\nimport type * as Audio from \"./schemas/audio\";\nimport type * as Contact from \"./schemas/contact\";\nimport type * as Document from \"./schemas/document\";\nimport type * as Image from \"./schemas/image\";\nimport type * as List from \"./schemas/list\";\nimport type * as Location from \"./schemas/location\";\nimport type * as Reaction from \"./schemas/reaction\";\nimport type * as Status from \"./schemas/status\";\nimport type * as Sticker from \"./schemas/sticker\";\nimport type * as Template from \"./schemas/template\";\nimport type * as Text from \"./schemas/text\";\nimport type * as Video from \"./schemas/video\";\nimport type * as Voice from \"./schemas/voice\";\n\nexport class MessagesModule {\n constructor(private readonly api: ApiService) {}\n\n /**\n * Sends a text message\n * @param options - Text message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendText(\n options: Text.TextMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Text.TextMessageResponse> {\n const response = await this.api.post(Routes.Message.SendText, {\n body: options,\n ...methodOptions,\n });\n\n return response as Text.TextMessageResponse;\n }\n\n /**\n * Sends an image\n * @param options - Image message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendImage(\n options: Image.ImageMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Image.ImageMessageResponse> {\n options.mediatype = \"image\";\n const response = await this.api.post(Routes.Message.SendMedia, {\n body: options,\n ...methodOptions,\n });\n\n return response as Image.ImageMessageResponse;\n }\n\n /**\n * Sends a video\n * @param options - Video message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendVideo(\n options: Video.VideoMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Video.VideoMessageResponse> {\n options.mediatype = \"video\";\n const response = await this.api.post(Routes.Message.SendMedia, {\n body: options,\n ...methodOptions,\n });\n\n return response as Video.VideoMessageResponse;\n }\n\n /**\n * Sends a document\n * @param options - Document message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendDocument(\n options: Document.DocumentMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Document.DocumentMessageResponse> {\n options.mediatype = \"document\";\n const response = await this.api.post(Routes.Message.SendMedia, {\n body: options,\n ...methodOptions,\n });\n\n return response as Document.DocumentMessageResponse;\n }\n\n /**\n * Sends an audio\n * @param options - Audio message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendAudio(\n options: Audio.AudioMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Audio.AudioMessageResponse> {\n options.mediatype = \"audio\";\n const response = await this.api.post(Routes.Message.SendMedia, {\n body: options,\n ...methodOptions,\n });\n\n return response as Audio.AudioMessageResponse;\n }\n\n /**\n * Sends a voice message\n * @param options - Voice message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendVoice(\n options: Voice.VoiceMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Voice.VoiceMessageResponse> {\n const response = await this.api.post(Routes.Message.SendVoice, {\n body: options,\n ...methodOptions,\n });\n\n return response as Voice.VoiceMessageResponse;\n }\n\n /**\n * Sends a sticker\n * @param options - Sticker message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendSticker(\n options: Sticker.StickerMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Sticker.StickerMessageResponse> {\n const response = await this.api.post(Routes.Message.SendSticker, {\n body: options,\n ...methodOptions,\n });\n\n return response as Sticker.StickerMessageResponse;\n }\n\n /**\n * Sends a location\n * @param options - Location message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendLocation(\n options: Location.LocationMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Location.LocationMessageResponse> {\n const response = await this.api.post(Routes.Message.SendLocation, {\n body: options,\n ...methodOptions,\n });\n\n return response as Location.LocationMessageResponse;\n }\n\n /**\n * Sends a contact\n * @param options - Contact message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendContact(\n options: Contact.ContactMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Contact.ContactMessageResponse> {\n const response = await this.api.post(Routes.Message.SendContact, {\n body: options,\n ...methodOptions,\n });\n\n return response as Contact.ContactMessageResponse;\n }\n\n /**\n * Sends a reaction\n * @param options - Reaction message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendReaction(\n options: Reaction.ReactionMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Reaction.ReactionMessageResponse> {\n const response = await this.api.post(Routes.Message.SendReaction, {\n body: options,\n ...methodOptions,\n });\n\n return response as Reaction.ReactionMessageResponse;\n }\n\n /**\n * Sends a template\n * @param options - Template message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendTemplate(\n options: Template.TemplateMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Template.TemplateMessageResponse> {\n const response = await this.api.post(Routes.Message.SendTemplate, {\n body: options,\n ...methodOptions,\n });\n\n return response as Template.TemplateMessageResponse;\n }\n\n /**\n * Sends a status\n * @param options - Status message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendStatus(\n options: Status.StatusMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<Status.StatusMessageResponse> {\n const response = await this.api.post(Routes.Message.SendStatus, {\n body: options,\n ...methodOptions,\n });\n\n return response as Status.StatusMessageResponse;\n }\n\n /**\n * Sends a list\n * @param options - List message options\n * @param methodOptions - Method-specific options (instance override)\n */\n async sendList(\n options: List.ListMessageOptions,\n methodOptions?: MethodOptions\n ): Promise<List.ListMessageResponse> {\n const response = await this.api.post(Routes.Message.SendList, {\n body: options,\n ...methodOptions,\n });\n\n return response as List.ListMessageResponse;\n }\n}\n"],"mappings":";AAAO,IAAM,SAAS;AAAA,EACpB,SAAS;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,aAAa;AAAA,IACb,UAAU;AAAA,IACV,cAAc;AAAA,IACd,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,SAAS;AAAA,IACT,eAAe;AAAA,IACf,qBAAqB;AAAA,IACrB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,eAAe;AAAA,EACjB;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,eAAe;AAAA,IACf,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,OAAO;AAAA,EACT;AAAA,EACA,SAAS;AAAA,IACP,sBAAsB;AAAA,IACtB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,eAAe;AAAA,IACf,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,uBAAuB;AAAA,EACzB;AAAA,EACA,SAAS;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,UAAU;AAAA,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