botcast-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +257 -0
  3. package/dist/client.cjs +91 -0
  4. package/dist/client.d.ts +64 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +87 -0
  7. package/dist/errors.cjs +59 -0
  8. package/dist/errors.d.ts +25 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +49 -0
  11. package/dist/index.cjs +26 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +7 -0
  15. package/dist/modules/base.cjs +113 -0
  16. package/dist/modules/base.d.ts +22 -0
  17. package/dist/modules/base.d.ts.map +1 -0
  18. package/dist/modules/base.js +109 -0
  19. package/dist/modules/broadcast.cjs +30 -0
  20. package/dist/modules/broadcast.d.ts +27 -0
  21. package/dist/modules/broadcast.d.ts.map +1 -0
  22. package/dist/modules/broadcast.js +26 -0
  23. package/dist/modules/chats.cjs +113 -0
  24. package/dist/modules/chats.d.ts +106 -0
  25. package/dist/modules/chats.d.ts.map +1 -0
  26. package/dist/modules/chats.js +109 -0
  27. package/dist/modules/groups.cjs +200 -0
  28. package/dist/modules/groups.d.ts +139 -0
  29. package/dist/modules/groups.d.ts.map +1 -0
  30. package/dist/modules/groups.js +196 -0
  31. package/dist/modules/instances.cjs +138 -0
  32. package/dist/modules/instances.d.ts +91 -0
  33. package/dist/modules/instances.d.ts.map +1 -0
  34. package/dist/modules/instances.js +134 -0
  35. package/dist/modules/messages.cjs +217 -0
  36. package/dist/modules/messages.d.ts +155 -0
  37. package/dist/modules/messages.d.ts.map +1 -0
  38. package/dist/modules/messages.js +213 -0
  39. package/dist/modules/profile.cjs +129 -0
  40. package/dist/modules/profile.d.ts +92 -0
  41. package/dist/modules/profile.d.ts.map +1 -0
  42. package/dist/modules/profile.js +125 -0
  43. package/dist/types/chats.cjs +2 -0
  44. package/dist/types/chats.d.ts +62 -0
  45. package/dist/types/chats.d.ts.map +1 -0
  46. package/dist/types/chats.js +1 -0
  47. package/dist/types/groups.cjs +2 -0
  48. package/dist/types/groups.d.ts +47 -0
  49. package/dist/types/groups.d.ts.map +1 -0
  50. package/dist/types/groups.js +1 -0
  51. package/dist/types/index.cjs +22 -0
  52. package/dist/types/index.d.ts +34 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/index.js +6 -0
  55. package/dist/types/instances.cjs +2 -0
  56. package/dist/types/instances.d.ts +65 -0
  57. package/dist/types/instances.d.ts.map +1 -0
  58. package/dist/types/instances.js +1 -0
  59. package/dist/types/messages.cjs +2 -0
  60. package/dist/types/messages.d.ts +86 -0
  61. package/dist/types/messages.d.ts.map +1 -0
  62. package/dist/types/messages.js +1 -0
  63. package/dist/types/profile.cjs +2 -0
  64. package/dist/types/profile.d.ts +25 -0
  65. package/dist/types/profile.d.ts.map +1 -0
  66. package/dist/types/profile.js +1 -0
  67. package/dist/types/webhooks.cjs +2 -0
  68. package/dist/types/webhooks.d.ts +17 -0
  69. package/dist/types/webhooks.d.ts.map +1 -0
  70. package/dist/types/webhooks.js +1 -0
  71. package/dist/webhooks/index.cjs +71 -0
  72. package/dist/webhooks/index.d.ts +26 -0
  73. package/dist/webhooks/index.d.ts.map +1 -0
  74. package/dist/webhooks/index.js +67 -0
  75. package/package.json +61 -0
