@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.
- package/README.md +512 -297
- package/dist/WhatsApp.d.ts +177 -33
- package/dist/WhatsApp.js +146 -167
- package/dist/WhatsApp.js.map +1 -1
- package/dist/client/HttpClient.d.ts +6 -0
- package/dist/client/HttpClient.js +29 -0
- package/dist/client/HttpClient.js.map +1 -0
- package/dist/client/IHttpClient.d.ts +9 -0
- package/dist/client/IHttpClient.js +3 -0
- package/dist/client/IHttpClient.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/dist/services/ActionService.d.ts +9 -0
- package/dist/services/ActionService.js +32 -0
- package/dist/services/ActionService.js.map +1 -0
- package/dist/services/BusinessService.d.ts +10 -0
- package/dist/services/BusinessService.js +43 -0
- package/dist/services/BusinessService.js.map +1 -0
- package/dist/services/CallService.d.ts +10 -0
- package/dist/services/CallService.js +38 -0
- package/dist/services/CallService.js.map +1 -0
- package/dist/services/ChatService.d.ts +19 -0
- package/dist/services/ChatService.js +63 -0
- package/dist/services/ChatService.js.map +1 -0
- package/dist/services/CommunityService.d.ts +35 -0
- package/dist/services/CommunityService.js +125 -0
- package/dist/services/CommunityService.js.map +1 -0
- package/dist/services/ContactService.d.ts +21 -0
- package/dist/services/ContactService.js +68 -0
- package/dist/services/ContactService.js.map +1 -0
- package/dist/services/GroupService.d.ts +37 -0
- package/dist/services/GroupService.js +117 -0
- package/dist/services/GroupService.js.map +1 -0
- package/dist/services/InstanceService.d.ts +29 -0
- package/dist/services/InstanceService.js +130 -0
- package/dist/services/InstanceService.js.map +1 -0
- package/dist/services/LabelService.d.ts +18 -0
- package/dist/services/LabelService.js +49 -0
- package/dist/services/LabelService.js.map +1 -0
- package/dist/services/MessageService.d.ts +60 -0
- package/dist/services/MessageService.js +171 -0
- package/dist/services/MessageService.js.map +1 -0
- package/dist/services/NewsletterService.d.ts +23 -0
- package/dist/services/NewsletterService.js +129 -0
- package/dist/services/NewsletterService.js.map +1 -0
- package/dist/services/StatusService.d.ts +14 -0
- package/dist/services/StatusService.js +46 -0
- package/dist/services/StatusService.js.map +1 -0
- package/dist/types/index.d.ts +206 -11
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +6 -11
- package/.babelrc +0 -3
- package/dist/exemple.d.ts +0 -1
- package/dist/exemple.js +0 -264
- package/dist/exemple.js.map +0 -1
- package/src/WhatsApp.ts +0 -245
- package/src/exemple.ts +0 -312
- package/src/index.ts +0 -2
- package/src/types/index.ts +0 -190
- package/tsconfig.compile.json +0 -15
- package/tsconfig.json +0 -35
package/dist/WhatsApp.d.ts
CHANGED
|
@@ -1,33 +1,61 @@
|
|
|
1
|
-
import { Init, WebhookBody, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot, Connect,
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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<
|
|
13
|
-
setting(
|
|
31
|
+
logout(): Promise<ApiResponse>;
|
|
32
|
+
setting(data: {
|
|
14
33
|
markMessageRead: boolean;
|
|
34
|
+
saveMedia: boolean;
|
|
15
35
|
receiveStatusMessage: boolean;
|
|
16
36
|
receivePresence: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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;
|