@raphaelvserafim/client-api-whatsapp 1.0.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +512 -297
  2. package/dist/WhatsApp.d.ts +177 -33
  3. package/dist/WhatsApp.js +146 -167
  4. package/dist/WhatsApp.js.map +1 -1
  5. package/dist/client/HttpClient.d.ts +6 -0
  6. package/dist/client/HttpClient.js +29 -0
  7. package/dist/client/HttpClient.js.map +1 -0
  8. package/dist/client/IHttpClient.d.ts +9 -0
  9. package/dist/client/IHttpClient.js +3 -0
  10. package/dist/client/IHttpClient.js.map +1 -0
  11. package/dist/errors.d.ts +5 -0
  12. package/dist/errors.js +13 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +16 -1
  15. package/dist/index.js +37 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/services/ActionService.d.ts +9 -0
  18. package/dist/services/ActionService.js +32 -0
  19. package/dist/services/ActionService.js.map +1 -0
  20. package/dist/services/BusinessService.d.ts +10 -0
  21. package/dist/services/BusinessService.js +43 -0
  22. package/dist/services/BusinessService.js.map +1 -0
  23. package/dist/services/CallService.d.ts +10 -0
  24. package/dist/services/CallService.js +38 -0
  25. package/dist/services/CallService.js.map +1 -0
  26. package/dist/services/ChatService.d.ts +19 -0
  27. package/dist/services/ChatService.js +63 -0
  28. package/dist/services/ChatService.js.map +1 -0
  29. package/dist/services/CommunityService.d.ts +35 -0
  30. package/dist/services/CommunityService.js +125 -0
  31. package/dist/services/CommunityService.js.map +1 -0
  32. package/dist/services/ContactService.d.ts +21 -0
  33. package/dist/services/ContactService.js +68 -0
  34. package/dist/services/ContactService.js.map +1 -0
  35. package/dist/services/GroupService.d.ts +37 -0
  36. package/dist/services/GroupService.js +117 -0
  37. package/dist/services/GroupService.js.map +1 -0
  38. package/dist/services/InstanceService.d.ts +29 -0
  39. package/dist/services/InstanceService.js +130 -0
  40. package/dist/services/InstanceService.js.map +1 -0
  41. package/dist/services/LabelService.d.ts +18 -0
  42. package/dist/services/LabelService.js +49 -0
  43. package/dist/services/LabelService.js.map +1 -0
  44. package/dist/services/MessageService.d.ts +60 -0
  45. package/dist/services/MessageService.js +171 -0
  46. package/dist/services/MessageService.js.map +1 -0
  47. package/dist/services/NewsletterService.d.ts +23 -0
  48. package/dist/services/NewsletterService.js +129 -0
  49. package/dist/services/NewsletterService.js.map +1 -0
  50. package/dist/services/StatusService.d.ts +14 -0
  51. package/dist/services/StatusService.js +46 -0
  52. package/dist/services/StatusService.js.map +1 -0
  53. package/dist/types/index.d.ts +206 -11
  54. package/dist/types/index.js +12 -0
  55. package/dist/types/index.js.map +1 -1
  56. package/package.json +6 -11
  57. package/.babelrc +0 -3
  58. package/dist/exemple.d.ts +0 -1
  59. package/dist/exemple.js +0 -264
  60. package/dist/exemple.js.map +0 -1
  61. package/src/WhatsApp.ts +0 -245
  62. package/src/exemple.ts +0 -312
  63. package/src/index.ts +0 -2
  64. package/src/types/index.ts +0 -190
  65. package/tsconfig.compile.json +0 -15
  66. package/tsconfig.json +0 -35
