@green-api/greenapi-integration 0.3.0 → 0.5.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.
@@ -1,7 +1,8 @@
1
- import { Instance, Settings, SendMessage, SendFileByUrl, SendFileByUpload, SendPoll, StateInstance, Reboot, Logout, QR, SendResponse, SendFileByUploadResponse, SetSettingsResponse, GetAuthorizationCode, SetProfilePicture, WaSettings, UploadFile, SendLocation, SendContact, ForwardMessages, ForwardMessagesResponse } from "../types/types";
1
+ import { Instance, Settings, SendMessage, SendFileByUrl, SendFileByUpload, SendPoll, StateInstance, Reboot, Logout, QR, SendResponse, SendFileByUploadResponse, SetSettingsResponse, GetAuthorizationCode, SetProfilePicture, WaSettings, UploadFile, SendLocation, SendContact, ForwardMessages, ForwardMessagesResponse, QueueMessage, ClearMessagesQueue, ReadChatResponse, ReadChat, CheckWhatsapp, CheckWhatsappResponse, GetAvatarResponse, GetAvatar, Contact, ContactInfo, ArchiveChat, UnarchiveChat, SetDisappearingChat, SetDisappearingChatResponse, CreateGroupResponse, CreateGroup, UpdateGroupName, UpdateGroupNameResponse, GetGroupData, GroupData, AddGroupParticipant, AddGroupParticipantResponse, RemoveGroupParticipant, RemoveGroupParticipantResponse, SetGroupAdmin, SetGroupAdminResponse, RemoveAdminResponse, RemoveAdmin, SetGroupPicture, SetGroupPictureResponse, LeaveGroup, LeaveGroupResponse, GetMessage, JournalResponse, GetChatHistory, IncomingJournalResponse, OutgoingJournalResponse } from "../types/types";
2
2
  /**
3
3
  * Client for direct interaction with GREEN-API's WhatsApp gateway.
4
4
  * Provides methods for sending messages, managing instances, and handling files.
5
+ * For more information about the methods, refer to https://green-api.com/en/docs
5
6
  *
6
7
  * @category Client
7
8
  *
@@ -213,4 +214,227 @@ export declare class GreenApiClient {
213
214
  * @throws {Error} If phone number is not an integer
214
215
  */
215
216
  getAuthorizationCode(phoneNumber: number): Promise<GetAuthorizationCode>;
