evolution-api-sdk
Version:
Unofficial SDK for the Evolution Whatsapp API v2
212 lines (211 loc) • 6.31 kB
JavaScript
// 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/groups/index.ts
var GroupsModule = class {
constructor(api) {
this.api = api;
}
async findAll(getParticipants = false, methodOptions) {
const response = await this.api.get(Routes.Groups.FindAll, {
params: { getParticipants },
...methodOptions
});
if (getParticipants) {
return response;
}
return response;
}
/**
* Gets a group by invite code
* @param inviteCode - The group invite code (not the URL)
* @param methodOptions - Method-specific options (instance override)
*/
async findByInviteCode(inviteCode, methodOptions) {
const response = await this.api.get(Routes.Groups.FindByInviteCode, {
params: { inviteCode },
...methodOptions
});
return response;
}
/**
* Gets a group by JID
* @param groupJid - The group JID terminated with \@g.us
* @param methodOptions - Method-specific options (instance override)
*/
async findByJid(groupJid, methodOptions) {
const response = await this.api.get(Routes.Groups.FindByJid, {
params: { groupJid },
...methodOptions
});
return response;
}
async create(options, methodOptions) {
const response = await this.api.post(Routes.Groups.Create, {
body: options,
...methodOptions
});
return response;
}
async updatePicture(options, methodOptions) {
const response = await this.api.post(Routes.Groups.UpdatePicture, {
body: options,
...methodOptions
});
return response;
}
async updateSubject(options, methodOptions) {
const response = await this.api.post(Routes.Groups.UpdateSubject, {
body: options,
...methodOptions
});
return response;
}
async updateDescription(options, methodOptions) {
const response = await this.api.post(Routes.Groups.UpdateDescription, {
body: options,
...methodOptions
});
return response;
}
async fetchInviteCode(options, methodOptions) {
const response = await this.api.get(Routes.Groups.FetchInviteCode, {
params: options,
...methodOptions
});
return response;
}
async acceptInviteCode(options, methodOptions) {
const response = await this.api.post(Routes.Groups.AcceptInviteCode, {
body: options,
...methodOptions
});
return response;
}
async revokeInviteCode(options, methodOptions) {
const response = await this.api.post(Routes.Groups.RevokeInviteCode, {
body: options,
...methodOptions
});
return response;
}
async sendGroupInvite(options, methodOptions) {
const response = await this.api.post(Routes.Groups.SendGroupInvite, {
body: options,
...methodOptions
});
return response;
}
async findMembers(options, methodOptions) {
const response = await this.api.get(Routes.Groups.FindMembers, {
params: options,
...methodOptions
});
return response;
}
async updateMembers(options, methodOptions) {
const response = await this.api.post(Routes.Groups.UpdateMembers, {
body: options,
...methodOptions
});
return response;
}
async updateSetting(options, methodOptions) {
const response = await this.api.post(Routes.Groups.UpdateSetting, {
body: options,
...methodOptions
});
return response;
}
async toggleEphemeral(options, methodOptions) {
const response = await this.api.post(Routes.Groups.ToggleEphemeral, {
body: options,
...methodOptions
});
return response;
}
async leave(options, methodOptions) {
const response = await this.api.post(Routes.Groups.Leave, {
body: options,
...methodOptions
});
return response;
}
};
export {
GroupsModule
};
//# sourceMappingURL=index.mjs.map