@@ -1,33 +1,61 @@
1
- import { Init, WebhookBody, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot, Connect, Location, Buttons, Items } from './types';
1
+ import { Init, WebhookBody, TypeMessage, StatusPresence, Contact, Section, Location, Buttons, Items, HeaderMedia, DownloadableMessage, Product, CommunityCreate, CommunityUpdate, GroupParticipantsAction, ApiResponse, PairingCodeResponse, MobileRegisterData, EventData, InfoInstance, SendMessageRoot, Connect, RegisteredResponse, ContactInfo, GroupInfo, InviteCodeResponse, ChatInfo, LabelInfo, CommunityInfo, CatalogResponse, WebhookStatistics, ListMessagesResponse, DownloadMediaResponse, CallResponse, MessageData, GroupParticipant, LiveLocationData, SendContactsData, ProductMessageData, GroupInviteMessageData, CommunityGroupCreate } from './types';
2
+ import { IHttpClient } from './client/IHttpClient';
3
+ import { InstanceService } from './services/InstanceService';
4
+ import { MessageService } from './services/MessageService';
5
+ import { ChatService } from './services/ChatService';
6
+ import { CallService } from './services/CallService';
7
+ import { LabelService } from './services/LabelService';
8
+ import { ActionService } from './services/ActionService';
9
+ import { ContactService } from './services/ContactService';
10
+ import { GroupService } from './services/GroupService';
11
+ import { CommunityService } from './services/CommunityService';
12
+ import { BusinessService } from './services/BusinessService';
13
+ import { NewsletterService } from './services/NewsletterService';
14
+ import { StatusService } from './services/StatusService';
2
15
  export declare class WhatsApp {
3
- private readonly server;
4
- private readonly key;
5
- private route;
6
- private method;
7
- private body;
8
- constructor(data: Init);
9
- private request;
16
+ readonly instance: InstanceService;
17
+ readonly message: MessageService;
18
+ readonly chat: ChatService;
19
+ readonly call: CallService;
20
+ readonly label: LabelService;
21
+ readonly action: ActionService;
22
+ readonly contact: ContactService;
23
+ readonly group: GroupService;
24
+ readonly community: CommunityService;
25
+ readonly business: BusinessService;
26
+ readonly newsletter: NewsletterService;
27
+ readonly status: StatusService;
28
+ constructor(data: Init, httpClient?: IHttpClient);
10
29
  connect(): Promise<Connect>;
11
30
  info(): Promise<InfoInstance>;
12
- logout(): Promise<any>;
13
- setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }: {
31
+ logout(): Promise<ApiResponse>;
32
+ setting(data: {
14
33
  markMessageRead: boolean;
34
+ saveMedia: boolean;
15
35
  receiveStatusMessage: boolean;
16
36
  receivePresence: boolean;
17
- saveMedia: boolean;
18
- }): Promise<{
19
- status: number;
20
- message: string;
21
- }>;
22
- updateWebhook(body: WebhookBody): Promise<any>;
37
+ }): Promise<ApiResponse>;
38
+ updateWebhook(body: WebhookBody): Promise<ApiResponse>;
39
+ pairingCode(phoneNumber: string): Promise<PairingCodeResponse>;
40
+ addMongoDb(uri: string, dbName: string): Promise<ApiResponse>;
41
+ setProxy(proxy: string): Promise<ApiResponse>;
42
+ resync(): Promise<ApiResponse>;
43
+ restart(): Promise<ApiResponse>;
44
+ updateProfileStatus(text: string): Promise<ApiResponse>;
45
+ updateProfilePicture(url: string): Promise<ApiResponse>;
46
+ removeProfilePicture(): Promise<ApiResponse>;
47
+ updateProfileName(name: string): Promise<ApiResponse>;
48
+ mobileRegisterPrepare(data: MobileRegisterData): Promise<ApiResponse>;
49
+ mobileRequestCode(method: string): Promise<ApiResponse>;
50
+ mobileVerifyCode(code: string): Promise<ApiResponse>;
51
+ webhookStatistics(): Promise<WebhookStatistics>;
52
+ listMessages(phoneNumber: string, page?: number, limit?: number): Promise<ListMessagesResponse>;
23
53
  sendMessage(data: {
24
54
  type: TypeMessage;
25
55
  body: {
26
56
  to: string;
27
57
  msgId?: string;
28
- header?: {
29
- title?: string;
30
- };
58
+ header?: HeaderMedia;
31
59
  status?: StatusPresence;
32
60
  text?: string;
33
61
  url?: string;
@@ -56,19 +84,135 @@ export declare class WhatsApp {
56
84
  items?: Items[];
57
85
  };
58
86
  }, reply?: boolean): Promise<SendMessageRoot>;
59
- forwardingMessage(to: string, msgId: string): Promise<any>;
60
- rejectCall(id: string, from: string): Promise<any>;
61
- pairingCode(phoneNumber: string): Promise<any>;
62
- checkRegisteredWhatsapp(number: string): Promise<any>;
63
- contacts(): Promise<any>;
64
- contactProfile(id: string): Promise<any>;
65
- groups(): Promise<any>;
66
- infoGroup(id: string): Promise<any>;
67
- getInviteGroup(id: string): Promise<any>;
68
- updateGroup(id: string, name: string, description: string): Promise<any>;
69
- updateGroupPicture(id: string, url: string): Promise<any>;
70
- leaveGroup(id: string): Promise<any>;
71
- createGroup(name: string, participants: string[]): Promise<any>;
72
- addParticipantsGroup(id: string, participants: string[]): Promise<any>;
87
+ forwardingMessage(to: string, msgId: string): Promise<SendMessageRoot>;
88
+ sendSticker(to: string, url: string): Promise<SendMessageRoot>;
89
+ sendVideoNote(to: string, url: string): Promise<SendMessageRoot>;
90
+ sendPoll(to: string, name: string, values: Array<string | number | boolean>, selectableCount?: number): Promise<SendMessageRoot>;
91
+ sendEvent(data: EventData): Promise<SendMessageRoot>;
92
+ pinMessage(id: string, duration?: number): Promise<ApiResponse>;
93
+ unpinMessage(id: string): Promise<ApiResponse>;
94
+ sendCallLink(to: string, type: string, caption?: string): Promise<SendMessageRoot>;
95
+ sendImageBase64(to: string, base64: string, caption?: string): Promise<SendMessageRoot>;
96
+ sendAudioBase64(to: string, base64: string): Promise<SendMessageRoot>;
97
+ sendDocumentBase64(to: string, base64: string, mimetype: string, fileName?: string, caption?: string): Promise<SendMessageRoot>;
98
+ sendContacts(data: SendContactsData): Promise<SendMessageRoot>;
99
+ sendLiveLocation(data: LiveLocationData): Promise<SendMessageRoot>;
100
+ getMessageDetails(messageId: string): Promise<ApiResponse>;
101
+ getMessageMedia(messageId: string, format?: string): Promise<ApiResponse>;
102
+ sendProduct(data: ProductMessageData): Promise<SendMessageRoot>;
103
+ sendGroupInvite(data: GroupInviteMessageData): Promise<SendMessageRoot>;
104
+ requestPhone(to: string): Promise<ApiResponse>;
105
+ createCallLink(type: string): Promise<ApiResponse>;
106
+ getChats(): Promise<{
107
+ status: number;
108
+ data: ChatInfo[];
109
+ }>;
110
+ modifyChat(id: string, action: 'markRead' | 'pin', value: boolean): Promise<ApiResponse>;
111
+ deleteChat(chatId: string): Promise<ApiResponse>;
112
+ getChatMessages(chatId: string, page?: number, limit?: number): Promise<{
113
+ status: number;
114
+ data: MessageData[];
115
+ }>;
116
+ presenceSubscribe(jid: string): Promise<ApiResponse>;
117
+ setDisappearing(jid: string, expiration: number): Promise<ApiResponse>;
118
+ getPrivacy(): Promise<ApiResponse>;
119
+ makeCall(to: string, isVideo?: boolean): Promise<CallResponse>;
120
+ rejectCall(id: string, from: string): Promise<ApiResponse>;
121
+ acceptCall(callId: string, callFrom: string): Promise<ApiResponse>;
122
+ endCall(callId: string, peerJid: string): Promise<ApiResponse>;
123
+ getLabels(): Promise<{
124
+ status: number;
125
+ data: LabelInfo[];
126
+ }>;
127
+ createLabel(name: string, labelId?: string): Promise<ApiResponse>;
128
+ getChatLabel(labelId: string): Promise<{
129
+ status: number;
130
+ data: ChatInfo[];
131
+ }>;
132
+ addChatLabel(labelId: string, to: string): Promise<ApiResponse>;
133
+ deleteLabel(labelId: string): Promise<ApiResponse>;
134
+ removeChatLabel(labelId: string, to: string): Promise<ApiResponse>;
135
+ checkRegisteredWhatsapp(number: string): Promise<RegisteredResponse>;
136
+ downloadMedia(type: 'image' | 'video' | 'sticker' | 'audio' | 'document', message: DownloadableMessage): Promise<DownloadMediaResponse>;
137
+ deleteStorage(): Promise<ApiResponse>;
138
+ contacts(): Promise<{
139
+ status: number;
140
+ data: ContactInfo[];
141
+ }>;
142
+ addContact(number: string, name: string): Promise<ApiResponse>;
143
+ contactProfile(id: string): Promise<{
144
+ status: number;
145
+ data: ContactInfo;
146
+ }>;
147
+ removeContact(number: string): Promise<ApiResponse>;
148
+ blockContact(number: string, action: 'block' | 'unblock'): Promise<ApiResponse>;
149
+ clearContactSession(number: string): Promise<ApiResponse>;
150
+ getContactStatus(number: string): Promise<ApiResponse>;
151
+ listBlockedContacts(): Promise<ApiResponse>;
152
+ resolveLids(lids: string[]): Promise<ApiResponse>;
153
+ groups(): Promise<{
154
+ status: number;
155
+ data: GroupInfo[];
156
+ }>;
157
+ infoGroup(id: string): Promise<{
158
+ status: number;
159
+ data: GroupInfo;
160
+ }>;
161
+ createGroup(name: string, participants: string[]): Promise<{
162
+ status: number;
163
+ data: GroupInfo;
164
+ }>;
165
+ updateGroup(id: string, name: string, description: string): Promise<ApiResponse>;
166
+ changeGroupSettings(id: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<ApiResponse>;
167
+ leaveGroup(id: string): Promise<ApiResponse>;
168
+ getGroupMembers(id: string): Promise<{
169
+ status: number;
170
+ data: GroupParticipant[];
171
+ }>;
172
+ getGroupInviteInfo(code: string): Promise<ApiResponse>;
173
+ getInviteGroup(id: string): Promise<InviteCodeResponse>;
174
+ updateGroupPicture(id: string, url: string): Promise<ApiResponse>;
175
+ removeGroupPicture(id: string): Promise<ApiResponse>;
176
+ addParticipantsGroup(id: string, participants: string[]): Promise<ApiResponse>;
177
+ removeParticipantsGroup(id: string, participants: string[]): Promise<ApiResponse>;
178
+ updateGroupParticipantRole(id: string, action: 'promote' | 'demote', participants: string[]): Promise<ApiResponse>;
179
+ getGroupRequestParticipants(id: string): Promise<{
180
+ status: number;
181
+ data: GroupParticipant[];
182
+ }>;
183
+ updateGroupRequestParticipants(id: string, data: GroupParticipantsAction): Promise<ApiResponse>;
184
+ listCommunities(): Promise<{
185
+ status: number;
186
+ data: CommunityInfo[];
187
+ }>;
188
+ createCommunity(data: CommunityCreate): Promise<{
189
+ status: number;
190
+ data: CommunityInfo;
191
+ }>;
192
+ infoCommunity(id: string): Promise<{
193
+ status: number;
194
+ data: CommunityInfo;
195
+ }>;
196
+ updateCommunity(id: string, data: CommunityUpdate): Promise<ApiResponse>;
197
+ leaveCommunity(id: string): Promise<ApiResponse>;
198
+ updateCommunityPicture(id: string, url: string): Promise<ApiResponse>;
199
+ getCommunityInviteCode(id: string): Promise<InviteCodeResponse>;
200
+ removeCommunityParticipants(id: string, participants: string[]): Promise<ApiResponse>;
201
+ getCommunityRequestParticipants(id: string): Promise<{
202
+ status: number;
203
+ data: GroupParticipant[];
204
+ }>;
205
+ updateCommunityRequestParticipants(id: string, data: GroupParticipantsAction): Promise<ApiResponse>;
206
+ acceptCommunityInvite(code: string): Promise<ApiResponse>;
207
+ getCommunityInviteInfo(code: string): Promise<ApiResponse>;
208
+ createCommunityGroup(id: string, data: CommunityGroupCreate): Promise<ApiResponse>;
209
+ setCommunityEphemeral(id: string, expiration: number): Promise<ApiResponse>;
210
+ updateCommunitySettings(id: string, setting: string): Promise<ApiResponse>;
211
+ setCommunityMemberAddMode(id: string, mode: string): Promise<ApiResponse>;
212
+ setCommunityJoinApproval(id: string, mode: string): Promise<ApiResponse>;
213
+ getCatalog(limit?: number, cursor?: string): Promise<CatalogResponse>;
214
+ createProduct(product: Product): Promise<ApiResponse>;
215
+ updateProduct(productId: string, product: Product): Promise<ApiResponse>;
216
+ deleteProduct(productId: string): Promise<ApiResponse>;
73
217
  }
74
218
  export default WhatsApp;
package/dist/WhatsApp.js CHANGED
@@ -1,174 +1,153 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhatsApp = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
- const types_1 = require("./types");
4
+ const HttpClient_1 = require("./client/HttpClient");
5
+ const InstanceService_1 = require("./services/InstanceService");
6
+ const MessageService_1 = require("./services/MessageService");
7
+ const ChatService_1 = require("./services/ChatService");
8
+ const CallService_1 = require("./services/CallService");
9
+ const LabelService_1 = require("./services/LabelService");
10
+ const ActionService_1 = require("./services/ActionService");
11
+ const ContactService_1 = require("./services/ContactService");
12
+ const GroupService_1 = require("./services/GroupService");
13
+ const CommunityService_1 = require("./services/CommunityService");
14
+ const BusinessService_1 = require("./services/BusinessService");
15
+ const NewsletterService_1 = require("./services/NewsletterService");
16
+ const StatusService_1 = require("./services/StatusService");
7
17
  class WhatsApp {
8
- server;
9
- key;
10
- route;
11
- method = null;
12
- body = null;
13
- constructor(data) {
14
- this.server = data.server;
15
- this.key = data.key;
16
- }
17
- async request() {
18
- if (!this.route || !this.method) {
19
- throw new Error('Path and method must be defined before making a request.');
20
- }
21
- const options = {
22
- url: `${this.server}/${this.key}/${this.route}`,
23
- method: this.method,
24
- headers: {
25
- 'Content-Type': 'application/json'
26
- }
27
- };
28
- if ((this.method === 'POST' || this.method === 'PUT') && this.body) {
29
- options.data = JSON.stringify(this.body);
30
- }
31
- try {
32
- const response = await (0, axios_1.default)(options);
33
- return response.data;
34
- }
35
- catch (error) {
36
- throw new Error(`HTTP Request Error: ${error.message} (status: ${error.response?.status})`);
37
- }
38
- }
39
- async connect() {
40
- this.route = types_1.Routes.INSTANCES;
41
- this.method = types_1.HttpMethod.POST;
42
- return await this.request();
43
- }
44
- async info() {
45
- this.route = types_1.Routes.INSTANCES;
46
- this.method = types_1.HttpMethod.GET;
47
- return await this.request();
48
- }
49
- async logout() {
50
- this.route = types_1.Routes.INSTANCES;
51
- this.method = types_1.HttpMethod.DELETE;
52
- return await this.request();
53
- }
54
- async setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }) {
55
- this.route = types_1.Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}&receivePresence=${receivePresence}`;
56
- this.method = types_1.HttpMethod.PATCH;
57
- return await this.request();
58
- }
59
- async updateWebhook(body) {
60
- this.route = types_1.Routes.INSTANCES;
61
- this.method = types_1.HttpMethod.PUT;
62
- this.body = body;
63
- return await this.request();
64
- }
65
- async sendMessage(data, reply = false) {
66
- if (data.type === types_1.TypeMessage.BUTTON_PIX) {
67
- const { key, keyType, merchantName, subtotal, totalAmount, items } = data.body;
68
- if (!key || !keyType || !merchantName || !subtotal || !totalAmount || !items || items.length === 0) {
69
- throw new Error("Campos obrigatórios para pagamento via PIX estão ausentes.");
70
- }
71
- }
72
- if (reply) {
73
- this.route = types_1.Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
74
- }
75
- else {
76
- this.route = types_1.Routes.MESSAGES + "/" + data.type;
77
- }
78
- this.method = types_1.HttpMethod.POST;
79
- this.body = data.body;
80
- return await this.request();
81
- }
82
- async forwardingMessage(to, msgId) {
83
- this.route = types_1.Routes.MESSAGES + "/" + msgId + "/forwarding";
84
- this.method = types_1.HttpMethod.POST;
85
- this.body = {
86
- to,
87
- };
88
- return await this.request();
89
- }
90
- async rejectCall(id, from) {
91
- this.route = types_1.Routes.CALL + `/${id}/${from}`;
92
- this.method = types_1.HttpMethod.DELETE;
93
- return await this.request();
94
- }
95
- async pairingCode(phoneNumber) {
96
- this.route = types_1.Routes.INSTANCES + "/pairing-code";
97
- this.body = {
98
- phoneNumber,
99
- };
100
- this.method = types_1.HttpMethod.POST;
101
- return await this.request();
102
- }
103
- async checkRegisteredWhatsapp(number) {
104
- this.route = types_1.Routes.ACTIONS + "/registered?number=" + number;
105
- this.method = types_1.HttpMethod.GET;
106
- return await this.request();
107
- }
108
- async contacts() {
109
- this.route = types_1.Routes.CONTACTS;
110
- this.method = types_1.HttpMethod.GET;
111
- return await this.request();
112
- }
113
- async contactProfile(id) {
114
- this.route = types_1.Routes.CONTACTS + "/" + id;
115
- this.method = types_1.HttpMethod.GET;
116
- return await this.request();
117
- }
118
- async groups() {
119
- this.route = types_1.Routes.GROUPS;
120
- this.method = types_1.HttpMethod.GET;
121
- return await this.request();
122
- }
123
- async infoGroup(id) {
124
- this.route = types_1.Routes.GROUPS + "/" + id;
125
- this.method = types_1.HttpMethod.GET;
126
- return await this.request();
127
- }
128
- async getInviteGroup(id) {
129
- this.route = types_1.Routes.GROUPS + "/" + id + "/invite";
130
- this.method = types_1.HttpMethod.GET;
131
- return await this.request();
132
- }
133
- async updateGroup(id, name, description) {
134
- this.route = types_1.Routes.GROUPS + "/" + id;
135
- this.method = types_1.HttpMethod.PUT;
136
- this.body = {
137
- name,
138
- description
139
- };
140
- return await this.request();
141
- }
142
- async updateGroupPicture(id, url) {
143
- this.route = types_1.Routes.GROUPS + "/" + id + "/picture";
144
- this.method = types_1.HttpMethod.PUT;
145
- this.body = {
146
- url
147
- };
148
- return await this.request();
149
- }
150
- async leaveGroup(id) {
151
- this.route = types_1.Routes.GROUPS + "/" + id;
152
- this.method = types_1.HttpMethod.DELETE;
153
- return await this.request();
154
- }
155
- async createGroup(name, participants) {
156
- this.route = types_1.Routes.GROUPS;
157
- this.method = types_1.HttpMethod.POST;
158
- this.body = {
159
- name,
160
- participants
161
- };
162
- return await this.request();
163
- }
164
- async addParticipantsGroup(id, participants) {
165
- this.route = types_1.Routes.GROUPS + "/" + id + "/participants";
166
- this.method = types_1.HttpMethod.POST;
167
- this.body = {
168
- participants
169
- };
170
- return await this.request();
171
- }
18
+ constructor(data, httpClient) {
19
+ const client = httpClient ?? new HttpClient_1.HttpClient(`${data.server}/${data.key}`);
20
+ this.instance = new InstanceService_1.InstanceService(client);
21
+ this.message = new MessageService_1.MessageService(client);
22
+ this.chat = new ChatService_1.ChatService(client);
23
+ this.call = new CallService_1.CallService(client);
24
+ this.label = new LabelService_1.LabelService(client);
25
+ this.action = new ActionService_1.ActionService(client);
26
+ this.contact = new ContactService_1.ContactService(client);
27
+ this.group = new GroupService_1.GroupService(client);
28
+ this.community = new CommunityService_1.CommunityService(client);
29
+ this.business = new BusinessService_1.BusinessService(client);
30
+ this.newsletter = new NewsletterService_1.NewsletterService(client);
31
+ this.status = new StatusService_1.StatusService(client);
32
+ }
33
+ // ==================== Backward Compatibility ====================
34
+ // These methods delegate to the corresponding services.
35
+ // Use wa.instance.*, wa.message.*, wa.group.*, etc. for the new API.
36
+ // Instance
37
+ connect() { return this.instance.connect(); }
38
+ info() { return this.instance.info(); }
39
+ logout() { return this.instance.logout(); }
40
+ setting(data) { return this.instance.setting(data); }
41
+ updateWebhook(body) { return this.instance.updateWebhook(body); }
42
+ pairingCode(phoneNumber) { return this.instance.pairingCode(phoneNumber); }
43
+ addMongoDb(uri, dbName) { return this.instance.addMongoDb(uri, dbName); }
44
+ setProxy(proxy) { return this.instance.setProxy(proxy); }
45
+ resync() { return this.instance.resync(); }
46
+ restart() { return this.instance.restart(); }
47
+ updateProfileStatus(text) { return this.instance.updateProfileStatus(text); }
48
+ updateProfilePicture(url) { return this.instance.updateProfilePicture(url); }
49
+ removeProfilePicture() { return this.instance.removeProfilePicture(); }
50
+ updateProfileName(name) { return this.instance.updateProfileName(name); }
51
+ mobileRegisterPrepare(data) { return this.instance.mobileRegisterPrepare(data); }
52
+ mobileRequestCode(method) { return this.instance.mobileRequestCode(method); }
53
+ mobileVerifyCode(code) { return this.instance.mobileVerifyCode(code); }
54
+ webhookStatistics() { return this.instance.webhookStatistics(); }
55
+ // Messages
56
+ listMessages(phoneNumber, page, limit) { return this.message.list(phoneNumber, page, limit); }
57
+ sendMessage(data, reply) { return this.message.send(data, reply); }
58
+ forwardingMessage(to, msgId) { return this.message.forward(to, msgId); }
59
+ sendSticker(to, url) { return this.message.sendSticker(to, url); }
60
+ sendVideoNote(to, url) { return this.message.sendVideoNote(to, url); }
61
+ sendPoll(to, name, values, selectableCount) { return this.message.sendPoll(to, name, values, selectableCount); }
62
+ sendEvent(data) { return this.message.sendEvent(data); }
63
+ pinMessage(id, duration) { return this.message.pin(id, duration); }
64
+ unpinMessage(id) { return this.message.unpin(id); }
65
+ sendCallLink(to, type, caption) { return this.message.sendCallLink(to, type, caption); }
66
+ sendImageBase64(to, base64, caption) { return this.message.sendImageBase64(to, base64, caption); }
67
+ sendAudioBase64(to, base64) { return this.message.sendAudioBase64(to, base64); }
68
+ sendDocumentBase64(to, base64, mimetype, fileName, caption) { return this.message.sendDocumentBase64(to, base64, mimetype, fileName, caption); }
69
+ sendContacts(data) { return this.message.sendContacts(data); }
70
+ sendLiveLocation(data) { return this.message.sendLiveLocation(data); }
71
+ getMessageDetails(messageId) { return this.message.getDetails(messageId); }
72
+ getMessageMedia(messageId, format) { return this.message.getMedia(messageId, format); }
73
+ sendProduct(data) { return this.message.sendProduct(data); }
74
+ sendGroupInvite(data) { return this.message.sendGroupInvite(data); }
75
+ requestPhone(to) { return this.message.requestPhone(to); }
76
+ createCallLink(type) { return this.message.createCallLink(type); }
77
+ // Chat
78
+ getChats() { return this.chat.list(); }
79
+ modifyChat(id, action, value) { return this.chat.modify(id, action, value); }
80
+ deleteChat(chatId) { return this.chat.delete(chatId); }
81
+ getChatMessages(chatId, page, limit) { return this.chat.messages(chatId, page, limit); }
82
+ presenceSubscribe(jid) { return this.chat.presenceSubscribe(jid); }
83
+ setDisappearing(jid, expiration) { return this.chat.disappearing(jid, expiration); }
84
+ getPrivacy() { return this.chat.privacy(); }
85
+ // Call
86
+ makeCall(to, isVideo) { return this.call.call(to, isVideo); }
87
+ rejectCall(id, from) { return this.call.reject(id, from); }
88
+ acceptCall(callId, callFrom) { return this.call.accept(callId, callFrom); }
89
+ endCall(callId, peerJid) { return this.call.end(callId, peerJid); }
90
+ // Labels
91
+ getLabels() { return this.label.list(); }
92
+ createLabel(name, labelId) { return this.label.create(name, labelId); }
93
+ getChatLabel(labelId) { return this.label.getChats(labelId); }
94
+ addChatLabel(labelId, to) { return this.label.addToChat(labelId, to); }
95
+ deleteLabel(labelId) { return this.label.delete(labelId); }
96
+ removeChatLabel(labelId, to) { return this.label.removeFromChat(labelId, to); }
97
+ // Actions
98
+ checkRegisteredWhatsapp(number) { return this.action.checkRegistered(number); }
99
+ downloadMedia(type, message) { return this.action.downloadMedia(type, message); }
100
+ deleteStorage() { return this.action.deleteStorage(); }
101
+ // Contacts
102
+ contacts() { return this.contact.list(); }
103
+ addContact(number, name) { return this.contact.add(number, name); }
104
+ contactProfile(id) { return this.contact.profile(id); }
105
+ removeContact(number) { return this.contact.remove(number); }
106
+ blockContact(number, action) { return this.contact.block(number, action); }
107
+ clearContactSession(number) { return this.contact.clearSession(number); }
108
+ getContactStatus(number) { return this.contact.getStatus(number); }
109
+ listBlockedContacts() { return this.contact.listBlocked(); }
110
+ resolveLids(lids) { return this.contact.resolveLids(lids); }
111
+ // Groups
112
+ groups() { return this.group.list(); }
113
+ infoGroup(id) { return this.group.info(id); }
114
+ createGroup(name, participants) { return this.group.create(name, participants); }
115
+ updateGroup(id, name, description) { return this.group.update(id, name, description); }
116
+ changeGroupSettings(id, setting) { return this.group.changeSettings(id, setting); }
117
+ leaveGroup(id) { return this.group.leave(id); }
118
+ getGroupMembers(id) { return this.group.getMembers(id); }
119
+ getGroupInviteInfo(code) { return this.group.getInviteInfo(code); }
120
+ getInviteGroup(id) { return this.group.getInviteCode(id); }
121
+ updateGroupPicture(id, url) { return this.group.updatePicture(id, url); }
122
+ removeGroupPicture(id) { return this.group.removePicture(id); }
123
+ addParticipantsGroup(id, participants) { return this.group.addParticipants(id, participants); }
124
+ removeParticipantsGroup(id, participants) { return this.group.removeParticipants(id, participants); }
125
+ updateGroupParticipantRole(id, action, participants) { return this.group.updateParticipantRole(id, action, participants); }
126
+ getGroupRequestParticipants(id) { return this.group.getRequestParticipants(id); }
127
+ updateGroupRequestParticipants(id, data) { return this.group.updateRequestParticipants(id, data); }
128
+ // Community
129
+ listCommunities() { return this.community.list(); }
130
+ createCommunity(data) { return this.community.create(data); }
131
+ infoCommunity(id) { return this.community.info(id); }
132
+ updateCommunity(id, data) { return this.community.update(id, data); }
133
+ leaveCommunity(id) { return this.community.leave(id); }
134
+ updateCommunityPicture(id, url) { return this.community.updatePicture(id, url); }
135
+ getCommunityInviteCode(id) { return this.community.getInviteCode(id); }
136
+ removeCommunityParticipants(id, participants) { return this.community.removeParticipants(id, participants); }
137
+ getCommunityRequestParticipants(id) { return this.community.getRequestParticipants(id); }
138
+ updateCommunityRequestParticipants(id, data) { return this.community.updateRequestParticipants(id, data); }
139
+ acceptCommunityInvite(code) { return this.community.acceptInvite(code); }
140
+ getCommunityInviteInfo(code) { return this.community.getInviteInfo(code); }
141
+ createCommunityGroup(id, data) { return this.community.createGroup(id, data); }
142
+ setCommunityEphemeral(id, expiration) { return this.community.ephemeral(id, expiration); }
143
+ updateCommunitySettings(id, setting) { return this.community.updateSettings(id, setting); }
144
+ setCommunityMemberAddMode(id, mode) { return this.community.memberAddMode(id, mode); }
145
+ setCommunityJoinApproval(id, mode) { return this.community.joinApproval(id, mode); }
146
+ // Business
147
+ getCatalog(limit, cursor) { return this.business.getCatalog(limit, cursor); }
148
+ createProduct(product) { return this.business.createProduct(product); }
149
+ updateProduct(productId, product) { return this.business.updateProduct(productId, product); }
150
+ deleteProduct(productId) { return this.business.deleteProduct(productId); }
172
151
  }
173
152
  exports.WhatsApp = WhatsApp;
174
153
  exports.default = WhatsApp;