217
+ /**
218
+ * Gets the list of messages in the sending queue.
219
+ * Messages are stored for 24 hours and will be sent immediately after phone authorization.
220
+ * The sending speed is regulated by the Message Sending Interval parameter.
221
+ *
222
+ * @returns Promise resolving to an array of queued messages
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * const queuedMessages = await client.showMessagesQueue();
227
+ * console.log(queuedMessages);
228
+ * ```
229
+ */
230
+ showMessagesQueue(): Promise<QueueMessage[]>;
231
+ /**
232
+ * Clears the queue of messages waiting to be sent.
233
+ * Important when switching phone numbers to prevent sending queued messages with the new number.
234
+ *
235
+ * @returns Promise resolving to queue clearing status
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const result = await client.clearMessagesQueue();
240
+ * if (result.isCleared) {
241
+ * console.log('Queue successfully cleared');
242
+ * }
243
+ * ```
244
+ */
245
+ clearMessagesQueue(): Promise<ClearMessagesQueue>;
246
+ /**
247
+ * Marks messages in a chat as read.
248
+ * For this to work, "Receive webhooks on incoming messages and files" setting must be enabled.
249
+ * Note: Only messages received after enabling the setting can be marked as read.
250
+ *
251
+ * @param params - Parameters specifying which messages to mark as read
252
+ * @returns Promise resolving to read status
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * // Mark all messages in chat as read
257
+ * const result = await client.readChat({
258
+ * chatId: "1234567890@c.us"
259
+ * });
260
+ *
261
+ * // Mark specific message as read
262
+ * const result = await client.readChat({
263
+ * chatId: "1234567890@c.us",
264
+ * idMessage: "B275A7AA0D6EF89BB9245169BDF174E6"
265
+ * });
266
+ * ```
267
+ */
268
+ readChat(params: ReadChat): Promise<ReadChatResponse>;
269
+ /**
270
+ * Checks WhatsApp account availability on a phone number.
271
+ *
272
+ * @param params - Parameters containing the phone number to check
273
+ * @returns Promise resolving to WhatsApp availability status
274
+ * @throws {Error} If phone number is not an integer or not 11-12 digits
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * const result = await client.checkWhatsapp({
279
+ * phoneNumber: 11001234567
280
+ * });
281
+ *
282
+ * if (result.existsWhatsapp) {
283
+ * console.log('WhatsApp account exists');
284
+ * }
285
+ * ```
286
+ */
287
+ checkWhatsapp(params: CheckWhatsapp): Promise<CheckWhatsappResponse>;
288
+ /**
289
+ * Gets a user or group chat avatar.
290
+ *
291
+ * @param params - Parameters containing the chat ID
292
+ * @returns Promise resolving to avatar information
293
+ */
294
+ getAvatar(params: GetAvatar): Promise<GetAvatarResponse>;
295
+ /**
296
+ * Gets a list of the current account contacts.
297
+ * Note: Contact information updates can take up to 5 minutes.
298
+ * If an empty array is received, retry the method call.
299
+ *
300
+ * @returns Promise resolving to array of contacts
301
+ */
302
+ getContacts(): Promise<Contact[]>;
303
+ /**
304
+ * Gets detailed information about a contact.
305
+ * Note: This method does not support group chats, use getGroupData for groups.
306
+ *
307
+ * @param params - Parameters containing the chat ID
308
+ * @returns Promise resolving to contact information
309
+ */
310
+ getContactInfo(params: GetAvatar): Promise<ContactInfo>;
311
+ /**
312
+ * Archives a chat. Chat must have at least one incoming message.
313
+ * Note: "Receive webhooks on incoming messages and files" setting must be enabled.
314
+ *
315
+ * @param params - Parameters containing the chat ID to archive
316
+ * @returns Promise resolving to void on success
317
+ */
318
+ archiveChat(params: ArchiveChat): Promise<void>;
319
+ /**
320
+ * Unarchives a chat.
321
+ *
322
+ * @param params - Parameters containing the chat ID to unarchive
323
+ * @returns Promise resolving to void on success
324
+ */
325
+ unarchiveChat(params: UnarchiveChat): Promise<void>;
326
+ /**
327
+ * Changes settings of disappearing messages in chats.
328
+ * Valid expiration times: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
329
+ *
330
+ * @param params - Parameters containing chat ID and message expiration time
331
+ * @returns Promise resolving to chat disappearing message settings
332
+ */
333
+ setDisappearingChat(params: SetDisappearingChat): Promise<SetDisappearingChatResponse>;
334
+ /**
335
+ * Creates a group chat.
336
+ * Note: Limited to creating 1 group per 5 minutes to simulate human behavior.
337
+ *
338
+ * @param params - Parameters containing group name and participant IDs
339
+ * @returns Promise resolving to group creation result
340
+ */
341
+ createGroup(params: CreateGroup): Promise<CreateGroupResponse>;
342
+ /**
343
+ * Changes a group chat name.
344
+ *
345
+ * @param params - Parameters containing group ID and new name
346
+ * @returns Promise resolving to update status
347
+ */
348
+ updateGroupName(params: UpdateGroupName): Promise<UpdateGroupNameResponse>;
349
+ /**
350
+ * Gets group chat data.
351
+ * Note: groupInviteLink will be empty if user is not an admin or owner.
352
+ *
353
+ * @param params - Parameters containing group ID
354
+ * @returns Promise resolving to group data
355
+ */
356
+ getGroupData(params: GetGroupData): Promise<GroupData>;
357
+ /**
358
+ * Adds a participant to a group chat.
359
+ * Note: Only group administrators can add members.
360
+ * The participant's number should be saved in the phonebook for reliable addition.
361
+ *
362
+ * @param params - Parameters containing group ID and participant ID
363
+ * @returns Promise resolving to addition status
364
+ */
365
+ addGroupParticipant(params: AddGroupParticipant): Promise<AddGroupParticipantResponse>;
366
+ /**
367
+ * Removes a participant from a group chat.
368
+ *
369
+ * @param params - Parameters containing group ID and participant ID to remove
370
+ * @returns Promise resolving to removal status
371
+ */
372
+ removeGroupParticipant(params: RemoveGroupParticipant): Promise<RemoveGroupParticipantResponse>;
373
+ /**
374
+ * Sets a group chat participant as an administrator.
375
+ *
376
+ * @param params - Parameters containing group ID and participant ID to promote
377
+ * @returns Promise resolving to admin status change result
378
+ */
379
+ setGroupAdmin(params: SetGroupAdmin): Promise<SetGroupAdminResponse>;
380
+ /**
381
+ * Removes administrator rights from a group chat participant.
382
+ *
383
+ * @param params - Parameters containing group ID and participant ID to demote
384
+ * @returns Promise resolving to admin removal status
385
+ */
386
+ removeAdmin(params: RemoveAdmin): Promise<RemoveAdminResponse>;
387
+ /**
388
+ * Sets a group chat picture.
389
+ *
390
+ * @param params - Parameters containing group ID and picture file (jpg)
391
+ * @returns Promise resolving to picture update status
392
+ */
393
+ setGroupPicture(params: SetGroupPicture): Promise<SetGroupPictureResponse>;
394
+ /**
395
+ * Makes the current account leave a group chat.
396
+ *
397
+ * @param params - Parameters containing the group ID to leave
398
+ * @returns Promise resolving to leave status
399
+ */
400
+ leaveGroup(params: LeaveGroup): Promise<LeaveGroupResponse>;
401
+ /**
402
+ * Gets details of a specific message.
403
+ * Note: To receive incoming webhooks, requires "Receive webhooks on incoming messages and files" setting to be enabled.
404
+ * Note: To receive statuses of sent messsages, requires "Receive notifications about the statuses of sent messages" to be enabled.
405
+ * Messages can take up to 2 minutes to appear in the journal.
406
+ *
407
+ * @param params - Parameters containing chat ID and message ID
408
+ * @returns Promise resolving to message details
409
+ */
410
+ getMessage(params: GetMessage): Promise<JournalResponse>;
411
+ /**
412
+ * Gets chat message history.
413
+ * Note: Requires "Receive webhooks" setting to be enabled.
414
+ * Messages can take up to 2 minutes to appear in history.
415
+ *
416
+ * @param params - Parameters containing chat ID and optional message count
417
+ * @returns Promise resolving to array of messages
418
+ */
419
+ getChatHistory(params: GetChatHistory): Promise<JournalResponse[]>;
420
+ /**
421
+ * Gets last incoming messages for the specified time period.
422
+ * Default is 24 hours (1440 minutes).
423
+ * Note: Requires "Receive webhooks" setting to be enabled.
424
+ * Messages can take up to 2 minutes to appear in history.
425
+ *
426
+ * @param minutes - Optional time period in minutes
427
+ * @returns Promise resolving to array of incoming messages
428
+ */
429
+ lastIncomingMessages(minutes?: number): Promise<IncomingJournalResponse[]>;
430
+ /**
431
+ * Gets last outgoing messages for the specified time period.
432
+ * Default is 24 hours (1440 minutes).
433
+ * Note: Requires "Receive webhooks" setting to be enabled.
434
+ * Messages can take up to 2 minutes to appear in history.
435
+ *
436
+ * @param minutes - Optional time period in minutes
437
+ * @returns Promise resolving to array of outgoing messages
438
+ */
439
+ lastOutgoingMessages(minutes?: number): Promise<OutgoingJournalResponse[]>;
216
440
  }
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GreenApiClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
+ const errors_1 = require("./errors");
8
9
  /**
9
10
  * Client for direct interaction with GREEN-API's WhatsApp gateway.
10
11
  * Provides methods for sending messages, managing instances, and handling files.
12
+ * For more information about the methods, refer to https://green-api.com/en/docs
11
13
  *
12
14
  * @category Client
13
15
  *
@@ -43,19 +45,20 @@ class GreenApiClient {
43
45
  buildEndpoint(endpoint) {
44
46
  return `/${endpoint}/${this.instance.apiTokenInstance}`;
45
47
  }
46
- async makeRequest(method, endpoint, data, config) {
48
+ async makeRequest(method, endpoint, data, queryParams, config) {
47
49
  try {
50
+ const url = this.buildEndpoint(endpoint) + (queryParams ? "?" + new URLSearchParams(Object.entries(queryParams).map(([key, value]) => [key, value.toString()])).toString() : "");
48
51
  const response = await (method === "get"
49
- ? this.client.get(this.buildEndpoint(endpoint), config)
50
- : this.client.post(this.buildEndpoint(endpoint), data, config));
52
+ ? this.client.get(url, config)
53
+ : this.client.post(url, data, config));
51
54
  return response.data;
52
55
  }
53
56
  catch (error) {
54
- throw new Error(`Failed to ${endpoint.replace(/([A-Z])/g, " $1").toLowerCase()}: ${error.message}. ${JSON.stringify(error.response?.data)}`);
57
+ throw new errors_1.IntegrationError(`Failed to ${endpoint.replace(/([A-Z])/g, " $1").toLowerCase()}: ${error.message}. ${JSON.stringify(error.response?.data)}`, "INTEGRATION_ERROR");
55
58
  }
56
59
  }
57
60
  async makeFileUploadRequest(endpoint, formData, headers) {
58
- return this.makeRequest("post", endpoint, formData, {
61
+ return this.makeRequest("post", endpoint, formData, undefined, {
59
62
  headers: { "Content-Type": "multipart/form-data" },
60
63
  ...headers,
61
64
  });
@@ -334,5 +337,284 @@ class GreenApiClient {
334
337
  }
335
338
  return this.makeRequest("post", "getAuthorizationCode", { phoneNumber });
336
339
  }
340
+ /**
341
+ * Gets the list of messages in the sending queue.
342
+ * Messages are stored for 24 hours and will be sent immediately after phone authorization.
343
+ * The sending speed is regulated by the Message Sending Interval parameter.
344
+ *
345
+ * @returns Promise resolving to an array of queued messages
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const queuedMessages = await client.showMessagesQueue();
350
+ * console.log(queuedMessages);
351
+ * ```
352
+ */
353
+ async showMessagesQueue() {
354
+ return this.makeRequest("get", "showMessagesQueue");
355
+ }
356
+ /**
357
+ * Clears the queue of messages waiting to be sent.
358
+ * Important when switching phone numbers to prevent sending queued messages with the new number.
359
+ *
360
+ * @returns Promise resolving to queue clearing status
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * const result = await client.clearMessagesQueue();
365
+ * if (result.isCleared) {
366
+ * console.log('Queue successfully cleared');
367
+ * }
368
+ * ```
369
+ */
370
+ async clearMessagesQueue() {
371
+ return this.makeRequest("get", "clearMessagesQueue");
372
+ }
373
+ /**
374
+ * Marks messages in a chat as read.
375
+ * For this to work, "Receive webhooks on incoming messages and files" setting must be enabled.
376
+ * Note: Only messages received after enabling the setting can be marked as read.
377
+ *
378
+ * @param params - Parameters specifying which messages to mark as read
379
+ * @returns Promise resolving to read status
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * // Mark all messages in chat as read
384
+ * const result = await client.readChat({
385
+ * chatId: "1234567890@c.us"
386
+ * });
387
+ *
388
+ * // Mark specific message as read
389
+ * const result = await client.readChat({
390
+ * chatId: "1234567890@c.us",
391
+ * idMessage: "B275A7AA0D6EF89BB9245169BDF174E6"
392
+ * });
393
+ * ```
394
+ */
395
+ async readChat(params) {
396
+ return this.makeRequest("post", "readChat", params);
397
+ }
398
+ /**
399
+ * Checks WhatsApp account availability on a phone number.
400
+ *
401
+ * @param params - Parameters containing the phone number to check
402
+ * @returns Promise resolving to WhatsApp availability status
403
+ * @throws {Error} If phone number is not an integer or not 11-12 digits
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const result = await client.checkWhatsapp({
408
+ * phoneNumber: 11001234567
409
+ * });
410
+ *
411
+ * if (result.existsWhatsapp) {
412
+ * console.log('WhatsApp account exists');
413
+ * }
414
+ * ```
415
+ */
416
+ async checkWhatsapp(params) {
417
+ const phoneStr = params.phoneNumber.toString();
418
+ if (!Number.isInteger(params.phoneNumber)) {
419
+ throw new Error("Phone number must contain only digits");
420
+ }
421
+ if (phoneStr.length < 11 || phoneStr.length > 12) {
422
+ throw new Error("Phone number must be 11 or 12 digits");
423
+ }
424
+ return this.makeRequest("post", "checkWhatsapp", params);
425
+ }
426
+ /**
427
+ * Gets a user or group chat avatar.
428
+ *
429
+ * @param params - Parameters containing the chat ID
430
+ * @returns Promise resolving to avatar information
431
+ */
432
+ async getAvatar(params) {
433
+ return this.makeRequest("post", "getAvatar", params);
434
+ }
435
+ /**
436
+ * Gets a list of the current account contacts.
437
+ * Note: Contact information updates can take up to 5 minutes.
438
+ * If an empty array is received, retry the method call.
439
+ *
440
+ * @returns Promise resolving to array of contacts
441
+ */
442
+ async getContacts() {
443
+ return this.makeRequest("get", "getContacts");
444
+ }
445
+ /**
446
+ * Gets detailed information about a contact.
447
+ * Note: This method does not support group chats, use getGroupData for groups.
448
+ *
449
+ * @param params - Parameters containing the chat ID
450
+ * @returns Promise resolving to contact information
451
+ */
452
+ async getContactInfo(params) {
453
+ return this.makeRequest("post", "getContactInfo", params);
454
+ }
455
+ /**
456
+ * Archives a chat. Chat must have at least one incoming message.
457
+ * Note: "Receive webhooks on incoming messages and files" setting must be enabled.
458
+ *
459
+ * @param params - Parameters containing the chat ID to archive
460
+ * @returns Promise resolving to void on success
461
+ */
462
+ async archiveChat(params) {
463
+ return this.makeRequest("post", "archiveChat", params);
464
+ }
465
+ /**
466
+ * Unarchives a chat.
467
+ *
468
+ * @param params - Parameters containing the chat ID to unarchive
469
+ * @returns Promise resolving to void on success
470
+ */
471
+ async unarchiveChat(params) {
472
+ return this.makeRequest("post", "unarchiveChat", params);
473
+ }
474
+ /**
475
+ * Changes settings of disappearing messages in chats.
476
+ * Valid expiration times: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
477
+ *
478
+ * @param params - Parameters containing chat ID and message expiration time
479
+ * @returns Promise resolving to chat disappearing message settings
480
+ */
481
+ async setDisappearingChat(params) {
482
+ return this.makeRequest("post", "setDisappearingChat", params);
483
+ }
484
+ /**
485
+ * Creates a group chat.
486
+ * Note: Limited to creating 1 group per 5 minutes to simulate human behavior.
487
+ *
488
+ * @param params - Parameters containing group name and participant IDs
489
+ * @returns Promise resolving to group creation result
490
+ */
491
+ async createGroup(params) {
492
+ return this.makeRequest("post", "createGroup", params);
493
+ }
494
+ /**
495
+ * Changes a group chat name.
496
+ *
497
+ * @param params - Parameters containing group ID and new name
498
+ * @returns Promise resolving to update status
499
+ */
500
+ async updateGroupName(params) {
501
+ return this.makeRequest("post", "updateGroupName", params);
502
+ }
503
+ /**
504
+ * Gets group chat data.
505
+ * Note: groupInviteLink will be empty if user is not an admin or owner.
506
+ *
507
+ * @param params - Parameters containing group ID
508
+ * @returns Promise resolving to group data
509
+ */
510
+ async getGroupData(params) {
511
+ return this.makeRequest("post", "getGroupData", params);
512
+ }
513
+ /**
514
+ * Adds a participant to a group chat.
515
+ * Note: Only group administrators can add members.
516
+ * The participant's number should be saved in the phonebook for reliable addition.
517
+ *
518
+ * @param params - Parameters containing group ID and participant ID
519
+ * @returns Promise resolving to addition status
520
+ */
521
+ async addGroupParticipant(params) {
522
+ return this.makeRequest("post", "addGroupParticipant", params);
523
+ }
524
+ /**
525
+ * Removes a participant from a group chat.
526
+ *
527
+ * @param params - Parameters containing group ID and participant ID to remove
528
+ * @returns Promise resolving to removal status
529
+ */
530
+ async removeGroupParticipant(params) {
531
+ return this.makeRequest("post", "removeGroupParticipant", params);
532
+ }
533
+ /**
534
+ * Sets a group chat participant as an administrator.
535
+ *
536
+ * @param params - Parameters containing group ID and participant ID to promote
537
+ * @returns Promise resolving to admin status change result
538
+ */
539
+ async setGroupAdmin(params) {
540
+ return this.makeRequest("post", "setGroupAdmin", params);
541
+ }
542
+ /**
543
+ * Removes administrator rights from a group chat participant.
544
+ *
545
+ * @param params - Parameters containing group ID and participant ID to demote
546
+ * @returns Promise resolving to admin removal status
547
+ */
548
+ async removeAdmin(params) {
549
+ return this.makeRequest("post", "removeAdmin", params);
550
+ }
551
+ /**
552
+ * Sets a group chat picture.
553
+ *
554
+ * @param params - Parameters containing group ID and picture file (jpg)
555
+ * @returns Promise resolving to picture update status
556
+ */
557
+ async setGroupPicture(params) {
558
+ const formData = new FormData();
559
+ formData.append("file", params.file);
560
+ formData.append("groupId", params.groupId);
561
+ return this.makeFileUploadRequest("setGroupPicture", formData);
562
+ }
563
+ /**
564
+ * Makes the current account leave a group chat.
565
+ *
566
+ * @param params - Parameters containing the group ID to leave
567
+ * @returns Promise resolving to leave status
568
+ */
569
+ async leaveGroup(params) {
570
+ return this.makeRequest("post", "leaveGroup", params);
571
+ }
572
+ /**
573
+ * Gets details of a specific message.
574
+ * Note: To receive incoming webhooks, requires "Receive webhooks on incoming messages and files" setting to be enabled.
575
+ * Note: To receive statuses of sent messsages, requires "Receive notifications about the statuses of sent messages" to be enabled.
576
+ * Messages can take up to 2 minutes to appear in the journal.
577
+ *
578
+ * @param params - Parameters containing chat ID and message ID
579
+ * @returns Promise resolving to message details
580
+ */
581
+ async getMessage(params) {
582
+ return this.makeRequest("post", "getMessage", params);
583
+ }
584
+ /**
585
+ * Gets chat message history.
586
+ * Note: Requires "Receive webhooks" setting to be enabled.
587
+ * Messages can take up to 2 minutes to appear in history.
588
+ *
589
+ * @param params - Parameters containing chat ID and optional message count
590
+ * @returns Promise resolving to array of messages
591
+ */
592
+ async getChatHistory(params) {
593
+ return this.makeRequest("post", "getChatHistory", params);
594
+ }
595
+ /**
596
+ * Gets last incoming messages for the specified time period.
597
+ * Default is 24 hours (1440 minutes).
598
+ * Note: Requires "Receive webhooks" setting to be enabled.
599
+ * Messages can take up to 2 minutes to appear in history.
600
+ *
601
+ * @param minutes - Optional time period in minutes
602
+ * @returns Promise resolving to array of incoming messages
603
+ */
604
+ async lastIncomingMessages(minutes) {
605
+ return this.makeRequest("get", "lastIncomingMessages", undefined, minutes ? { minutes } : undefined);
606
+ }
607
+ /**
608
+ * Gets last outgoing messages for the specified time period.
609
+ * Default is 24 hours (1440 minutes).
610
+ * Note: Requires "Receive webhooks" setting to be enabled.
611
+ * Messages can take up to 2 minutes to appear in history.
612
+ *
613
+ * @param minutes - Optional time period in minutes
614
+ * @returns Promise resolving to array of outgoing messages
615
+ */
616
+ async lastOutgoingMessages(minutes) {
617
+ return this.makeRequest("get", "lastOutgoingMessages", undefined, minutes ? { minutes } : undefined);
618
+ }
337
619
  }
338
620
  exports.GreenApiClient = GreenApiClient;
@@ -25,10 +25,9 @@ export declare abstract class StorageProvider<TUser extends BaseUser = BaseUser,
25
25
  * Creates a new instance in storage.
26
26
  *
27
27
  * @param instance - The instance data to store
28
- * @param userId - ID of the user who owns this instance
29
28
  * @returns Promise resolving to the created instance
30
29
  */
31
- abstract createInstance(instance: Instance, userId: bigint | number): Promise<TInstance>;
30
+ abstract createInstance(instance: Instance): Promise<TInstance>;
32
31
  /**
33
32
  * Retrieves an instance by its ID.
34
33
  *