@@ -0,0 +1,109 @@
1
+ import { BaseModule } from './base.js';
2
+ export class ChatsModule extends BaseModule {
3
+ /**
4
+ * Lists synced WhatsApp chats with optional search and pagination.
5
+ */
6
+ async list(params) {
7
+ return this.request({
8
+ method: 'GET',
9
+ path: this.buildPath('chats'),
10
+ query: params,
11
+ });
12
+ }
13
+ /**
14
+ * Lists synced WhatsApp contacts.
15
+ */
16
+ async listContacts(params) {
17
+ return this.request({
18
+ method: 'GET',
19
+ path: this.buildPath('contacts'),
20
+ query: params,
21
+ });
22
+ }
23
+ /**
24
+ * Lists synced chat messages.
25
+ */
26
+ async listMessages(params) {
27
+ return this.request({
28
+ method: 'GET',
29
+ path: this.buildPath('messages'),
30
+ query: params,
31
+ });
32
+ }
33
+ /**
34
+ * Modifies a chat state (archive, mute, read, pin, star, delete).
35
+ */
36
+ async modify(options) {
37
+ return this.request({
38
+ method: 'POST',
39
+ path: this.buildPath('chats/modify'),
40
+ body: options,
41
+ });
42
+ }
43
+ /**
44
+ * Archives a chat.
45
+ */
46
+ async archive(targetJid) {
47
+ return this.modify({ jid: targetJid, action: 'archive' });
48
+ }
49
+ /**
50
+ * Unarchives a chat.
51
+ */
52
+ async unarchive(targetJid) {
53
+ return this.modify({ jid: targetJid, action: 'unarchive' });
54
+ }
55
+ /**
56
+ * Mutes chat notifications for a specified duration in milliseconds (default: 8 hours).
57
+ */
58
+ async mute(targetJid, durationMs = 8 * 60 * 60 * 1000) {
59
+ return this.modify({ jid: targetJid, action: 'mute', duration: durationMs });
60
+ }
61
+ /**
62
+ * Unmutes chat notifications.
63
+ */
64
+ async unmute(targetJid) {
65
+ return this.modify({ jid: targetJid, action: 'unmute' });
66
+ }
67
+ /**
68
+ * Pins a chat to the top of the chat list.
69
+ */
70
+ async pin(targetJid) {
71
+ return this.modify({ jid: targetJid, action: 'pin', isPin: true });
72
+ }
73
+ /**
74
+ * Unpins a chat from the top.
75
+ */
76
+ async unpin(targetJid) {
77
+ return this.modify({ jid: targetJid, action: 'unpin' });
78
+ }
79
+ /**
80
+ * Deletes an entire chat conversation.
81
+ */
82
+ async deleteChat(targetJid) {
83
+ return this.modify({ jid: targetJid, action: 'delete_chat' });
84
+ }
85
+ /**
86
+ * Configures disappearing messages for a chat.
87
+ *
88
+ * @param recipient Target chat JID or phone number
89
+ * @param duration Duration in seconds (86400: 24h, 604800: 7d, 7776000: 90d)
90
+ * @param enabled Whether disappearing messages is enabled (default: true)
91
+ */
92
+ async setDisappearing(recipient, duration = 86400, enabled = true) {
93
+ return this.request({
94
+ method: 'POST',
95
+ path: this.buildPath('chats/disappearing'),
96
+ body: { recipient, duration, enabled },
97
+ });
98
+ }
99
+ /**
100
+ * Requests older chat history from the linked phone.
101
+ */
102
+ async fetchHistory(options) {
103
+ return this.request({
104
+ method: 'POST',
105
+ path: this.buildPath('chats/fetch-history'),
106
+ body: options || {},
107
+ });
108
+ }
109
+ }
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupsModule = void 0;
4
+ const base_js_1 = require("./base.js");
5
+ class GroupsModule extends base_js_1.BaseModule {
6
+ /**
7
+ * Creates a new WhatsApp group.
8
+ *
9
+ * @param subject Group title / name
10
+ * @param participants Array of participant phone numbers with country codes
11
+ */
12
+ async create(subject, participants) {
13
+ return this.request({
14
+ method: 'POST',
15
+ path: this.buildPath('groups/create'),
16
+ body: { subject, participants },
17
+ });
18
+ }
19
+ /**
20
+ * Fetches all WhatsApp groups that the connected instance is participating in.
21
+ */
22
+ async list() {
23
+ return this.request({
24
+ method: 'GET',
25
+ path: this.buildPath('groups/list'),
26
+ });
27
+ }
28
+ /**
29
+ * Retrieves complete group metadata (participants, description, settings, admins).
30
+ */
31
+ async getMetadata(groupJid) {
32
+ return this.request({
33
+ method: 'GET',
34
+ path: this.buildPath('groups/metadata'),
35
+ query: { jid: groupJid },
36
+ });
37
+ }
38
+ /**
39
+ * Updates participants in a group (add, remove, promote to admin, demote).
40
+ */
41
+ async updateParticipants(groupJid, participants, action) {
42
+ return this.request({
43
+ method: 'POST',
44
+ path: this.buildPath('groups/participants'),
45
+ body: { jid: groupJid, participants, action },
46
+ });
47
+ }
48
+ /**
49
+ * Adds members to a group.
50
+ */
51
+ async addParticipants(groupJid, participants) {
52
+ return this.updateParticipants(groupJid, participants, 'add');
53
+ }
54
+ /**
55
+ * Removes members from a group.
56
+ */
57
+ async removeParticipants(groupJid, participants) {
58
+ return this.updateParticipants(groupJid, participants, 'remove');
59
+ }
60
+ /**
61
+ * Promotes members to group administrators.
62
+ */
63
+ async promoteParticipants(groupJid, participants) {
64
+ return this.updateParticipants(groupJid, participants, 'promote');
65
+ }
66
+ /**
67
+ * Demotes group administrators back to regular members.
68
+ */
69
+ async demoteParticipants(groupJid, participants) {
70
+ return this.updateParticipants(groupJid, participants, 'demote');
71
+ }
72
+ /**
73
+ * Changes the group subject / title.
74
+ */
75
+ async updateSubject(groupJid, subject) {
76
+ return this.request({
77
+ method: 'POST',
78
+ path: this.buildPath('groups/subject'),
79
+ body: { jid: groupJid, subject },
80
+ });
81
+ }
82
+ /**
83
+ * Updates the group description.
84
+ */
85
+ async updateDescription(groupJid, description) {
86
+ return this.request({
87
+ method: 'POST',
88
+ path: this.buildPath('groups/description'),
89
+ body: { jid: groupJid, description },
90
+ });
91
+ }
92
+ /**
93
+ * Updates group permissions / settings:
94
+ * - `announcement`: Only admins can send messages
95
+ * - `not_announcement`: All members can send messages
96
+ * - `locked`: Only admins can edit group info
97
+ * - `unlocked`: All members can edit group info
98
+ */
99
+ async updateSettings(groupJid, setting) {
100
+ return this.request({
101
+ method: 'POST',
102
+ path: this.buildPath('groups/settings'),
103
+ body: { jid: groupJid, setting },
104
+ });
105
+ }
106
+ /**
107
+ * Leaves a WhatsApp group.
108
+ */
109
+ async leave(groupJid) {
110
+ return this.request({
111
+ method: 'POST',
112
+ path: this.buildPath('groups/leave'),
113
+ body: { jid: groupJid },
114
+ });
115
+ }
116
+ /**
117
+ * Gets the invite code and shareable invite link for a group.
118
+ */
119
+ async getInviteCode(groupJid) {
120
+ return this.request({
121
+ method: 'POST',
122
+ path: this.buildPath('groups/invite'),
123
+ body: { action: 'get_code', jid: groupJid },
124
+ });
125
+ }
126
+ /**
127
+ * Revokes the current invite code and creates a new one.
128
+ */
129
+ async revokeInviteCode(groupJid) {
130
+ return this.request({
131
+ method: 'POST',
132
+ path: this.buildPath('groups/invite'),
133
+ body: { action: 'revoke', jid: groupJid },
134
+ });
135
+ }
136
+ /**
137
+ * Joins a group using an invite code.
138
+ */
139
+ async acceptInvite(code) {
140
+ return this.request({
141
+ method: 'POST',
142
+ path: this.buildPath('groups/invite'),
143
+ body: { action: 'accept', code },
144
+ });
145
+ }
146
+ /**
147
+ * Inspects group metadata using an invite code before joining.
148
+ */
149
+ async getInviteInfo(code) {
150
+ return this.request({
151
+ method: 'POST',
152
+ path: this.buildPath('groups/invite'),
153
+ body: { action: 'inspect', code },
154
+ });
155
+ }
156
+ /**
157
+ * Gets pending participant join requests (for groups with admin approval enabled).
158
+ */
159
+ async getJoinRequests(groupJid) {
160
+ return this.request({
161
+ method: 'GET',
162
+ path: this.buildPath('groups/join-requests'),
163
+ query: { jid: groupJid },
164
+ });
165
+ }
166
+ /**
167
+ * Approves or rejects participant join requests.
168
+ */
169
+ async updateJoinRequests(groupJid, participants, action) {
170
+ return this.request({
171
+ method: 'POST',
172
+ path: this.buildPath('groups/join-requests'),
173
+ body: { jid: groupJid, participants, action },
174
+ });
175
+ }
176
+ /**
177
+ * Configures disappearing messages for a group.
178
+ *
179
+ * @param groupJid Group JID
180
+ * @param durationSeconds 0 for off, 86400 (24h), 604800 (7d), 7776000 (90d)
181
+ */
182
+ async setEphemeral(groupJid, durationSeconds) {
183
+ return this.request({
184
+ method: 'POST',
185
+ path: this.buildPath('groups/ephemeral'),
186
+ body: { jid: groupJid, duration: durationSeconds },
187
+ });
188
+ }
189
+ /**
190
+ * Configures member add mode (`all_member_add` or `admin_add`).
191
+ */
192
+ async setMemberAddMode(groupJid, mode) {
193
+ return this.request({
194
+ method: 'POST',
195
+ path: this.buildPath('groups/member-add-mode'),
196
+ body: { jid: groupJid, mode },
197
+ });
198
+ }
199
+ }
200
+ exports.GroupsModule = GroupsModule;
@@ -0,0 +1,139 @@
1
+ import { BaseModule } from './base.js';
2
+ import { CreateGroupResponse, GroupMetadata, GroupParticipantAction, GroupSetting, GroupMemberAddMode, GroupInviteCodeResponse, JoinRequestItem } from '../types/index.js';
3
+ export declare class GroupsModule extends BaseModule {
4
+ /**
5
+ * Creates a new WhatsApp group.
6
+ *
7
+ * @param subject Group title / name
8
+ * @param participants Array of participant phone numbers with country codes
9
+ */
10
+ create(subject: string, participants: string[]): Promise<CreateGroupResponse>;
11
+ /**
12
+ * Fetches all WhatsApp groups that the connected instance is participating in.
13
+ */
14
+ list(): Promise<{
15
+ success: boolean;
16
+ total: number;
17
+ groups: Record<string, GroupMetadata>;
18
+ }>;
19
+ /**
20
+ * Retrieves complete group metadata (participants, description, settings, admins).
21
+ */
22
+ getMetadata(groupJid: string): Promise<{
23
+ success: boolean;
24
+ metadata: GroupMetadata;
25
+ }>;
26
+ /**
27
+ * Updates participants in a group (add, remove, promote to admin, demote).
28
+ */
29
+ updateParticipants(groupJid: string, participants: string[], action: GroupParticipantAction): Promise<{
30
+ success: boolean;
31
+ message: string;
32
+ result?: any;
33
+ }>;
34
+ /**
35
+ * Adds members to a group.
36
+ */
37
+ addParticipants(groupJid: string, participants: string[]): Promise<any>;
38
+ /**
39
+ * Removes members from a group.
40
+ */
41
+ removeParticipants(groupJid: string, participants: string[]): Promise<any>;
42
+ /**
43
+ * Promotes members to group administrators.
44
+ */
45
+ promoteParticipants(groupJid: string, participants: string[]): Promise<any>;
46
+ /**
47
+ * Demotes group administrators back to regular members.
48
+ */
49
+ demoteParticipants(groupJid: string, participants: string[]): Promise<any>;
50
+ /**
51
+ * Changes the group subject / title.
52
+ */
53
+ updateSubject(groupJid: string, subject: string): Promise<{
54
+ success: boolean;
55
+ message: string;
56
+ }>;
57
+ /**
58
+ * Updates the group description.
59
+ */
60
+ updateDescription(groupJid: string, description: string): Promise<{
61
+ success: boolean;
62
+ message: string;
63
+ }>;
64
+ /**
65
+ * Updates group permissions / settings:
66
+ * - `announcement`: Only admins can send messages
67
+ * - `not_announcement`: All members can send messages
68
+ * - `locked`: Only admins can edit group info
69
+ * - `unlocked`: All members can edit group info
70
+ */
71
+ updateSettings(groupJid: string, setting: GroupSetting): Promise<{
72
+ success: boolean;
73
+ message: string;
74
+ }>;
75
+ /**
76
+ * Leaves a WhatsApp group.
77
+ */
78
+ leave(groupJid: string): Promise<{
79
+ success: boolean;
80
+ message: string;
81
+ }>;
82
+ /**
83
+ * Gets the invite code and shareable invite link for a group.
84
+ */
85
+ getInviteCode(groupJid: string): Promise<GroupInviteCodeResponse>;
86
+ /**
87
+ * Revokes the current invite code and creates a new one.
88
+ */
89
+ revokeInviteCode(groupJid: string): Promise<GroupInviteCodeResponse>;
90
+ /**
91
+ * Joins a group using an invite code.
92
+ */
93
+ acceptInvite(code: string): Promise<{
94
+ success: boolean;
95
+ message: string;
96
+ result?: any;
97
+ }>;
98
+ /**
99
+ * Inspects group metadata using an invite code before joining.
100
+ */
101
+ getInviteInfo(code: string): Promise<{
102
+ success: boolean;
103
+ groupInfo: any;
104
+ }>;
105
+ /**
106
+ * Gets pending participant join requests (for groups with admin approval enabled).
107
+ */
108
+ getJoinRequests(groupJid: string): Promise<{
109
+ success: boolean;
110
+ groupJid: string;
111
+ pendingRequests: JoinRequestItem[];
112
+ }>;
113
+ /**
114
+ * Approves or rejects participant join requests.
115
+ */
116
+ updateJoinRequests(groupJid: string, participants: string[], action: 'approve' | 'reject'): Promise<{
117
+ success: boolean;
118
+ message: string;
119
+ result?: any;
120
+ }>;
121
+ /**
122
+ * Configures disappearing messages for a group.
123
+ *
124
+ * @param groupJid Group JID
125
+ * @param durationSeconds 0 for off, 86400 (24h), 604800 (7d), 7776000 (90d)
126
+ */
127
+ setEphemeral(groupJid: string, durationSeconds: number): Promise<{
128
+ success: boolean;
129
+ message: string;
130
+ }>;
131
+ /**
132
+ * Configures member add mode (`all_member_add` or `admin_add`).
133
+ */
134
+ setMemberAddMode(groupJid: string, mode: GroupMemberAddMode): Promise<{
135
+ success: boolean;
136
+ message: string;
137
+ }>;
138
+ }
139
+ //# sourceMappingURL=groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../src/modules/groups.ts"],"names":[],"mappings":"AAAA,OAAO,E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OAAO,CAAC;QAAC,SAAS,EAAE,GAAG,CAAA;KAAE,CAAC,CAMtF;IAED;;OAEG;IACU,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC,CAMlI;IAED;;OAEG;IACU,kBAAkB,CAC7B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EAAE,EACtB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAC3B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAM9D;IAED;;;;;OAKG;IACU,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAMnH;IAED;;OAEG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAMxH;CACF"}
@@ -0,0 +1,196 @@
1
+ import { BaseModule } from './base.js';
2
+ export class GroupsModule extends BaseModule {
3
+ /**
4
+ * Creates a new WhatsApp group.
5
+ *
6
+ * @param subject Group title / name
7
+ * @param participants Array of participant phone numbers with country codes
8
+ */
9
+ async create(subject, participants) {
10
+ return this.request({
11
+ method: 'POST',
12
+ path: this.buildPath('groups/create'),
13
+ body: { subject, participants },
14
+ });
15
+ }
16
+ /**
17
+ * Fetches all WhatsApp groups that the connected instance is participating in.
18
+ */
19
+ async list() {
20
+ return this.request({
21
+ method: 'GET',
22
+ path: this.buildPath('groups/list'),
23
+ });
24
+ }
25
+ /**
26
+ * Retrieves complete group metadata (participants, description, settings, admins).
27
+ */
28
+ async getMetadata(groupJid) {
29
+ return this.request({
30
+ method: 'GET',
31
+ path: this.buildPath('groups/metadata'),
32
+ query: { jid: groupJid },
33
+ });
34
+ }
35
+ /**
36
+ * Updates participants in a group (add, remove, promote to admin, demote).
37
+ */
38
+ async updateParticipants(groupJid, participants, action) {
39
+ return this.request({
40
+ method: 'POST',
41
+ path: this.buildPath('groups/participants'),
42
+ body: { jid: groupJid, participants, action },
43
+ });
44
+ }
45
+ /**
46
+ * Adds members to a group.
47
+ */
48
+ async addParticipants(groupJid, participants) {
49
+ return this.updateParticipants(groupJid, participants, 'add');
50
+ }
51
+ /**
52
+ * Removes members from a group.
53
+ */
54
+ async removeParticipants(groupJid, participants) {
55
+ return this.updateParticipants(groupJid, participants, 'remove');
56
+ }
57
+ /**
58
+ * Promotes members to group administrators.
59
+ */
60
+ async promoteParticipants(groupJid, participants) {
61
+ return this.updateParticipants(groupJid, participants, 'promote');
62
+ }
63
+ /**
64
+ * Demotes group administrators back to regular members.
65
+ */
66
+ async demoteParticipants(groupJid, participants) {
67
+ return this.updateParticipants(groupJid, participants, 'demote');
68
+ }
69
+ /**
70
+ * Changes the group subject / title.
71
+ */
72
+ async updateSubject(groupJid, subject) {
73
+ return this.request({
74
+ method: 'POST',
75
+ path: this.buildPath('groups/subject'),
76
+ body: { jid: groupJid, subject },
77
+ });
78
+ }
79
+ /**
80
+ * Updates the group description.
81
+ */
82
+ async updateDescription(groupJid, description) {
83
+ return this.request({
84
+ method: 'POST',
85
+ path: this.buildPath('groups/description'),
86
+ body: { jid: groupJid, description },
87
+ });
88
+ }
89
+ /**
90
+ * Updates group permissions / settings:
91
+ * - `announcement`: Only admins can send messages
92
+ * - `not_announcement`: All members can send messages
93
+ * - `locked`: Only admins can edit group info
94
+ * - `unlocked`: All members can edit group info
95
+ */
96
+ async updateSettings(groupJid, setting) {
97
+ return this.request({
98
+ method: 'POST',
99
+ path: this.buildPath('groups/settings'),
100
+ body: { jid: groupJid, setting },
101
+ });
102
+ }
103
+ /**
104
+ * Leaves a WhatsApp group.
105
+ */
106
+ async leave(groupJid) {
107
+ return this.request({
108
+ method: 'POST',
109
+ path: this.buildPath('groups/leave'),
110
+ body: { jid: groupJid },
111
+ });
112
+ }
113
+ /**
114
+ * Gets the invite code and shareable invite link for a group.
115
+ */
116
+ async getInviteCode(groupJid) {
117
+ return this.request({
118
+ method: 'POST',
119
+ path: this.buildPath('groups/invite'),
120
+ body: { action: 'get_code', jid: groupJid },
121
+ });
122
+ }
123
+ /**
124
+ * Revokes the current invite code and creates a new one.
125
+ */
126
+ async revokeInviteCode(groupJid) {
127
+ return this.request({
128
+ method: 'POST',
129
+ path: this.buildPath('groups/invite'),
130
+ body: { action: 'revoke', jid: groupJid },
131
+ });
132
+ }
133
+ /**
134
+ * Joins a group using an invite code.
135
+ */
136
+ async acceptInvite(code) {
137
+ return this.request({
138
+ method: 'POST',
139
+ path: this.buildPath('groups/invite'),
140
+ body: { action: 'accept', code },
141
+ });
142
+ }
143
+ /**
144
+ * Inspects group metadata using an invite code before joining.
145
+ */
146
+ async getInviteInfo(code) {
147
+ return this.request({
148
+ method: 'POST',
149
+ path: this.buildPath('groups/invite'),
150
+ body: { action: 'inspect', code },
151
+ });
152
+ }
153
+ /**
154
+ * Gets pending participant join requests (for groups with admin approval enabled).
155
+ */
156
+ async getJoinRequests(groupJid) {
157
+ return this.request({
158
+ method: 'GET',
159
+ path: this.buildPath('groups/join-requests'),
160
+ query: { jid: groupJid },
161
+ });
162
+ }
163
+ /**
164
+ * Approves or rejects participant join requests.
165
+ */
166
+ async updateJoinRequests(groupJid, participants, action) {
167
+ return this.request({
168
+ method: 'POST',
169
+ path: this.buildPath('groups/join-requests'),
170
+ body: { jid: groupJid, participants, action },
171
+ });
172
+ }
173
+ /**
174
+ * Configures disappearing messages for a group.
175
+ *
176
+ * @param groupJid Group JID
177
+ * @param durationSeconds 0 for off, 86400 (24h), 604800 (7d), 7776000 (90d)
178
+ */
179
+ async setEphemeral(groupJid, durationSeconds) {
180
+ return this.request({
181
+ method: 'POST',
182
+ path: this.buildPath('groups/ephemeral'),
183
+ body: { jid: groupJid, duration: durationSeconds },
184
+ });
185
+ }
186
+ /**
187
+ * Configures member add mode (`all_member_add` or `admin_add`).
188
+ */
189
+ async setMemberAddMode(groupJid, mode) {
190
+ return this.request({
191
+ method: 'POST',
192
+ path: this.buildPath('groups/member-add-mode'),
193
+ body: { jid: groupJid, mode },
194
+ });
195
+ }
196
+ }