@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/types/index.d.ts
CHANGED
|
@@ -15,7 +15,13 @@ export declare enum Routes {
|
|
|
15
15
|
CONTACTS = "contacts",
|
|
16
16
|
GROUPS = "groups",
|
|
17
17
|
ACTIONS = "actions",
|
|
18
|
-
CALL = "call"
|
|
18
|
+
CALL = "call",
|
|
19
|
+
CHAT = "chat",
|
|
20
|
+
LABELS = "labels",
|
|
21
|
+
COMMUNITY = "community",
|
|
22
|
+
BUSINESS = "business",
|
|
23
|
+
NEWSLETTER = "newsletter",
|
|
24
|
+
STATUS = "status"
|
|
19
25
|
}
|
|
20
26
|
export declare enum TypeMessage {
|
|
21
27
|
PRESENCE = "presence",
|
|
@@ -33,7 +39,13 @@ export declare enum TypeMessage {
|
|
|
33
39
|
BUTTON_ACTION = "button_action",
|
|
34
40
|
BUTTON_PIX = "pix",
|
|
35
41
|
POLL = "survey",
|
|
36
|
-
MENU = "list"
|
|
42
|
+
MENU = "list",
|
|
43
|
+
STICKER = "sticker",
|
|
44
|
+
VIDEO_NOTE = "video-note",
|
|
45
|
+
POLL_V2 = "poll",
|
|
46
|
+
EVENT = "event",
|
|
47
|
+
PIN = "pin",
|
|
48
|
+
CALL_LINK = "call-link"
|
|
37
49
|
}
|
|
38
50
|
export declare enum StatusPresence {
|
|
39
51
|
UNAVAILABLE = "unavailable",
|
|
@@ -42,8 +54,13 @@ export declare enum StatusPresence {
|
|
|
42
54
|
RECORDING = "recording",
|
|
43
55
|
PAUSED = "paused"
|
|
44
56
|
}
|
|
57
|
+
export interface ApiResponse {
|
|
58
|
+
status: number;
|
|
59
|
+
message: string;
|
|
60
|
+
}
|
|
45
61
|
export interface WebhookBody {
|
|
46
62
|
allowWebhook: boolean;
|
|
63
|
+
allowNumber?: string;
|
|
47
64
|
webhookMessage: string;
|
|
48
65
|
webhookGroup: string;
|
|
49
66
|
webhookConnection: string;
|
|
@@ -94,6 +111,7 @@ export interface User {
|
|
|
94
111
|
}
|
|
95
112
|
export interface Webhook {
|
|
96
113
|
allowWebhook: boolean;
|
|
114
|
+
allowNumber?: string;
|
|
97
115
|
webhookMessage: string;
|
|
98
116
|
webhookGroup: string;
|
|
99
117
|
webhookConnection: string;
|
|
@@ -103,21 +121,21 @@ export interface Webhook {
|
|
|
103
121
|
}
|
|
104
122
|
export interface SendMessageRoot {
|
|
105
123
|
status: number;
|
|
106
|
-
data:
|
|
124
|
+
data: MessageData;
|
|
107
125
|
}
|
|
108
|
-
export interface
|
|
109
|
-
key:
|
|
110
|
-
message:
|
|
126
|
+
export interface MessageData {
|
|
127
|
+
key: MessageKey;
|
|
128
|
+
message: MessageContent;
|
|
111
129
|
messageTimestamp: string;
|
|
112
130
|
status: string;
|
|
113
131
|
}
|
|
114
|
-
export interface
|
|
132
|
+
export interface MessageKey {
|
|
115
133
|
remoteJid: string;
|
|
116
134
|
fromMe: boolean;
|
|
117
135
|
id: string;
|
|
118
136
|
}
|
|
119
|
-
export interface
|
|
120
|
-
extendedTextMessage
|
|
137
|
+
export interface MessageContent {
|
|
138
|
+
extendedTextMessage?: ExtendedTextMessage;
|
|
121
139
|
}
|
|
122
140
|
export interface ExtendedTextMessage {
|
|
123
141
|
text: string;
|
|
@@ -129,12 +147,16 @@ export interface Connect {
|
|
|
129
147
|
image: string;
|
|
130
148
|
user?: User;
|
|
131
149
|
}
|
|
150
|
+
export interface PairingCodeResponse {
|
|
151
|
+
status: number;
|
|
152
|
+
code: string;
|
|
153
|
+
}
|
|
132
154
|
export interface BusinessProfile {
|
|
133
155
|
wid: string;
|
|
134
156
|
description: string;
|
|
135
|
-
website:
|
|
157
|
+
website: string[];
|
|
136
158
|
category: string;
|
|
137
|
-
business_hours:
|
|
159
|
+
business_hours: Record<string, unknown>;
|
|
138
160
|
}
|
|
139
161
|
export interface Buttons {
|
|
140
162
|
type: "quick_reply" | "cta_copy" | "cta_url" | "cta_call";
|
|
@@ -150,3 +172,176 @@ export interface Items {
|
|
|
150
172
|
price: number;
|
|
151
173
|
quantity: number;
|
|
152
174
|
}
|
|
175
|
+
export interface HeaderMedia {
|
|
176
|
+
title?: string;
|
|
177
|
+
hasMediaAttachment?: boolean;
|
|
178
|
+
imageMessage?: {
|
|
179
|
+
url: string;
|
|
180
|
+
};
|
|
181
|
+
videoMessage?: {
|
|
182
|
+
url: string;
|
|
183
|
+
};
|
|
184
|
+
documentMessage?: {
|
|
185
|
+
url: string;
|
|
186
|
+
mimetype?: string;
|
|
187
|
+
fileName?: string;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface DownloadableMessage {
|
|
191
|
+
mediaKey: string;
|
|
192
|
+
directPath: string;
|
|
193
|
+
url: string;
|
|
194
|
+
}
|
|
195
|
+
export interface Product {
|
|
196
|
+
name: string;
|
|
197
|
+
description?: string;
|
|
198
|
+
originCountryCode?: string;
|
|
199
|
+
currency?: string;
|
|
200
|
+
price?: number;
|
|
201
|
+
images?: {
|
|
202
|
+
url: string;
|
|
203
|
+
}[];
|
|
204
|
+
}
|
|
205
|
+
export interface CommunityCreate {
|
|
206
|
+
name: string;
|
|
207
|
+
subject: string;
|
|
208
|
+
}
|
|
209
|
+
export interface CommunityUpdate {
|
|
210
|
+
subject: string;
|
|
211
|
+
description: string;
|
|
212
|
+
}
|
|
213
|
+
export interface GroupParticipantsAction {
|
|
214
|
+
participants: string[];
|
|
215
|
+
action: 'reject' | 'approve';
|
|
216
|
+
}
|
|
217
|
+
export interface MobileRegisterData {
|
|
218
|
+
phoneNumberCountryCode: string;
|
|
219
|
+
phoneNumberNationalNumber: string;
|
|
220
|
+
phoneNumberMobileNetworkCode: string;
|
|
221
|
+
}
|
|
222
|
+
export interface EventData {
|
|
223
|
+
to: string;
|
|
224
|
+
name: string;
|
|
225
|
+
description?: string;
|
|
226
|
+
startTime?: string;
|
|
227
|
+
locationName?: string;
|
|
228
|
+
locationAddress?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface RegisteredResponse {
|
|
231
|
+
status: number;
|
|
232
|
+
registered: boolean;
|
|
233
|
+
}
|
|
234
|
+
export interface ContactInfo {
|
|
235
|
+
id: string;
|
|
236
|
+
name?: string;
|
|
237
|
+
notify?: string;
|
|
238
|
+
imgUrl?: string;
|
|
239
|
+
}
|
|
240
|
+
export interface GroupInfo {
|
|
241
|
+
id: string;
|
|
242
|
+
subject: string;
|
|
243
|
+
owner: string;
|
|
244
|
+
creation: number;
|
|
245
|
+
desc?: string;
|
|
246
|
+
participants: GroupParticipant[];
|
|
247
|
+
}
|
|
248
|
+
export interface GroupParticipant {
|
|
249
|
+
id: string;
|
|
250
|
+
admin?: string;
|
|
251
|
+
}
|
|
252
|
+
export interface InviteCodeResponse {
|
|
253
|
+
status: number;
|
|
254
|
+
inviteCode: string;
|
|
255
|
+
}
|
|
256
|
+
export interface ChatInfo {
|
|
257
|
+
id: string;
|
|
258
|
+
name?: string;
|
|
259
|
+
timestamp?: number;
|
|
260
|
+
unreadCount?: number;
|
|
261
|
+
}
|
|
262
|
+
export interface LabelInfo {
|
|
263
|
+
id: string;
|
|
264
|
+
name: string;
|
|
265
|
+
color?: number;
|
|
266
|
+
}
|
|
267
|
+
export interface CommunityInfo {
|
|
268
|
+
id: string;
|
|
269
|
+
name: string;
|
|
270
|
+
subject?: string;
|
|
271
|
+
description?: string;
|
|
272
|
+
participants?: GroupParticipant[];
|
|
273
|
+
}
|
|
274
|
+
export interface CatalogResponse {
|
|
275
|
+
status: number;
|
|
276
|
+
data: Product[];
|
|
277
|
+
cursor?: string;
|
|
278
|
+
}
|
|
279
|
+
export interface WebhookStatistics {
|
|
280
|
+
status: number;
|
|
281
|
+
data: Record<string, unknown>;
|
|
282
|
+
}
|
|
283
|
+
export interface ListMessagesResponse {
|
|
284
|
+
status: number;
|
|
285
|
+
data: MessageData[];
|
|
286
|
+
page?: number;
|
|
287
|
+
limit?: number;
|
|
288
|
+
total?: number;
|
|
289
|
+
}
|
|
290
|
+
export interface DownloadMediaResponse {
|
|
291
|
+
status: number;
|
|
292
|
+
data: string;
|
|
293
|
+
}
|
|
294
|
+
export interface CallResponse {
|
|
295
|
+
status: number;
|
|
296
|
+
data: Record<string, unknown>;
|
|
297
|
+
}
|
|
298
|
+
export interface LiveLocationData {
|
|
299
|
+
to: string;
|
|
300
|
+
latitude: number;
|
|
301
|
+
longitude: number;
|
|
302
|
+
caption?: string;
|
|
303
|
+
}
|
|
304
|
+
export interface SendContactsData {
|
|
305
|
+
to: string;
|
|
306
|
+
displayName: string;
|
|
307
|
+
contacts: Contact[];
|
|
308
|
+
}
|
|
309
|
+
export interface ProductMessageData {
|
|
310
|
+
to: string;
|
|
311
|
+
businessOwnerJid: string;
|
|
312
|
+
productId: string;
|
|
313
|
+
catalogId: string;
|
|
314
|
+
body?: string;
|
|
315
|
+
footer?: string;
|
|
316
|
+
}
|
|
317
|
+
export interface GroupInviteMessageData {
|
|
318
|
+
to: string;
|
|
319
|
+
groupJid: string;
|
|
320
|
+
groupName: string;
|
|
321
|
+
inviteCode: string;
|
|
322
|
+
inviteExpiration?: number;
|
|
323
|
+
caption?: string;
|
|
324
|
+
}
|
|
325
|
+
export interface StatusTextData {
|
|
326
|
+
text: string;
|
|
327
|
+
statusJidList?: string[];
|
|
328
|
+
}
|
|
329
|
+
export interface StatusMediaData {
|
|
330
|
+
url: string;
|
|
331
|
+
caption?: string;
|
|
332
|
+
statusJidList?: string[];
|
|
333
|
+
}
|
|
334
|
+
export interface StatusMentionData {
|
|
335
|
+
jid: string;
|
|
336
|
+
statusMsgId: string;
|
|
337
|
+
}
|
|
338
|
+
export interface NewsletterInfo {
|
|
339
|
+
id: string;
|
|
340
|
+
name?: string;
|
|
341
|
+
description?: string;
|
|
342
|
+
subscribers?: number;
|
|
343
|
+
}
|
|
344
|
+
export interface CommunityGroupCreate {
|
|
345
|
+
subject: string;
|
|
346
|
+
participants?: string[];
|
|
347
|
+
}
|
package/dist/types/index.js
CHANGED
|
@@ -17,6 +17,12 @@ var Routes;
|
|
|
17
17
|
Routes["GROUPS"] = "groups";
|
|
18
18
|
Routes["ACTIONS"] = "actions";
|
|
19
19
|
Routes["CALL"] = "call";
|
|
20
|
+
Routes["CHAT"] = "chat";
|
|
21
|
+
Routes["LABELS"] = "labels";
|
|
22
|
+
Routes["COMMUNITY"] = "community";
|
|
23
|
+
Routes["BUSINESS"] = "business";
|
|
24
|
+
Routes["NEWSLETTER"] = "newsletter";
|
|
25
|
+
Routes["STATUS"] = "status";
|
|
20
26
|
})(Routes || (exports.Routes = Routes = {}));
|
|
21
27
|
var TypeMessage;
|
|
22
28
|
(function (TypeMessage) {
|
|
@@ -36,6 +42,12 @@ var TypeMessage;
|
|
|
36
42
|
TypeMessage["BUTTON_PIX"] = "pix";
|
|
37
43
|
TypeMessage["POLL"] = "survey";
|
|
38
44
|
TypeMessage["MENU"] = "list";
|
|
45
|
+
TypeMessage["STICKER"] = "sticker";
|
|
46
|
+
TypeMessage["VIDEO_NOTE"] = "video-note";
|
|
47
|
+
TypeMessage["POLL_V2"] = "poll";
|
|
48
|
+
TypeMessage["EVENT"] = "event";
|
|
49
|
+
TypeMessage["PIN"] = "pin";
|
|
50
|
+
TypeMessage["CALL_LINK"] = "call-link";
|
|
39
51
|
})(TypeMessage || (exports.TypeMessage = TypeMessage = {}));
|
|
40
52
|
var StatusPresence;
|
|
41
53
|
(function (StatusPresence) {
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAGD,IAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAGD,IAAY,MAaX;AAbD,WAAY,MAAM;IAChB,gCAAsB,CAAA;IACtB,8BAAoB,CAAA;IACpB,+BAAqB,CAAA;IACrB,2BAAiB,CAAA;IACjB,6BAAmB,CAAA;IACnB,uBAAa,CAAA;IACb,uBAAa,CAAA;IACb,2BAAiB,CAAA;IACjB,iCAAuB,CAAA;IACvB,+BAAqB,CAAA;IACrB,mCAAyB,CAAA;IACzB,2BAAiB,CAAA;AACnB,CAAC,EAbW,MAAM,sBAAN,MAAM,QAajB;AAGD,IAAY,WAuBX;AAvBD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,4CAA6B,CAAA;IAC7B,8CAA+B,CAAA;IAC/B,iCAAkB,CAAA;IAClB,8BAAe,CAAA;IACf,4BAAa,CAAA;IACb,kCAAmB,CAAA;IACnB,wCAAyB,CAAA;IACzB,+BAAgB,CAAA;IAChB,8BAAe,CAAA;IACf,0BAAW,CAAA;IACX,sCAAuB,CAAA;AACzB,CAAC,EAvBW,WAAW,2BAAX,WAAW,QAuBtB;AAGD,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,6CAA2B,CAAA;IAC3B,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB","sourcesContent":["export interface Init {\n server: string;\n key: string;\n}\n\nexport enum HttpMethod {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n DELETE = 'DELETE',\n PATCH = 'PATCH',\n}\n\n\nexport enum Routes {\n INSTANCES = 'instance',\n MESSAGES = 'message',\n CONTACTS = 'contacts',\n GROUPS = 'groups',\n ACTIONS = 'actions',\n CALL = 'call',\n CHAT = 'chat',\n LABELS = 'labels',\n COMMUNITY = 'community',\n BUSINESS = 'business',\n NEWSLETTER = 'newsletter',\n STATUS = 'status',\n}\n\n\nexport enum TypeMessage {\n PRESENCE = 'presence',\n TEXT = 'text',\n AUDIO = 'audio',\n IMAGE = 'image',\n VIDEO = 'video',\n DOCUMENT = 'document',\n CONTACT = 'contact',\n LOCATION = 'location',\n REACTION = 'reaction',\n LINK = 'link',\n TITLE = 'title',\n BUTTON_REPLY = 'button_reply',\n BUTTON_ACTION = 'button_action',\n BUTTON_PIX = 'pix',\n POLL = 'survey',\n MENU = 'list',\n STICKER = 'sticker',\n VIDEO_NOTE = 'video-note',\n POLL_V2 = 'poll',\n EVENT = 'event',\n PIN = 'pin',\n CALL_LINK = 'call-link',\n}\n\n\nexport enum StatusPresence {\n UNAVAILABLE = 'unavailable',\n AVAILABLE = 'available',\n COMPOSING = 'composing',\n RECORDING = 'recording',\n PAUSED = 'paused',\n}\n\n\nexport interface ApiResponse {\n status: number;\n message: string;\n}\n\n\nexport interface WebhookBody {\n allowWebhook: boolean;\n allowNumber?: string;\n webhookMessage: string;\n webhookGroup: string;\n webhookConnection: string;\n webhookQrCode: string;\n webhookMessageFromMe: string;\n webhookHistory: string;\n}\n\nexport interface Contact {\n fullName: string;\n phoneNumber: string;\n organization?: string;\n}\n\n\nexport interface Location {\n latitude: number;\n longitude: number;\n address: string;\n}\n\nexport interface Row {\n title: string;\n description: string;\n rowId: string;\n}\n\nexport interface Section {\n title: string;\n rows: Row[];\n}\n\n\n\nexport interface InfoInstance {\n status: number;\n instance: Instance;\n}\n\nexport interface Instance {\n receive_status_message: boolean;\n save_media: boolean;\n receive_presence: boolean;\n permission: number;\n mark_messages: boolean;\n blocked: boolean;\n user?: User;\n phoneConnected: boolean;\n webhook: Webhook;\n businessProfile?: BusinessProfile;\n}\n\nexport interface User {\n id?: string;\n lid?: string;\n name?: string;\n imageProfile?: string;\n}\n\nexport interface Webhook {\n allowWebhook: boolean;\n allowNumber?: string;\n webhookMessage: string;\n webhookGroup: string;\n webhookConnection: string;\n webhookQrCode: string;\n webhookMessageFromMe: string;\n webhookHistory: string;\n}\n\n\n\nexport interface SendMessageRoot {\n status: number;\n data: MessageData;\n}\n\nexport interface MessageData {\n key: MessageKey;\n message: MessageContent;\n messageTimestamp: string;\n status: string;\n}\n\nexport interface MessageKey {\n remoteJid: string;\n fromMe: boolean;\n id: string;\n}\n\nexport interface MessageContent {\n extendedTextMessage?: ExtendedTextMessage;\n}\n\nexport interface ExtendedTextMessage {\n text: string;\n}\n\nexport interface Connect {\n status: number;\n phoneConnected: boolean;\n qrcode: string;\n image: string;\n user?: User;\n}\n\n\nexport interface PairingCodeResponse {\n status: number;\n code: string;\n}\n\n\nexport interface BusinessProfile {\n wid: string;\n description: string;\n website: string[];\n category: string;\n business_hours: Record<string, unknown>;\n}\n\n\n\nexport interface Buttons {\n type: \"quick_reply\" | \"cta_copy\" | \"cta_url\" | \"cta_call\";\n copy_code?: string;\n phone_number?: string;\n url?: string;\n id?: string;\n text: string;\n}\n\n\nexport interface Items {\n id: string;\n name: string;\n price: number;\n quantity: number;\n}\n\n\nexport interface HeaderMedia {\n title?: string;\n hasMediaAttachment?: boolean;\n imageMessage?: { url: string };\n videoMessage?: { url: string };\n documentMessage?: { url: string; mimetype?: string; fileName?: string };\n}\n\n\nexport interface DownloadableMessage {\n mediaKey: string;\n directPath: string;\n url: string;\n}\n\n\nexport interface Product {\n name: string;\n description?: string;\n originCountryCode?: string;\n currency?: string;\n price?: number;\n images?: { url: string }[];\n}\n\n\nexport interface CommunityCreate {\n name: string;\n subject: string;\n}\n\nexport interface CommunityUpdate {\n subject: string;\n description: string;\n}\n\n\nexport interface GroupParticipantsAction {\n participants: string[];\n action: 'reject' | 'approve';\n}\n\n\nexport interface MobileRegisterData {\n phoneNumberCountryCode: string;\n phoneNumberNationalNumber: string;\n phoneNumberMobileNetworkCode: string;\n}\n\n\nexport interface EventData {\n to: string;\n name: string;\n description?: string;\n startTime?: string;\n locationName?: string;\n locationAddress?: string;\n}\n\n\nexport interface RegisteredResponse {\n status: number;\n registered: boolean;\n}\n\n\nexport interface ContactInfo {\n id: string;\n name?: string;\n notify?: string;\n imgUrl?: string;\n}\n\n\nexport interface GroupInfo {\n id: string;\n subject: string;\n owner: string;\n creation: number;\n desc?: string;\n participants: GroupParticipant[];\n}\n\nexport interface GroupParticipant {\n id: string;\n admin?: string;\n}\n\n\nexport interface InviteCodeResponse {\n status: number;\n inviteCode: string;\n}\n\n\nexport interface ChatInfo {\n id: string;\n name?: string;\n timestamp?: number;\n unreadCount?: number;\n}\n\n\nexport interface LabelInfo {\n id: string;\n name: string;\n color?: number;\n}\n\n\nexport interface CommunityInfo {\n id: string;\n name: string;\n subject?: string;\n description?: string;\n participants?: GroupParticipant[];\n}\n\n\nexport interface CatalogResponse {\n status: number;\n data: Product[];\n cursor?: string;\n}\n\n\nexport interface WebhookStatistics {\n status: number;\n data: Record<string, unknown>;\n}\n\n\nexport interface ListMessagesResponse {\n status: number;\n data: MessageData[];\n page?: number;\n limit?: number;\n total?: number;\n}\n\n\nexport interface DownloadMediaResponse {\n status: number;\n data: string;\n}\n\n\nexport interface CallResponse {\n status: number;\n data: Record<string, unknown>;\n}\n\n\nexport interface LiveLocationData {\n to: string;\n latitude: number;\n longitude: number;\n caption?: string;\n}\n\n\nexport interface SendContactsData {\n to: string;\n displayName: string;\n contacts: Contact[];\n}\n\n\nexport interface ProductMessageData {\n to: string;\n businessOwnerJid: string;\n productId: string;\n catalogId: string;\n body?: string;\n footer?: string;\n}\n\n\nexport interface GroupInviteMessageData {\n to: string;\n groupJid: string;\n groupName: string;\n inviteCode: string;\n inviteExpiration?: number;\n caption?: string;\n}\n\n\nexport interface StatusTextData {\n text: string;\n statusJidList?: string[];\n}\n\n\nexport interface StatusMediaData {\n url: string;\n caption?: string;\n statusJidList?: string[];\n}\n\n\nexport interface StatusMentionData {\n jid: string;\n statusMsgId: string;\n}\n\n\nexport interface NewsletterInfo {\n id: string;\n name?: string;\n description?: string;\n subscribers?: number;\n}\n\n\nexport interface CommunityGroupCreate {\n subject: string;\n participants?: string[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raphaelvserafim/client-api-whatsapp",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "With our API, you can send text, audio, video, and image messages quickly and easily. Adapt to your business communication needs comprehensively.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"private": false,
|
|
8
11
|
"keywords": [
|
|
9
12
|
"api",
|
|
@@ -27,19 +30,11 @@
|
|
|
27
30
|
"url": "https://github.com/raphaelvserafim/client-api-whatsapp.git"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"axios": "^1.6.8"
|
|
31
|
-
"fs": "^0.0.1-security",
|
|
32
|
-
"typescript": "^5.4.3"
|
|
33
|
+
"axios": "^1.6.8"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@babel/preset-env": "^7.24.3",
|
|
36
|
-
"@jest/globals": "^29.7.0",
|
|
37
|
-
"@types/jest": "^29.5.12",
|
|
38
36
|
"@types/node": "^20.11.30",
|
|
39
|
-
"babel-jest": "^29.7.0",
|
|
40
|
-
"jest": "^29.7.0",
|
|
41
|
-
"ts-jest": "^29.1.2",
|
|
42
37
|
"tslib": "^2.6.2",
|
|
43
38
|
"typescript": "^5.4.3"
|
|
44
39
|
}
|
|
45
|
-
}
|
|
40
|
+
}
|
package/.babelrc
DELETED
package/dist/exemple.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/exemple.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const WhatsApp_1 = tslib_1.__importDefault(require("./WhatsApp"));
|
|
5
|
-
const types_1 = require("./types");
|
|
6
|
-
const whatsapp = new WhatsApp_1.default({ server: "", key: "" });
|
|
7
|
-
const to = "559999999999"; // If you want to send it to the group = 123456789@us
|
|
8
|
-
whatsapp.info().then((response) => {
|
|
9
|
-
console.log(response);
|
|
10
|
-
}).catch(console.error);
|
|
11
|
-
whatsapp.connect().then((response) => {
|
|
12
|
-
console.log(response);
|
|
13
|
-
}).catch(console.error);
|
|
14
|
-
whatsapp.logout().then((response) => {
|
|
15
|
-
console.log(response);
|
|
16
|
-
}).catch(console.error);
|
|
17
|
-
whatsapp.contacts().then((response) => {
|
|
18
|
-
console.log(response);
|
|
19
|
-
}).catch(console.error);
|
|
20
|
-
whatsapp.sendMessage({
|
|
21
|
-
type: types_1.TypeMessage.PRESENCE,
|
|
22
|
-
body: {
|
|
23
|
-
to: to,
|
|
24
|
-
status: types_1.StatusPresence.COMPOSING
|
|
25
|
-
}
|
|
26
|
-
}).then((response) => {
|
|
27
|
-
console.log(response);
|
|
28
|
-
}).catch(console.error);
|
|
29
|
-
whatsapp.sendMessage({
|
|
30
|
-
type: types_1.TypeMessage.TEXT,
|
|
31
|
-
body: {
|
|
32
|
-
to: to,
|
|
33
|
-
text: "Hey"
|
|
34
|
-
}
|
|
35
|
-
}).then((response) => {
|
|
36
|
-
console.log(response);
|
|
37
|
-
}).catch(console.error);
|
|
38
|
-
whatsapp.sendMessage({
|
|
39
|
-
type: types_1.TypeMessage.BUTTON_PIX,
|
|
40
|
-
body: {
|
|
41
|
-
to: "14375223417",
|
|
42
|
-
title: "Pizza",
|
|
43
|
-
text: "Pizza ",
|
|
44
|
-
referenceId: "apiwame",
|
|
45
|
-
code: "0020",
|
|
46
|
-
key: "23711695000115",
|
|
47
|
-
merchantName: "CACHE SISTEMAS WEB",
|
|
48
|
-
keyType: "CNPJ",
|
|
49
|
-
items: [
|
|
50
|
-
{
|
|
51
|
-
id: "123",
|
|
52
|
-
name: "Pizza G",
|
|
53
|
-
price: 10,
|
|
54
|
-
quantity: 10
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
subtotal: "90",
|
|
58
|
-
totalAmount: "100"
|
|
59
|
-
}
|
|
60
|
-
}).then((response) => {
|
|
61
|
-
console.log(response);
|
|
62
|
-
}).catch(console.error);
|
|
63
|
-
whatsapp.sendMessage({
|
|
64
|
-
type: types_1.TypeMessage.BUTTON_PIX,
|
|
65
|
-
body: {
|
|
66
|
-
to: "14375223417",
|
|
67
|
-
title: "Pizza",
|
|
68
|
-
text: "Pizza ",
|
|
69
|
-
referenceId: "apiwame",
|
|
70
|
-
code: "0020",
|
|
71
|
-
key: "23711695000115",
|
|
72
|
-
merchantName: "CACHE SISTEMAS WEB",
|
|
73
|
-
keyType: "CNPJ",
|
|
74
|
-
items: [
|
|
75
|
-
{
|
|
76
|
-
id: "123",
|
|
77
|
-
name: "Pizza G",
|
|
78
|
-
price: 10,
|
|
79
|
-
quantity: 10
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
subtotal: "90",
|
|
83
|
-
totalAmount: "100"
|
|
84
|
-
}
|
|
85
|
-
}).then((response) => {
|
|
86
|
-
console.log(response);
|
|
87
|
-
}).catch(console.error);
|
|
88
|
-
whatsapp.sendMessage({
|
|
89
|
-
type: types_1.TypeMessage.BUTTON_REPLY,
|
|
90
|
-
body: {
|
|
91
|
-
to: "14375223417",
|
|
92
|
-
header: {
|
|
93
|
-
title: "Example Header",
|
|
94
|
-
},
|
|
95
|
-
text: "This is a test",
|
|
96
|
-
footer: "choose an option",
|
|
97
|
-
buttons: [
|
|
98
|
-
{
|
|
99
|
-
type: "quick_reply",
|
|
100
|
-
id: "uniqId1",
|
|
101
|
-
text: "Yes"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
type: "quick_reply",
|
|
105
|
-
id: "uniqId2",
|
|
106
|
-
text: "No"
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
}).then((response) => {
|
|
111
|
-
console.log(response);
|
|
112
|
-
}).catch(console.error);
|
|
113
|
-
whatsapp.sendMessage({
|
|
114
|
-
type: types_1.TypeMessage.BUTTON_ACTION,
|
|
115
|
-
body: {
|
|
116
|
-
to: "14375223417",
|
|
117
|
-
header: {
|
|
118
|
-
title: "Example Header",
|
|
119
|
-
},
|
|
120
|
-
text: "This is a test",
|
|
121
|
-
footer: "choose an option",
|
|
122
|
-
buttons: [
|
|
123
|
-
{
|
|
124
|
-
type: "cta_copy",
|
|
125
|
-
copy_code: "1234567890",
|
|
126
|
-
text: "Copy barcode"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
type: "cta_url",
|
|
130
|
-
url: "https://api-wa.me",
|
|
131
|
-
text: "Access the website"
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
type: "cta_call",
|
|
135
|
-
phone_number: "+5566996852025",
|
|
136
|
-
text: "Call us"
|
|
137
|
-
}
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
}).then((response) => {
|
|
141
|
-
console.log(response);
|
|
142
|
-
}).catch(console.error);
|
|
143
|
-
whatsapp.sendMessage({
|
|
144
|
-
type: types_1.TypeMessage.MENU,
|
|
145
|
-
body: {
|
|
146
|
-
to: "14375223417",
|
|
147
|
-
buttonText: "Menu",
|
|
148
|
-
text: "string",
|
|
149
|
-
title: "Menu",
|
|
150
|
-
description: "Description",
|
|
151
|
-
footer: "footer",
|
|
152
|
-
sections: [
|
|
153
|
-
{
|
|
154
|
-
title: "Pizza",
|
|
155
|
-
rows: [
|
|
156
|
-
{
|
|
157
|
-
title: "Pizza 01",
|
|
158
|
-
description: "Example pizza 01",
|
|
159
|
-
rowId: "1"
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
}).then((response) => {
|
|
166
|
-
console.log(response);
|
|
167
|
-
}).catch(console.error);
|
|
168
|
-
whatsapp.sendMessage({
|
|
169
|
-
type: types_1.TypeMessage.POLL,
|
|
170
|
-
body: {
|
|
171
|
-
to: "14375223417",
|
|
172
|
-
name: "Do you like PHP?",
|
|
173
|
-
options: [
|
|
174
|
-
"Yes",
|
|
175
|
-
"No"
|
|
176
|
-
],
|
|
177
|
-
}
|
|
178
|
-
}).then((response) => {
|
|
179
|
-
console.log(response);
|
|
180
|
-
}).catch(console.error);
|
|
181
|
-
whatsapp.sendMessage({
|
|
182
|
-
type: types_1.TypeMessage.TEXT,
|
|
183
|
-
body: {
|
|
184
|
-
msgId: "SKJH455AJKJ",
|
|
185
|
-
to: to,
|
|
186
|
-
text: "Hey"
|
|
187
|
-
}
|
|
188
|
-
}, true).then((response) => {
|
|
189
|
-
console.log(response);
|
|
190
|
-
}).catch(console.error);
|
|
191
|
-
whatsapp.sendMessage({
|
|
192
|
-
type: types_1.TypeMessage.AUDIO,
|
|
193
|
-
body: {
|
|
194
|
-
to: to,
|
|
195
|
-
url: ""
|
|
196
|
-
}
|
|
197
|
-
}).then((response) => {
|
|
198
|
-
console.log(response);
|
|
199
|
-
}).catch(console.error);
|
|
200
|
-
whatsapp.sendMessage({
|
|
201
|
-
type: types_1.TypeMessage.IMAGE,
|
|
202
|
-
body: {
|
|
203
|
-
to: to,
|
|
204
|
-
url: ""
|
|
205
|
-
}
|
|
206
|
-
}).then((response) => {
|
|
207
|
-
console.log(response);
|
|
208
|
-
}).catch(console.error);
|
|
209
|
-
whatsapp.sendMessage({
|
|
210
|
-
type: types_1.TypeMessage.VIDEO,
|
|
211
|
-
body: {
|
|
212
|
-
to: to,
|
|
213
|
-
url: ""
|
|
214
|
-
}
|
|
215
|
-
}).then((response) => {
|
|
216
|
-
console.log(response);
|
|
217
|
-
}).catch(console.error);
|
|
218
|
-
whatsapp.sendMessage({
|
|
219
|
-
type: types_1.TypeMessage.DOCUMENT,
|
|
220
|
-
body: {
|
|
221
|
-
to: to,
|
|
222
|
-
url: "",
|
|
223
|
-
mimetype: "",
|
|
224
|
-
fileName: ""
|
|
225
|
-
}
|
|
226
|
-
}).then((response) => {
|
|
227
|
-
console.log(response);
|
|
228
|
-
}).catch(console.error);
|
|
229
|
-
whatsapp.sendMessage({
|
|
230
|
-
type: types_1.TypeMessage.CONTACT,
|
|
231
|
-
body: {
|
|
232
|
-
to: to,
|
|
233
|
-
contact: {
|
|
234
|
-
fullName: "Raphael",
|
|
235
|
-
phoneNumber: to,
|
|
236
|
-
organization: "api-wa.me"
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}).then((response) => {
|
|
240
|
-
console.log(response);
|
|
241
|
-
}).catch(console.error);
|
|
242
|
-
whatsapp.sendMessage({
|
|
243
|
-
type: types_1.TypeMessage.REACTION,
|
|
244
|
-
body: {
|
|
245
|
-
to: to,
|
|
246
|
-
msgId: "ASDDF872AHDURBSG",
|
|
247
|
-
text: "🤖"
|
|
248
|
-
}
|
|
249
|
-
}).then((response) => {
|
|
250
|
-
console.log(response);
|
|
251
|
-
}).catch(console.error);
|
|
252
|
-
whatsapp.groups().then((response) => {
|
|
253
|
-
console.log(response);
|
|
254
|
-
}).catch(console.error);
|
|
255
|
-
whatsapp.infoGroup("123456789@us").then((response) => {
|
|
256
|
-
console.log(response);
|
|
257
|
-
}).catch(console.error);
|
|
258
|
-
whatsapp.createGroup("Devs", [to]).then((response) => {
|
|
259
|
-
console.log(response);
|
|
260
|
-
}).catch(console.error);
|
|
261
|
-
whatsapp.updateGroup("123456789@us", "Devs", "Only developers !").then((response) => {
|
|
262
|
-
console.log(response);
|
|
263
|
-
}).catch(console.error);
|
|
264
|
-
//# sourceMappingURL=exemple.js.map
|
package/dist/exemple.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exemple.js","sourceRoot":"","sources":["../src/exemple.ts"],"names":[],"mappings":";;;AAAA,kEAAkC;AAClC,mCAAsD;AAEtD,MAAM,QAAQ,GAAG,IAAI,kBAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;AAEvD,MAAM,EAAE,GAAG,cAAc,CAAA,CAAC,sDAAsD;AAEhF,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAGvB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAGxB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ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CAAC,CAAA;AAGvB,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAClF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import WhatsApp from \"./WhatsApp\";\nimport { StatusPresence, TypeMessage } from \"./types\";\n\nconst whatsapp = new WhatsApp({ server: \"\", key: \"\" });\n\nconst to = \"559999999999\" // If you want to send it to the group = 123456789@us\n\nwhatsapp.info().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.connect().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.logout().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.contacts().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.PRESENCE,\n body: {\n to: to,\n status: StatusPresence.COMPOSING\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n to: to,\n text: \"Hey\"\n }\n}).then((response) => {\n console.log(response)\n\n}).catch(console.error)\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_PIX,\n body: {\n to: \"14375223417\",\n title: \"Pizza\",\n text: \"Pizza \",\n referenceId: \"apiwame\",\n code: \"0020\",\n key: \"23711695000115\",\n merchantName: \"CACHE SISTEMAS WEB\",\n keyType: \"CNPJ\",\n items: [\n {\n id: \"123\",\n name: \"Pizza G\",\n price: 10,\n quantity: 10\n },\n ],\n subtotal: \"90\",\n totalAmount: \"100\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_PIX,\n body: {\n to: \"14375223417\",\n title: \"Pizza\",\n text: \"Pizza \",\n referenceId: \"apiwame\",\n code: \"0020\",\n key: \"23711695000115\",\n merchantName: \"CACHE SISTEMAS WEB\",\n keyType: \"CNPJ\",\n items: [\n {\n id: \"123\",\n name: \"Pizza G\",\n price: 10,\n quantity: 10\n },\n ],\n subtotal: \"90\",\n totalAmount: \"100\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_REPLY,\n body: {\n to: \"14375223417\",\n header: {\n title: \"Example Header\",\n },\n text: \"This is a test\",\n footer: \"choose an option\",\n buttons: [\n {\n type: \"quick_reply\",\n id: \"uniqId1\",\n text: \"Yes\"\n },\n {\n type: \"quick_reply\",\n id: \"uniqId2\",\n text: \"No\"\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_ACTION,\n body: {\n to: \"14375223417\",\n header: {\n title: \"Example Header\",\n },\n text: \"This is a test\",\n footer: \"choose an option\",\n buttons: [\n {\n type: \"cta_copy\",\n copy_code: \"1234567890\",\n text: \"Copy barcode\"\n },\n {\n type: \"cta_url\",\n url: \"https://api-wa.me\",\n text: \"Access the website\"\n },\n {\n type: \"cta_call\",\n phone_number: \"+5566996852025\",\n text: \"Call us\"\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.MENU,\n body: {\n to: \"14375223417\",\n buttonText: \"Menu\",\n text: \"string\",\n title: \"Menu\",\n description: \"Description\",\n footer: \"footer\",\n sections: [\n {\n title: \"Pizza\",\n rows: [\n {\n title: \"Pizza 01\",\n description: \"Example pizza 01\",\n rowId: \"1\"\n }\n ]\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.POLL,\n body: {\n to: \"14375223417\",\n name: \"Do you like PHP?\",\n options: [\n \"Yes\",\n \"No\"\n ],\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n msgId: \"SKJH455AJKJ\",\n to: to,\n text: \"Hey\"\n }\n}, true).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.AUDIO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.IMAGE,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.VIDEO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.DOCUMENT,\n body: {\n to: to,\n url: \"\",\n mimetype: \"\",\n fileName: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.CONTACT,\n body: {\n to: to,\n contact: {\n fullName: \"Raphael\",\n phoneNumber: to,\n organization: \"api-wa.me\"\n }\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.REACTION,\n body: {\n to: to,\n msgId: \"ASDDF872AHDURBSG\",\n text: \"🤖\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.groups().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.infoGroup(\"123456789@us\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.createGroup(\"Devs\", [to]).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.updateGroup(\"123456789@us\", \"Devs\", \"Only developers !\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\n"]}
|