@zapyapi/sdk 1.0.0-beta.1 → 1.0.0-beta.11
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 +131 -30
- package/index.cjs +1536 -151
- package/index.js +1516 -142
- package/package.json +1 -2
- package/src/client.d.ts +1 -1
- package/src/errors.d.ts +101 -5
- package/src/errors.d.ts.map +1 -1
- package/src/generated/Api.d.ts +637 -7
- package/src/generated/Api.d.ts.map +1 -1
- package/src/index.d.ts +13 -8
- package/src/index.d.ts.map +1 -1
- package/src/resources/base.resource.d.ts.map +1 -1
- package/src/resources/instances.resource.d.ts +106 -1
- package/src/resources/instances.resource.d.ts.map +1 -1
- package/src/resources/messages.resource.d.ts +70 -1
- package/src/resources/messages.resource.d.ts.map +1 -1
- package/src/types/enums.d.ts +6 -87
- package/src/types/enums.d.ts.map +1 -1
- package/src/types/events/contact.d.ts +65 -0
- package/src/types/events/contact.d.ts.map +1 -0
- package/src/types/events/index.d.ts +76 -0
- package/src/types/events/index.d.ts.map +1 -0
- package/src/types/events/instance-status.d.ts +10 -0
- package/src/types/events/instance-status.d.ts.map +1 -0
- package/src/types/events/presence.d.ts +18 -0
- package/src/types/events/presence.d.ts.map +1 -0
- package/src/types/events/qr-code.d.ts +9 -0
- package/src/types/events/qr-code.d.ts.map +1 -0
- package/src/types/events/reaction.d.ts +14 -0
- package/src/types/events/reaction.d.ts.map +1 -0
- package/src/types/index.d.ts +8 -5
- package/src/types/index.d.ts.map +1 -1
- package/src/types/instances.types.d.ts +99 -0
- package/src/types/instances.types.d.ts.map +1 -1
- package/src/types/message-events.types.d.ts +250 -0
- package/src/types/message-events.types.d.ts.map +1 -0
- package/src/types/messages.types.d.ts +68 -1
- package/src/types/messages.types.d.ts.map +1 -1
- package/src/utils/phone.d.ts +1 -1
- package/src/version.d.ts +1 -1
- package/src/version.d.ts.map +1 -1
- package/src/types/webhook-events.types.d.ts +0 -232
- package/src/types/webhook-events.types.d.ts.map +0 -1
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
|
|
3
3
|
/** SDK version - auto-generated from package.json */
|
|
4
|
-
const SDK_VERSION = '1.0.0-beta.
|
|
4
|
+
const SDK_VERSION = '1.0.0-beta.11';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Custom error classes for @zapyapi/sdk
|
|
@@ -10,11 +10,30 @@ const SDK_VERSION = '1.0.0-beta.1';
|
|
|
10
10
|
* Base error class for all ZapyAPI errors
|
|
11
11
|
*/
|
|
12
12
|
class ZapyError extends Error {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Original error that caused this error (if any)
|
|
15
|
+
*/
|
|
16
|
+
cause;
|
|
17
|
+
constructor(message, cause) {
|
|
18
|
+
super(message, {
|
|
19
|
+
cause
|
|
20
|
+
});
|
|
15
21
|
this.name = 'ZapyError';
|
|
16
22
|
Object.setPrototypeOf(this, ZapyError.prototype);
|
|
17
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Get a detailed string representation of the error
|
|
26
|
+
*/
|
|
27
|
+
toDetailedString() {
|
|
28
|
+
let result = `${this.name}: ${this.message}`;
|
|
29
|
+
if (this.cause) {
|
|
30
|
+
result += `\nCaused by: ${this.cause.message}`;
|
|
31
|
+
if (this.cause.stack) {
|
|
32
|
+
result += `\n${this.cause.stack}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
18
37
|
}
|
|
19
38
|
/**
|
|
20
39
|
* Error thrown when the API returns an error response
|
|
@@ -36,13 +55,28 @@ class ZapyApiError extends ZapyError {
|
|
|
36
55
|
* Additional error details
|
|
37
56
|
*/
|
|
38
57
|
details;
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
/**
|
|
59
|
+
* HTTP method used in the request
|
|
60
|
+
*/
|
|
61
|
+
method;
|
|
62
|
+
/**
|
|
63
|
+
* URL that was requested
|
|
64
|
+
*/
|
|
65
|
+
url;
|
|
66
|
+
/**
|
|
67
|
+
* Raw response body (for debugging)
|
|
68
|
+
*/
|
|
69
|
+
responseBody;
|
|
70
|
+
constructor(message, statusCode, code, options) {
|
|
71
|
+
super(message, options?.cause);
|
|
41
72
|
this.name = 'ZapyApiError';
|
|
42
73
|
this.statusCode = statusCode;
|
|
43
74
|
this.code = code;
|
|
44
|
-
this.requestId = requestId;
|
|
45
|
-
this.details = details;
|
|
75
|
+
this.requestId = options?.requestId;
|
|
76
|
+
this.details = options?.details;
|
|
77
|
+
this.method = options?.method;
|
|
78
|
+
this.url = options?.url;
|
|
79
|
+
this.responseBody = options?.responseBody;
|
|
46
80
|
Object.setPrototypeOf(this, ZapyApiError.prototype);
|
|
47
81
|
}
|
|
48
82
|
/**
|
|
@@ -52,10 +86,81 @@ class ZapyApiError extends ZapyError {
|
|
|
52
86
|
const statusCode = error.response?.status ?? 500;
|
|
53
87
|
const data = error.response?.data;
|
|
54
88
|
const requestId = error.response?.headers?.['x-request-id'];
|
|
55
|
-
|
|
56
|
-
|
|
89
|
+
const method = error.config?.method?.toUpperCase();
|
|
90
|
+
const url = error.config?.url;
|
|
91
|
+
// Build a descriptive message
|
|
92
|
+
let message;
|
|
93
|
+
if (data && typeof data === 'object' && 'message' in data && data.message) {
|
|
94
|
+
message = data.message;
|
|
95
|
+
} else if (error.message) {
|
|
96
|
+
message = error.message;
|
|
97
|
+
} else {
|
|
98
|
+
message = `Request failed with status ${statusCode}`;
|
|
99
|
+
}
|
|
100
|
+
// Add context to the message
|
|
101
|
+
const context = [];
|
|
102
|
+
if (method && url) {
|
|
103
|
+
context.push(`${method} ${url}`);
|
|
104
|
+
}
|
|
105
|
+
if (statusCode) {
|
|
106
|
+
context.push(`Status: ${statusCode}`);
|
|
57
107
|
}
|
|
58
|
-
|
|
108
|
+
if (requestId) {
|
|
109
|
+
context.push(`Request ID: ${requestId}`);
|
|
110
|
+
}
|
|
111
|
+
const fullMessage = context.length > 0 ? `${message} [${context.join(' | ')}]` : message;
|
|
112
|
+
const code = data && typeof data === 'object' && 'code' in data && data.code ? data.code : 'UNKNOWN_ERROR';
|
|
113
|
+
const details = data && typeof data === 'object' && 'details' in data ? data.details : undefined;
|
|
114
|
+
return new ZapyApiError(fullMessage, statusCode, code, {
|
|
115
|
+
requestId: requestId || (data && typeof data === 'object' && 'requestId' in data ? data.requestId : undefined),
|
|
116
|
+
details,
|
|
117
|
+
method,
|
|
118
|
+
url,
|
|
119
|
+
responseBody: data,
|
|
120
|
+
cause: error
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get a detailed string representation for logging
|
|
125
|
+
*/
|
|
126
|
+
toDetailedString() {
|
|
127
|
+
const lines = [`${this.name}: ${this.message}`, ` Status Code: ${this.statusCode}`, ` Error Code: ${this.code}`];
|
|
128
|
+
if (this.method && this.url) {
|
|
129
|
+
lines.push(` Request: ${this.method} ${this.url}`);
|
|
130
|
+
}
|
|
131
|
+
if (this.requestId) {
|
|
132
|
+
lines.push(` Request ID: ${this.requestId}`);
|
|
133
|
+
}
|
|
134
|
+
if (this.details && Object.keys(this.details).length > 0) {
|
|
135
|
+
lines.push(` Details: ${JSON.stringify(this.details, null, 2)}`);
|
|
136
|
+
}
|
|
137
|
+
if (this.responseBody && typeof this.responseBody === 'object') {
|
|
138
|
+
lines.push(` Response Body: ${JSON.stringify(this.responseBody, null, 2)}`);
|
|
139
|
+
}
|
|
140
|
+
if (this.cause) {
|
|
141
|
+
lines.push(` Caused by: ${this.cause.message}`);
|
|
142
|
+
if (this.cause.stack) {
|
|
143
|
+
lines.push(` Stack: ${this.cause.stack.split('\n').slice(1, 4).join('\n ')}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return lines.join('\n');
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Convert to a plain object for logging/serialization
|
|
150
|
+
*/
|
|
151
|
+
toJSON() {
|
|
152
|
+
return {
|
|
153
|
+
name: this.name,
|
|
154
|
+
message: this.message,
|
|
155
|
+
statusCode: this.statusCode,
|
|
156
|
+
code: this.code,
|
|
157
|
+
requestId: this.requestId,
|
|
158
|
+
method: this.method,
|
|
159
|
+
url: this.url,
|
|
160
|
+
details: this.details,
|
|
161
|
+
responseBody: this.responseBody,
|
|
162
|
+
cause: this.cause?.message
|
|
163
|
+
};
|
|
59
164
|
}
|
|
60
165
|
}
|
|
61
166
|
/**
|
|
@@ -72,16 +177,32 @@ class ValidationError extends ZapyError {
|
|
|
72
177
|
this.details = details;
|
|
73
178
|
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
74
179
|
}
|
|
180
|
+
toDetailedString() {
|
|
181
|
+
const fieldErrors = Object.entries(this.details).map(([field, errors]) => ` ${field}: ${errors.join(', ')}`).join('\n');
|
|
182
|
+
return `${this.name}: ${this.message}\n${fieldErrors}`;
|
|
183
|
+
}
|
|
184
|
+
toJSON() {
|
|
185
|
+
return {
|
|
186
|
+
name: this.name,
|
|
187
|
+
message: this.message,
|
|
188
|
+
details: this.details
|
|
189
|
+
};
|
|
190
|
+
}
|
|
75
191
|
}
|
|
76
192
|
/**
|
|
77
193
|
* Error thrown when an instance is not found
|
|
78
194
|
*/
|
|
79
195
|
class InstanceNotFoundError extends ZapyApiError {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
196
|
+
instanceId;
|
|
197
|
+
constructor(instanceId, options) {
|
|
198
|
+
super(`Instance '${instanceId}' not found`, 404, 'INSTANCE_NOT_FOUND', {
|
|
199
|
+
...options,
|
|
200
|
+
details: {
|
|
201
|
+
instanceId
|
|
202
|
+
}
|
|
83
203
|
});
|
|
84
204
|
this.name = 'InstanceNotFoundError';
|
|
205
|
+
this.instanceId = instanceId;
|
|
85
206
|
Object.setPrototypeOf(this, InstanceNotFoundError.prototype);
|
|
86
207
|
}
|
|
87
208
|
}
|
|
@@ -89,8 +210,8 @@ class InstanceNotFoundError extends ZapyApiError {
|
|
|
89
210
|
* Error thrown when authentication fails
|
|
90
211
|
*/
|
|
91
212
|
class AuthenticationError extends ZapyApiError {
|
|
92
|
-
constructor(message = 'Invalid or missing API key',
|
|
93
|
-
super(message, 401, 'UNAUTHORIZED',
|
|
213
|
+
constructor(message = 'Invalid or missing API key', options) {
|
|
214
|
+
super(message, 401, 'UNAUTHORIZED', options);
|
|
94
215
|
this.name = 'AuthenticationError';
|
|
95
216
|
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
96
217
|
}
|
|
@@ -103,14 +224,89 @@ class RateLimitError extends ZapyApiError {
|
|
|
103
224
|
* Timestamp when the rate limit resets (Unix ms)
|
|
104
225
|
*/
|
|
105
226
|
retryAfter;
|
|
106
|
-
constructor(message = 'Rate limit exceeded', retryAfter,
|
|
107
|
-
super(message, 429, 'RATE_LIMIT_EXCEEDED',
|
|
108
|
-
|
|
227
|
+
constructor(message = 'Rate limit exceeded', retryAfter, options) {
|
|
228
|
+
super(message, 429, 'RATE_LIMIT_EXCEEDED', {
|
|
229
|
+
...options,
|
|
230
|
+
details: retryAfter ? {
|
|
231
|
+
retryAfter
|
|
232
|
+
} : undefined
|
|
109
233
|
});
|
|
110
234
|
this.name = 'RateLimitError';
|
|
111
235
|
this.retryAfter = retryAfter;
|
|
112
236
|
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
113
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Get the Date when the rate limit resets
|
|
240
|
+
*/
|
|
241
|
+
getRetryAfterDate() {
|
|
242
|
+
return this.retryAfter ? new Date(this.retryAfter) : undefined;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Error thrown when a network error occurs (no response received)
|
|
247
|
+
*/
|
|
248
|
+
class NetworkError extends ZapyError {
|
|
249
|
+
/**
|
|
250
|
+
* HTTP method used in the request
|
|
251
|
+
*/
|
|
252
|
+
method;
|
|
253
|
+
/**
|
|
254
|
+
* URL that was requested
|
|
255
|
+
*/
|
|
256
|
+
url;
|
|
257
|
+
/**
|
|
258
|
+
* Error code (e.g., ECONNREFUSED, ETIMEDOUT)
|
|
259
|
+
*/
|
|
260
|
+
code;
|
|
261
|
+
constructor(message, options) {
|
|
262
|
+
super(message, options?.cause);
|
|
263
|
+
this.name = 'NetworkError';
|
|
264
|
+
this.method = options?.method;
|
|
265
|
+
this.url = options?.url;
|
|
266
|
+
this.code = options?.code;
|
|
267
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
268
|
+
}
|
|
269
|
+
toDetailedString() {
|
|
270
|
+
const lines = [`${this.name}: ${this.message}`];
|
|
271
|
+
if (this.code) {
|
|
272
|
+
lines.push(` Error Code: ${this.code}`);
|
|
273
|
+
}
|
|
274
|
+
if (this.method && this.url) {
|
|
275
|
+
lines.push(` Request: ${this.method} ${this.url}`);
|
|
276
|
+
}
|
|
277
|
+
if (this.cause) {
|
|
278
|
+
lines.push(` Caused by: ${this.cause.message}`);
|
|
279
|
+
}
|
|
280
|
+
return lines.join('\n');
|
|
281
|
+
}
|
|
282
|
+
toJSON() {
|
|
283
|
+
return {
|
|
284
|
+
name: this.name,
|
|
285
|
+
message: this.message,
|
|
286
|
+
code: this.code,
|
|
287
|
+
method: this.method,
|
|
288
|
+
url: this.url,
|
|
289
|
+
cause: this.cause?.message
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Error thrown when request times out
|
|
295
|
+
*/
|
|
296
|
+
class TimeoutError extends NetworkError {
|
|
297
|
+
/**
|
|
298
|
+
* Timeout duration in milliseconds
|
|
299
|
+
*/
|
|
300
|
+
timeout;
|
|
301
|
+
constructor(message = 'Request timed out', options) {
|
|
302
|
+
super(message, {
|
|
303
|
+
...options,
|
|
304
|
+
code: 'ETIMEDOUT'
|
|
305
|
+
});
|
|
306
|
+
this.name = 'TimeoutError';
|
|
307
|
+
this.timeout = options?.timeout;
|
|
308
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
309
|
+
}
|
|
114
310
|
}
|
|
115
311
|
|
|
116
312
|
/**
|
|
@@ -126,18 +322,58 @@ class BaseResource {
|
|
|
126
322
|
*/
|
|
127
323
|
handleError(error) {
|
|
128
324
|
if (this.isAxiosError(error)) {
|
|
129
|
-
const
|
|
130
|
-
const
|
|
325
|
+
const method = error.config?.method?.toUpperCase();
|
|
326
|
+
const url = error.config?.url;
|
|
327
|
+
const requestId = error.response?.headers?.['x-request-id'];
|
|
328
|
+
// Network errors (no response received)
|
|
329
|
+
if (!error.response) {
|
|
330
|
+
const code = error.code;
|
|
331
|
+
// Timeout errors
|
|
332
|
+
if (code === 'ECONNABORTED' || code === 'ETIMEDOUT' || error.message?.includes('timeout')) {
|
|
333
|
+
const timeout = error.config?.timeout;
|
|
334
|
+
throw new TimeoutError(`Request timed out${timeout ? ` after ${timeout}ms` : ''}`, {
|
|
335
|
+
method,
|
|
336
|
+
url,
|
|
337
|
+
timeout,
|
|
338
|
+
cause: error
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
// Other network errors (connection refused, DNS failure, etc.)
|
|
342
|
+
throw new NetworkError(error.message || 'Network error occurred', {
|
|
343
|
+
method,
|
|
344
|
+
url,
|
|
345
|
+
code,
|
|
346
|
+
cause: error
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const statusCode = error.response.status;
|
|
350
|
+
const retryAfter = error.response.headers?.['retry-after'];
|
|
131
351
|
if (statusCode === 401) {
|
|
132
|
-
throw new AuthenticationError(error.response
|
|
352
|
+
throw new AuthenticationError(error.response.data?.message || 'Invalid or missing API key', {
|
|
353
|
+
requestId,
|
|
354
|
+
method,
|
|
355
|
+
url,
|
|
356
|
+
cause: error
|
|
357
|
+
});
|
|
133
358
|
}
|
|
134
359
|
if (statusCode === 429) {
|
|
135
|
-
|
|
360
|
+
const retryAfterMs = retryAfter ? parseInt(retryAfter, 10) * 1000 : undefined;
|
|
361
|
+
throw new RateLimitError(error.response.data?.message || 'Rate limit exceeded', retryAfterMs, {
|
|
362
|
+
requestId,
|
|
363
|
+
method,
|
|
364
|
+
url,
|
|
365
|
+
cause: error
|
|
366
|
+
});
|
|
136
367
|
}
|
|
137
368
|
throw ZapyApiError.fromAxiosError(error);
|
|
138
369
|
}
|
|
370
|
+
if (error instanceof ZapyError) {
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
139
373
|
if (error instanceof Error) {
|
|
140
|
-
throw new ZapyApiError(error.message, 500, 'UNKNOWN_ERROR'
|
|
374
|
+
throw new ZapyApiError(error.message, 500, 'UNKNOWN_ERROR', {
|
|
375
|
+
cause: error
|
|
376
|
+
});
|
|
141
377
|
}
|
|
142
378
|
throw new ZapyApiError('An unexpected error occurred', 500, 'UNKNOWN_ERROR');
|
|
143
379
|
}
|
|
@@ -197,10 +433,13 @@ class MessagesResource extends BaseResource {
|
|
|
197
433
|
*/
|
|
198
434
|
async sendImage(instanceId, options) {
|
|
199
435
|
try {
|
|
436
|
+
const image = options.url || options.base64;
|
|
437
|
+
if (!image) {
|
|
438
|
+
throw new Error('Either url or base64 must be provided');
|
|
439
|
+
}
|
|
200
440
|
const response = await this.http.post(`/message/${instanceId}/image`, {
|
|
201
441
|
to: options.to,
|
|
202
|
-
|
|
203
|
-
base64: options.base64,
|
|
442
|
+
image,
|
|
204
443
|
caption: options.caption,
|
|
205
444
|
quoteMessageId: options.quotedMessageId
|
|
206
445
|
});
|
|
@@ -225,10 +464,13 @@ class MessagesResource extends BaseResource {
|
|
|
225
464
|
*/
|
|
226
465
|
async sendVideo(instanceId, options) {
|
|
227
466
|
try {
|
|
467
|
+
const video = options.url || options.base64;
|
|
468
|
+
if (!video) {
|
|
469
|
+
throw new Error('Either url or base64 must be provided');
|
|
470
|
+
}
|
|
228
471
|
const response = await this.http.post(`/message/${instanceId}/video`, {
|
|
229
472
|
to: options.to,
|
|
230
|
-
|
|
231
|
-
base64: options.base64,
|
|
473
|
+
video,
|
|
232
474
|
caption: options.caption,
|
|
233
475
|
quoteMessageId: options.quotedMessageId
|
|
234
476
|
});
|
|
@@ -252,10 +494,13 @@ class MessagesResource extends BaseResource {
|
|
|
252
494
|
*/
|
|
253
495
|
async sendAudioNote(instanceId, options) {
|
|
254
496
|
try {
|
|
497
|
+
const audio = options.url || options.base64;
|
|
498
|
+
if (!audio) {
|
|
499
|
+
throw new Error('Either url or base64 must be provided');
|
|
500
|
+
}
|
|
255
501
|
const response = await this.http.post(`/message/${instanceId}/audio-note`, {
|
|
256
502
|
to: options.to,
|
|
257
|
-
|
|
258
|
-
base64: options.base64,
|
|
503
|
+
audio,
|
|
259
504
|
quoteMessageId: options.quotedMessageId
|
|
260
505
|
});
|
|
261
506
|
return response.data;
|
|
@@ -278,10 +523,13 @@ class MessagesResource extends BaseResource {
|
|
|
278
523
|
*/
|
|
279
524
|
async sendAudioFile(instanceId, options) {
|
|
280
525
|
try {
|
|
526
|
+
const audio = options.url || options.base64;
|
|
527
|
+
if (!audio) {
|
|
528
|
+
throw new Error('Either url or base64 must be provided');
|
|
529
|
+
}
|
|
281
530
|
const response = await this.http.post(`/message/${instanceId}/audio-file`, {
|
|
282
531
|
to: options.to,
|
|
283
|
-
|
|
284
|
-
base64: options.base64,
|
|
532
|
+
audio,
|
|
285
533
|
quoteMessageId: options.quotedMessageId
|
|
286
534
|
});
|
|
287
535
|
return response.data;
|
|
@@ -306,11 +554,14 @@ class MessagesResource extends BaseResource {
|
|
|
306
554
|
*/
|
|
307
555
|
async sendDocument(instanceId, options) {
|
|
308
556
|
try {
|
|
557
|
+
const document = options.url || options.base64;
|
|
558
|
+
if (!document) {
|
|
559
|
+
throw new Error('Either url or base64 must be provided');
|
|
560
|
+
}
|
|
309
561
|
const response = await this.http.post(`/message/${instanceId}/document`, {
|
|
310
562
|
to: options.to,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
filename: options.filename,
|
|
563
|
+
document,
|
|
564
|
+
fileName: options.filename,
|
|
314
565
|
caption: options.caption,
|
|
315
566
|
quoteMessageId: options.quotedMessageId
|
|
316
567
|
});
|
|
@@ -426,6 +677,124 @@ class MessagesResource extends BaseResource {
|
|
|
426
677
|
this.handleError(error);
|
|
427
678
|
}
|
|
428
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Send a location message
|
|
682
|
+
*
|
|
683
|
+
* @param instanceId - Instance ID
|
|
684
|
+
* @param options - Location message options
|
|
685
|
+
* @returns Message response with ID and status
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* await client.messages.sendLocation('my-instance', {
|
|
689
|
+
* to: '5511999999999',
|
|
690
|
+
* latitude: -23.5505,
|
|
691
|
+
* longitude: -46.6333,
|
|
692
|
+
* name: 'São Paulo',
|
|
693
|
+
* address: 'São Paulo, Brazil'
|
|
694
|
+
* });
|
|
695
|
+
*/
|
|
696
|
+
async sendLocation(instanceId, options) {
|
|
697
|
+
try {
|
|
698
|
+
const response = await this.http.post(`/message/${instanceId}/location`, {
|
|
699
|
+
to: options.to,
|
|
700
|
+
latitude: options.latitude,
|
|
701
|
+
longitude: options.longitude,
|
|
702
|
+
name: options.name,
|
|
703
|
+
address: options.address,
|
|
704
|
+
quoteMessageId: options.quotedMessageId
|
|
705
|
+
});
|
|
706
|
+
return response.data;
|
|
707
|
+
} catch (error) {
|
|
708
|
+
this.handleError(error);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Send a contact card message
|
|
713
|
+
*
|
|
714
|
+
* @param instanceId - Instance ID
|
|
715
|
+
* @param options - Contact message options
|
|
716
|
+
* @returns Message response with ID and status
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* await client.messages.sendContact('my-instance', {
|
|
720
|
+
* to: '5511999999999',
|
|
721
|
+
* contact: {
|
|
722
|
+
* fullName: 'John Doe',
|
|
723
|
+
* phoneNumber: '+5511988887777',
|
|
724
|
+
* organization: 'Acme Inc'
|
|
725
|
+
* }
|
|
726
|
+
* });
|
|
727
|
+
*/
|
|
728
|
+
async sendContact(instanceId, options) {
|
|
729
|
+
try {
|
|
730
|
+
const response = await this.http.post(`/message/${instanceId}/contact`, {
|
|
731
|
+
to: options.to,
|
|
732
|
+
contact: options.contact,
|
|
733
|
+
quoteMessageId: options.quotedMessageId
|
|
734
|
+
});
|
|
735
|
+
return response.data;
|
|
736
|
+
} catch (error) {
|
|
737
|
+
this.handleError(error);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Send a sticker message
|
|
742
|
+
*
|
|
743
|
+
* @param instanceId - Instance ID
|
|
744
|
+
* @param options - Sticker message options
|
|
745
|
+
* @returns Message response with ID and status
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* await client.messages.sendSticker('my-instance', {
|
|
749
|
+
* to: '5511999999999',
|
|
750
|
+
* url: 'https://example.com/sticker.webp'
|
|
751
|
+
* });
|
|
752
|
+
*/
|
|
753
|
+
async sendSticker(instanceId, options) {
|
|
754
|
+
try {
|
|
755
|
+
const sticker = options.url || options.base64;
|
|
756
|
+
if (!sticker) {
|
|
757
|
+
throw new Error('Either url or base64 must be provided');
|
|
758
|
+
}
|
|
759
|
+
const response = await this.http.post(`/message/${instanceId}/sticker`, {
|
|
760
|
+
to: options.to,
|
|
761
|
+
sticker,
|
|
762
|
+
quoteMessageId: options.quotedMessageId
|
|
763
|
+
});
|
|
764
|
+
return response.data;
|
|
765
|
+
} catch (error) {
|
|
766
|
+
this.handleError(error);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Send a reaction to a message
|
|
771
|
+
*
|
|
772
|
+
* @param instanceId - Instance ID
|
|
773
|
+
* @param options - Reaction options
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* // Add a reaction
|
|
777
|
+
* await client.messages.sendReaction('my-instance', {
|
|
778
|
+
* messageId: 'ABC123...',
|
|
779
|
+
* reaction: '👍'
|
|
780
|
+
* });
|
|
781
|
+
*
|
|
782
|
+
* // Remove a reaction
|
|
783
|
+
* await client.messages.sendReaction('my-instance', {
|
|
784
|
+
* messageId: 'ABC123...',
|
|
785
|
+
* reaction: ''
|
|
786
|
+
* });
|
|
787
|
+
*/
|
|
788
|
+
async sendReaction(instanceId, options) {
|
|
789
|
+
try {
|
|
790
|
+
await this.http.post(`/message/${instanceId}/reaction`, {
|
|
791
|
+
messageId: options.messageId,
|
|
792
|
+
reaction: options.reaction
|
|
793
|
+
});
|
|
794
|
+
} catch (error) {
|
|
795
|
+
this.handleError(error);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
429
798
|
}
|
|
430
799
|
|
|
431
800
|
/**
|
|
@@ -689,6 +1058,155 @@ class InstancesResource extends BaseResource {
|
|
|
689
1058
|
this.handleError(error);
|
|
690
1059
|
}
|
|
691
1060
|
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Check if phone numbers are registered on WhatsApp
|
|
1063
|
+
*
|
|
1064
|
+
* This method verifies if the provided phone numbers are registered on WhatsApp.
|
|
1065
|
+
* Useful for validating contacts before sending messages.
|
|
1066
|
+
*
|
|
1067
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1068
|
+
* @param numbers - Array of phone numbers to check (with country code, e.g., "5511999999999")
|
|
1069
|
+
* @returns Results indicating which numbers are registered on WhatsApp
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* const result = await client.instances.checkNumbers('my-instance', [
|
|
1073
|
+
* '5511999999999',
|
|
1074
|
+
* '5521888888888'
|
|
1075
|
+
* ]);
|
|
1076
|
+
*
|
|
1077
|
+
* for (const check of result.results) {
|
|
1078
|
+
* if (check.exists) {
|
|
1079
|
+
* console.log(`${check.number} is on WhatsApp (JID: ${check.jid})`);
|
|
1080
|
+
* } else {
|
|
1081
|
+
* console.log(`${check.number} is NOT on WhatsApp`);
|
|
1082
|
+
* }
|
|
1083
|
+
* }
|
|
1084
|
+
*/
|
|
1085
|
+
async checkNumbers(instanceId, numbers) {
|
|
1086
|
+
try {
|
|
1087
|
+
const response = await this.http.post(`/instances/${instanceId}/check-numbers`, {
|
|
1088
|
+
numbers
|
|
1089
|
+
});
|
|
1090
|
+
return response.data;
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
this.handleError(error);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Send a presence update (typing indicator, online status, etc.)
|
|
1097
|
+
*
|
|
1098
|
+
* Use this to show typing indicators or update online status for a contact.
|
|
1099
|
+
*
|
|
1100
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1101
|
+
* @param options - Presence options
|
|
1102
|
+
*
|
|
1103
|
+
* @example
|
|
1104
|
+
* // Show typing indicator
|
|
1105
|
+
* await client.instances.sendPresence('my-instance', {
|
|
1106
|
+
* to: '5511999999999',
|
|
1107
|
+
* presence: 'composing'
|
|
1108
|
+
* });
|
|
1109
|
+
*
|
|
1110
|
+
* // Show recording audio indicator
|
|
1111
|
+
* await client.instances.sendPresence('my-instance', {
|
|
1112
|
+
* to: '5511999999999',
|
|
1113
|
+
* presence: 'recording'
|
|
1114
|
+
* });
|
|
1115
|
+
*
|
|
1116
|
+
* // Stop typing indicator
|
|
1117
|
+
* await client.instances.sendPresence('my-instance', {
|
|
1118
|
+
* to: '5511999999999',
|
|
1119
|
+
* presence: 'paused'
|
|
1120
|
+
* });
|
|
1121
|
+
*/
|
|
1122
|
+
async sendPresence(instanceId, options) {
|
|
1123
|
+
try {
|
|
1124
|
+
await this.http.post(`/instances/${instanceId}/presence`, {
|
|
1125
|
+
to: options.to,
|
|
1126
|
+
presence: options.presence
|
|
1127
|
+
});
|
|
1128
|
+
} catch (error) {
|
|
1129
|
+
this.handleError(error);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Get profile picture URL for a contact
|
|
1134
|
+
*
|
|
1135
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1136
|
+
* @param phone - Phone number or JID of the contact
|
|
1137
|
+
* @returns Profile picture response with URL (null if not available)
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* const result = await client.instances.getProfilePicture('my-instance', '5511999999999');
|
|
1141
|
+
* if (result.url) {
|
|
1142
|
+
* console.log('Profile picture:', result.url);
|
|
1143
|
+
* } else {
|
|
1144
|
+
* console.log('No profile picture available');
|
|
1145
|
+
* }
|
|
1146
|
+
*/
|
|
1147
|
+
async getProfilePicture(instanceId, phone) {
|
|
1148
|
+
try {
|
|
1149
|
+
const response = await this.http.get(`/instances/${instanceId}/contacts/${phone}/profile-picture`);
|
|
1150
|
+
return response.data;
|
|
1151
|
+
} catch (error) {
|
|
1152
|
+
this.handleError(error);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Block a contact
|
|
1157
|
+
*
|
|
1158
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1159
|
+
* @param phone - Phone number or JID of the contact to block
|
|
1160
|
+
*
|
|
1161
|
+
* @example
|
|
1162
|
+
* await client.instances.blockContact('my-instance', '5511999999999');
|
|
1163
|
+
*/
|
|
1164
|
+
async blockContact(instanceId, phone) {
|
|
1165
|
+
try {
|
|
1166
|
+
await this.http.post(`/instances/${instanceId}/contacts/${phone}/block`);
|
|
1167
|
+
} catch (error) {
|
|
1168
|
+
this.handleError(error);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Unblock a contact
|
|
1173
|
+
*
|
|
1174
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1175
|
+
* @param phone - Phone number or JID of the contact to unblock
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* await client.instances.unblockContact('my-instance', '5511999999999');
|
|
1179
|
+
*/
|
|
1180
|
+
async unblockContact(instanceId, phone) {
|
|
1181
|
+
try {
|
|
1182
|
+
await this.http.delete(`/instances/${instanceId}/contacts/${phone}/block`);
|
|
1183
|
+
} catch (error) {
|
|
1184
|
+
this.handleError(error);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Get group metadata
|
|
1189
|
+
*
|
|
1190
|
+
* @param instanceId - Instance ID (must be connected)
|
|
1191
|
+
* @param groupId - Group JID (e.g., "120363123456789012@g.us")
|
|
1192
|
+
* @returns Group metadata including participants
|
|
1193
|
+
*
|
|
1194
|
+
* @example
|
|
1195
|
+
* const metadata = await client.instances.getGroupMetadata('my-instance', '120363123456789012@g.us');
|
|
1196
|
+
* console.log(`Group: ${metadata.subject}`);
|
|
1197
|
+
* console.log(`Participants: ${metadata.participants.length}`);
|
|
1198
|
+
* for (const p of metadata.participants) {
|
|
1199
|
+
* console.log(` - ${p.id} (${p.admin || 'member'})`);
|
|
1200
|
+
* }
|
|
1201
|
+
*/
|
|
1202
|
+
async getGroupMetadata(instanceId, groupId) {
|
|
1203
|
+
try {
|
|
1204
|
+
const response = await this.http.get(`/instances/${instanceId}/groups/${groupId}`);
|
|
1205
|
+
return response.data;
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
this.handleError(error);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
692
1210
|
}
|
|
693
1211
|
|
|
694
1212
|
/**
|
|
@@ -699,7 +1217,7 @@ class InstancesResource extends BaseResource {
|
|
|
699
1217
|
*
|
|
700
1218
|
* @example
|
|
701
1219
|
* ```typescript
|
|
702
|
-
* import { ZapyClient,
|
|
1220
|
+
* import { ZapyClient, ZapyEventTypes, isTextMessage } from '@zapyapi/sdk';
|
|
703
1221
|
*
|
|
704
1222
|
* const client = new ZapyClient({
|
|
705
1223
|
* apiKey: 'your-api-key',
|
|
@@ -809,42 +1327,21 @@ function createClient(options) {
|
|
|
809
1327
|
/**
|
|
810
1328
|
* SDK Enums - Type-safe enums for ZapyAPI SDK
|
|
811
1329
|
*
|
|
812
|
-
* These enums can be imported and used for type-safe comparisons and
|
|
813
|
-
* webhook event handling.
|
|
814
|
-
*
|
|
815
1330
|
* @example
|
|
816
1331
|
* ```typescript
|
|
817
|
-
* import {
|
|
818
|
-
*
|
|
819
|
-
* // Type-safe event handling
|
|
820
|
-
* if (event.event === WebhookEventType.MESSAGE) {
|
|
821
|
-
* // Handle message event
|
|
822
|
-
* }
|
|
1332
|
+
* import { InstanceStatus, ZapyEventTypes, ZapyMessageType } from '@zapyapi/sdk';
|
|
823
1333
|
*
|
|
824
1334
|
* // Check instance status
|
|
825
1335
|
* if (instance.status === InstanceStatus.CONNECTED) {
|
|
826
1336
|
* // Instance is ready
|
|
827
1337
|
* }
|
|
1338
|
+
*
|
|
1339
|
+
* // Handle webhook events
|
|
1340
|
+
* if (payload.event === ZapyEventTypes.MESSAGE) {
|
|
1341
|
+
* // Handle message
|
|
1342
|
+
* }
|
|
828
1343
|
* ```
|
|
829
1344
|
*/
|
|
830
|
-
/**
|
|
831
|
-
* Webhook event types sent by ZapyAPI
|
|
832
|
-
* These are the event types you'll receive in webhook payloads
|
|
833
|
-
*/
|
|
834
|
-
const WebhookEventType = {
|
|
835
|
-
/** New message received */
|
|
836
|
-
MESSAGE: 'message',
|
|
837
|
-
/** Message delivery status update */
|
|
838
|
-
MESSAGE_STATUS: 'message-status',
|
|
839
|
-
/** QR code generated for authentication */
|
|
840
|
-
QR_CODE: 'qr-code',
|
|
841
|
-
/** New contact discovered */
|
|
842
|
-
CONTACT_CREATED: 'contact-created',
|
|
843
|
-
/** Contact information updated */
|
|
844
|
-
CONTACT_UPDATED: 'contact-updated',
|
|
845
|
-
/** Duplicate contacts merged */
|
|
846
|
-
CONTACT_DEDUPLICATED: 'contact-deduplicated'
|
|
847
|
-
};
|
|
848
1345
|
/**
|
|
849
1346
|
* Instance status values
|
|
850
1347
|
* Represents the current state of a WhatsApp instance
|
|
@@ -869,48 +1366,6 @@ const InstanceStatus = {
|
|
|
869
1366
|
/** Payment pending for this instance */
|
|
870
1367
|
PAYMENT_PENDING: 'payment_pending'
|
|
871
1368
|
};
|
|
872
|
-
/**
|
|
873
|
-
* Message acknowledgment status
|
|
874
|
-
* Represents the delivery status of a sent message
|
|
875
|
-
*/
|
|
876
|
-
const MessageAckStatus = {
|
|
877
|
-
/** Message is pending to be sent */
|
|
878
|
-
PENDING: 'pending',
|
|
879
|
-
/** Message was sent to server */
|
|
880
|
-
SENT: 'sent',
|
|
881
|
-
/** Message was delivered to recipient */
|
|
882
|
-
DELIVERED: 'delivered',
|
|
883
|
-
/** Message was read by recipient */
|
|
884
|
-
READ: 'read',
|
|
885
|
-
/** Audio/video message was played */
|
|
886
|
-
PLAYED: 'played'
|
|
887
|
-
};
|
|
888
|
-
/**
|
|
889
|
-
* Message types for incoming messages
|
|
890
|
-
* Identifies the type of content in a received message
|
|
891
|
-
*/
|
|
892
|
-
const MessageType = {
|
|
893
|
-
/** Text message */
|
|
894
|
-
TEXT: 'text',
|
|
895
|
-
/** Image message */
|
|
896
|
-
IMAGE: 'image',
|
|
897
|
-
/** Video message */
|
|
898
|
-
VIDEO: 'video',
|
|
899
|
-
/** Audio message (voice note or file) */
|
|
900
|
-
AUDIO: 'audio',
|
|
901
|
-
/** Document/file message */
|
|
902
|
-
DOCUMENT: 'document',
|
|
903
|
-
/** Sticker message */
|
|
904
|
-
STICKER: 'sticker',
|
|
905
|
-
/** Location message */
|
|
906
|
-
LOCATION: 'location',
|
|
907
|
-
/** Contact card message */
|
|
908
|
-
CONTACT: 'contact',
|
|
909
|
-
/** Poll message */
|
|
910
|
-
POLL: 'poll',
|
|
911
|
-
/** Reaction message */
|
|
912
|
-
REACTION: 'reaction'
|
|
913
|
-
};
|
|
914
1369
|
/**
|
|
915
1370
|
* Webhook queue item status
|
|
916
1371
|
* Used for monitoring webhook delivery status
|
|
@@ -927,49 +1382,113 @@ const WebhookQueueStatus = {
|
|
|
927
1382
|
/** Webhook delivery is paused due to repeated failures */
|
|
928
1383
|
PAUSED: 'paused'
|
|
929
1384
|
};
|
|
930
|
-
/**
|
|
931
|
-
* Connection status for webhook events
|
|
932
|
-
* Sent in connection.update webhook events
|
|
933
|
-
*/
|
|
934
|
-
const ConnectionStatus = {
|
|
935
|
-
/** Instance is connecting */
|
|
936
|
-
CONNECTING: 'connecting',
|
|
937
|
-
/** Instance is connected */
|
|
938
|
-
CONNECTED: 'connected',
|
|
939
|
-
/** Instance disconnected */
|
|
940
|
-
DISCONNECTED: 'disconnected',
|
|
941
|
-
/** Connection error occurred */
|
|
942
|
-
ERROR: 'error'
|
|
943
|
-
};
|
|
944
1385
|
|
|
945
1386
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
1387
|
+
* WhatsApp Message Event Types
|
|
1388
|
+
* Comprehensive type definitions for all WhatsApp message types
|
|
948
1389
|
*/
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1390
|
+
// ============================================================================
|
|
1391
|
+
// Message Status
|
|
1392
|
+
// ============================================================================
|
|
1393
|
+
var ZapyMessageStatusEnum;
|
|
1394
|
+
(function (ZapyMessageStatusEnum) {
|
|
1395
|
+
ZapyMessageStatusEnum["UNKNOWN"] = "UNKNOWN";
|
|
1396
|
+
ZapyMessageStatusEnum["ERROR"] = "ERROR";
|
|
1397
|
+
ZapyMessageStatusEnum["PENDING"] = "PENDING";
|
|
1398
|
+
ZapyMessageStatusEnum["SENT"] = "SENT";
|
|
1399
|
+
ZapyMessageStatusEnum["RECEIVED"] = "RECEIVED";
|
|
1400
|
+
ZapyMessageStatusEnum["READ"] = "READ";
|
|
1401
|
+
ZapyMessageStatusEnum["PLAYED"] = "PLAYED";
|
|
1402
|
+
})(ZapyMessageStatusEnum || (ZapyMessageStatusEnum = {}));
|
|
1403
|
+
var ZapyMessageType;
|
|
1404
|
+
(function (ZapyMessageType) {
|
|
1405
|
+
ZapyMessageType["TEXT"] = "text";
|
|
1406
|
+
ZapyMessageType["IMAGE"] = "image";
|
|
1407
|
+
ZapyMessageType["VIDEO"] = "video";
|
|
1408
|
+
ZapyMessageType["AUDIO"] = "audio";
|
|
1409
|
+
ZapyMessageType["DOCUMENT"] = "document";
|
|
1410
|
+
ZapyMessageType["STICKER"] = "sticker";
|
|
1411
|
+
ZapyMessageType["LOCATION"] = "location";
|
|
1412
|
+
ZapyMessageType["LIVE_LOCATION"] = "live_location";
|
|
1413
|
+
ZapyMessageType["CONTACT"] = "contact";
|
|
1414
|
+
ZapyMessageType["REACTION"] = "reaction";
|
|
1415
|
+
ZapyMessageType["EDITED"] = "edited";
|
|
1416
|
+
ZapyMessageType["DELETED"] = "deleted";
|
|
1417
|
+
ZapyMessageType["POLL"] = "poll";
|
|
1418
|
+
ZapyMessageType["POLL_VOTE"] = "poll_vote";
|
|
1419
|
+
ZapyMessageType["CALL"] = "call";
|
|
1420
|
+
ZapyMessageType["UNSUPPORTED"] = "unsupported";
|
|
1421
|
+
})(ZapyMessageType || (ZapyMessageType = {}));
|
|
1422
|
+
// ============================================================================
|
|
1423
|
+
// Type Guards
|
|
1424
|
+
// ============================================================================
|
|
1425
|
+
function isTextMessage(message) {
|
|
1426
|
+
return message.messageType === ZapyMessageType.TEXT;
|
|
1427
|
+
}
|
|
1428
|
+
function isImageMessage(message) {
|
|
1429
|
+
return message.messageType === ZapyMessageType.IMAGE;
|
|
1430
|
+
}
|
|
1431
|
+
function isVideoMessage(message) {
|
|
1432
|
+
return message.messageType === ZapyMessageType.VIDEO;
|
|
1433
|
+
}
|
|
1434
|
+
function isAudioMessage(message) {
|
|
1435
|
+
return message.messageType === ZapyMessageType.AUDIO;
|
|
1436
|
+
}
|
|
1437
|
+
function isDocumentMessage(message) {
|
|
1438
|
+
return message.messageType === ZapyMessageType.DOCUMENT;
|
|
1439
|
+
}
|
|
1440
|
+
function isStickerMessage(message) {
|
|
1441
|
+
return message.messageType === ZapyMessageType.STICKER;
|
|
1442
|
+
}
|
|
1443
|
+
function isLocationMessage(message) {
|
|
1444
|
+
return message.messageType === ZapyMessageType.LOCATION;
|
|
1445
|
+
}
|
|
1446
|
+
function isLiveLocationMessage(message) {
|
|
1447
|
+
return message.messageType === ZapyMessageType.LIVE_LOCATION;
|
|
1448
|
+
}
|
|
1449
|
+
function isContactMessage(message) {
|
|
1450
|
+
return message.messageType === ZapyMessageType.CONTACT;
|
|
952
1451
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
return event.event === 'message-status';
|
|
1452
|
+
function isReactionMessage(message) {
|
|
1453
|
+
return message.messageType === ZapyMessageType.REACTION;
|
|
956
1454
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
return event.event === 'qr-code';
|
|
1455
|
+
function isEditedMessage(message) {
|
|
1456
|
+
return message.messageType === ZapyMessageType.EDITED;
|
|
960
1457
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
return event.event === 'contact-created';
|
|
1458
|
+
function isDeletedMessage(message) {
|
|
1459
|
+
return message.messageType === ZapyMessageType.DELETED;
|
|
964
1460
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return event.event === 'contact-updated';
|
|
1461
|
+
function isPollMessage(message) {
|
|
1462
|
+
return message.messageType === ZapyMessageType.POLL;
|
|
968
1463
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
return event.event === 'contact-deduplicated';
|
|
1464
|
+
function isPollVoteMessage(message) {
|
|
1465
|
+
return message.messageType === ZapyMessageType.POLL_VOTE;
|
|
972
1466
|
}
|
|
1467
|
+
function isCallMessage(message) {
|
|
1468
|
+
return message.messageType === ZapyMessageType.CALL;
|
|
1469
|
+
}
|
|
1470
|
+
function isUnsupportedMessage(message) {
|
|
1471
|
+
return message.messageType === ZapyMessageType.UNSUPPORTED;
|
|
1472
|
+
}
|
|
1473
|
+
function isMediaMessage(message) {
|
|
1474
|
+
return [ZapyMessageType.IMAGE, ZapyMessageType.VIDEO, ZapyMessageType.AUDIO, ZapyMessageType.DOCUMENT, ZapyMessageType.STICKER].includes(message.messageType);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// Re-export all event types
|
|
1478
|
+
/**
|
|
1479
|
+
* Event type constants for type-safe event handling
|
|
1480
|
+
*/
|
|
1481
|
+
const ZapyEventTypes = {
|
|
1482
|
+
MESSAGE: 'message',
|
|
1483
|
+
MESSAGE_STATUS: 'message-status',
|
|
1484
|
+
REACTION: 'reaction',
|
|
1485
|
+
PRESENCE: 'presence',
|
|
1486
|
+
QR_CODE: 'qr-code',
|
|
1487
|
+
CONTACT_CREATED: 'contact-created',
|
|
1488
|
+
CONTACT_UPDATED: 'contact-updated',
|
|
1489
|
+
CONTACT_DEDUPLICATED: 'contact-deduplicated',
|
|
1490
|
+
INSTANCE_STATUS: 'instance-status'
|
|
1491
|
+
};
|
|
973
1492
|
|
|
974
1493
|
/**
|
|
975
1494
|
* Phone number utilities for @zapyapi/sdk
|
|
@@ -984,7 +1503,7 @@ function isContactDeduplicatedEvent(event) {
|
|
|
984
1503
|
* normalizePhone('11999999999') // '5511999999999'
|
|
985
1504
|
* normalizePhone('5511999999999') // '5511999999999'
|
|
986
1505
|
* normalizePhone('+5511999999999') // '5511999999999'
|
|
987
|
-
* normalizePhone('5511999999999@
|
|
1506
|
+
* normalizePhone('5511999999999@s.whatsapp.net') // '5511999999999@s.whatsapp.net'
|
|
988
1507
|
*/
|
|
989
1508
|
function normalizePhone(phone) {
|
|
990
1509
|
// If it's already a WhatsApp ID, return as-is
|
|
@@ -1013,7 +1532,7 @@ function normalizePhone(phone) {
|
|
|
1013
1532
|
function isValidPhone(phone) {
|
|
1014
1533
|
// WhatsApp IDs are valid
|
|
1015
1534
|
if (phone.includes('@')) {
|
|
1016
|
-
return phone.endsWith('@c.us') || phone.endsWith('@g.us') || phone.endsWith('@lid');
|
|
1535
|
+
return phone.endsWith('@s.whatsapp.net') || phone.endsWith('@c.us') || phone.endsWith('@g.us') || phone.endsWith('@lid');
|
|
1017
1536
|
}
|
|
1018
1537
|
// Clean and check if it's a valid number
|
|
1019
1538
|
const cleaned = phone.replace(/[^\d]/g, '');
|
|
@@ -1079,7 +1598,6 @@ function extractPhone(jid) {
|
|
|
1079
1598
|
function verifyWebhookSignature(payload, signature, secret) {
|
|
1080
1599
|
if (!signature || !secret) return false;
|
|
1081
1600
|
try {
|
|
1082
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1083
1601
|
const crypto = require('crypto');
|
|
1084
1602
|
return verifySignatureWithCrypto(crypto, payload, signature, secret);
|
|
1085
1603
|
} catch {
|
|
@@ -1146,4 +1664,860 @@ function verifySignatureWithCrypto(crypto, payload, signature, secret) {
|
|
|
1146
1664
|
return crypto.timingSafeEqual(Buffer.from(signature, 'utf8'), Buffer.from(expectedSignature, 'utf8'));
|
|
1147
1665
|
}
|
|
1148
1666
|
|
|
1149
|
-
|
|
1667
|
+
/* eslint-disable */
|
|
1668
|
+
/* tslint:disable */
|
|
1669
|
+
// @ts-nocheck
|
|
1670
|
+
/*
|
|
1671
|
+
* ---------------------------------------------------------------
|
|
1672
|
+
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
|
1673
|
+
* ## ##
|
|
1674
|
+
* ## AUTHOR: acacode ##
|
|
1675
|
+
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
|
1676
|
+
* ---------------------------------------------------------------
|
|
1677
|
+
*/
|
|
1678
|
+
var ContentType;
|
|
1679
|
+
(function (ContentType) {
|
|
1680
|
+
ContentType["Json"] = "application/json";
|
|
1681
|
+
ContentType["JsonApi"] = "application/vnd.api+json";
|
|
1682
|
+
ContentType["FormData"] = "multipart/form-data";
|
|
1683
|
+
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
1684
|
+
ContentType["Text"] = "text/plain";
|
|
1685
|
+
})(ContentType || (ContentType = {}));
|
|
1686
|
+
class HttpClient {
|
|
1687
|
+
instance;
|
|
1688
|
+
securityData = null;
|
|
1689
|
+
securityWorker;
|
|
1690
|
+
secure;
|
|
1691
|
+
format;
|
|
1692
|
+
constructor({
|
|
1693
|
+
securityWorker,
|
|
1694
|
+
secure,
|
|
1695
|
+
format,
|
|
1696
|
+
...axiosConfig
|
|
1697
|
+
} = {}) {
|
|
1698
|
+
this.instance = axios.create({
|
|
1699
|
+
...axiosConfig,
|
|
1700
|
+
baseURL: axiosConfig.baseURL || ""
|
|
1701
|
+
});
|
|
1702
|
+
this.secure = secure;
|
|
1703
|
+
this.format = format;
|
|
1704
|
+
this.securityWorker = securityWorker;
|
|
1705
|
+
}
|
|
1706
|
+
setSecurityData = data => {
|
|
1707
|
+
this.securityData = data;
|
|
1708
|
+
};
|
|
1709
|
+
mergeRequestParams(params1, params2) {
|
|
1710
|
+
const method = params1.method || params2 && params2.method;
|
|
1711
|
+
return {
|
|
1712
|
+
...this.instance.defaults,
|
|
1713
|
+
...params1,
|
|
1714
|
+
...(params2 || {}),
|
|
1715
|
+
headers: {
|
|
1716
|
+
...(method && this.instance.defaults.headers[method.toLowerCase()] || {}),
|
|
1717
|
+
...(params1.headers || {}),
|
|
1718
|
+
...(params2 && params2.headers || {})
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
stringifyFormItem(formItem) {
|
|
1723
|
+
if (typeof formItem === "object" && formItem !== null) {
|
|
1724
|
+
return JSON.stringify(formItem);
|
|
1725
|
+
} else {
|
|
1726
|
+
return `${formItem}`;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
createFormData(input) {
|
|
1730
|
+
if (input instanceof FormData) {
|
|
1731
|
+
return input;
|
|
1732
|
+
}
|
|
1733
|
+
return Object.keys(input || {}).reduce((formData, key) => {
|
|
1734
|
+
const property = input[key];
|
|
1735
|
+
const propertyContent = property instanceof Array ? property : [property];
|
|
1736
|
+
for (const formItem of propertyContent) {
|
|
1737
|
+
const isFileType = formItem instanceof Blob || formItem instanceof File;
|
|
1738
|
+
formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
|
|
1739
|
+
}
|
|
1740
|
+
return formData;
|
|
1741
|
+
}, new FormData());
|
|
1742
|
+
}
|
|
1743
|
+
request = async ({
|
|
1744
|
+
secure,
|
|
1745
|
+
path,
|
|
1746
|
+
type,
|
|
1747
|
+
query,
|
|
1748
|
+
format,
|
|
1749
|
+
body,
|
|
1750
|
+
...params
|
|
1751
|
+
}) => {
|
|
1752
|
+
const secureParams = (typeof secure === "boolean" ? secure : this.secure) && this.securityWorker && (await this.securityWorker(this.securityData)) || {};
|
|
1753
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
1754
|
+
const responseFormat = format || this.format || undefined;
|
|
1755
|
+
if (type === ContentType.FormData && body && body !== null && typeof body === "object") {
|
|
1756
|
+
body = this.createFormData(body);
|
|
1757
|
+
}
|
|
1758
|
+
if (type === ContentType.Text && body && body !== null && typeof body !== "string") {
|
|
1759
|
+
body = JSON.stringify(body);
|
|
1760
|
+
}
|
|
1761
|
+
return this.instance.request({
|
|
1762
|
+
...requestParams,
|
|
1763
|
+
headers: {
|
|
1764
|
+
...(requestParams.headers || {}),
|
|
1765
|
+
...(type ? {
|
|
1766
|
+
"Content-Type": type
|
|
1767
|
+
} : {})
|
|
1768
|
+
},
|
|
1769
|
+
params: query,
|
|
1770
|
+
responseType: responseFormat,
|
|
1771
|
+
data: body,
|
|
1772
|
+
url: path
|
|
1773
|
+
});
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* @title Zapy API - Gerenciador de Instâncias WhatsApp
|
|
1778
|
+
* @version 1.0.0
|
|
1779
|
+
* @contact Suporte Zapy API <contato@zapyapi.com> (http://app.zapyapi.com/)
|
|
1780
|
+
*
|
|
1781
|
+
*
|
|
1782
|
+
* Formatos de Mensagem
|
|
1783
|
+
* - Números de Telefone: Formato brasileiro (11999999999) ou internacional (5511999999999)
|
|
1784
|
+
* - IDs do WhatsApp: Pessoal (@s.whatsapp.net), Grupos (@g.us), LIDs (@lid)
|
|
1785
|
+
* - Mídia: Arquivos codificados em Base64 ou URLs públicas
|
|
1786
|
+
*
|
|
1787
|
+
* Suporte
|
|
1788
|
+
* Para suporte técnico e documentação, visite nosso site.
|
|
1789
|
+
* https://app.zapyapi.com/
|
|
1790
|
+
*
|
|
1791
|
+
*/
|
|
1792
|
+
class Api extends HttpClient {
|
|
1793
|
+
instances = {
|
|
1794
|
+
/**
|
|
1795
|
+
* @description Lista todas as instâncias do WhatsApp
|
|
1796
|
+
*
|
|
1797
|
+
* @tags Instâncias
|
|
1798
|
+
* @name ManagerInstancesControllerListInstances
|
|
1799
|
+
* @summary Listar Instâncias
|
|
1800
|
+
* @request GET:/api/instances
|
|
1801
|
+
* @secure
|
|
1802
|
+
* @response `200` `(ResponsePaginated & {
|
|
1803
|
+
data?: (ListInstancesResponseDto)[],
|
|
1804
|
+
})` Lista paginada de instâncias obtida com sucesso
|
|
1805
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1806
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
1807
|
+
*/
|
|
1808
|
+
managerInstancesControllerListInstances: (query, params = {}) => this.request({
|
|
1809
|
+
path: `/api/instances`,
|
|
1810
|
+
method: "GET",
|
|
1811
|
+
query: query,
|
|
1812
|
+
secure: true,
|
|
1813
|
+
format: "json",
|
|
1814
|
+
...params
|
|
1815
|
+
}),
|
|
1816
|
+
/**
|
|
1817
|
+
* No description
|
|
1818
|
+
*
|
|
1819
|
+
* @tags Instâncias
|
|
1820
|
+
* @name ManagerInstancesControllerCreateInstance
|
|
1821
|
+
* @summary Create a new WhatsApp instance (Partner only - post-paid subscriptions required)
|
|
1822
|
+
* @request POST:/api/instances
|
|
1823
|
+
* @secure
|
|
1824
|
+
* @response `201` `ManagerInstanceResponseDto` Instance created successfully
|
|
1825
|
+
* @response `400` `void` Bad request
|
|
1826
|
+
*/
|
|
1827
|
+
managerInstancesControllerCreateInstance: (data, params = {}) => this.request({
|
|
1828
|
+
path: `/api/instances`,
|
|
1829
|
+
method: "POST",
|
|
1830
|
+
body: data,
|
|
1831
|
+
secure: true,
|
|
1832
|
+
type: ContentType.Json,
|
|
1833
|
+
format: "json",
|
|
1834
|
+
...params
|
|
1835
|
+
}),
|
|
1836
|
+
/**
|
|
1837
|
+
* @description Obtém o código QR para conectar a instância do WhatsApp
|
|
1838
|
+
*
|
|
1839
|
+
* @tags Instâncias
|
|
1840
|
+
* @name ManagerInstancesControllerGetQrCode
|
|
1841
|
+
* @summary Obter Código QR
|
|
1842
|
+
* @request GET:/api/instances/{instanceId}/qr
|
|
1843
|
+
* @secure
|
|
1844
|
+
* @response `200` `QRCodeResponseDto` Código QR obtido com sucesso
|
|
1845
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1846
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1847
|
+
*/
|
|
1848
|
+
managerInstancesControllerGetQrCode: ({
|
|
1849
|
+
instanceId,
|
|
1850
|
+
...query
|
|
1851
|
+
}, params = {}) => this.request({
|
|
1852
|
+
path: `/api/instances/${instanceId}/qr`,
|
|
1853
|
+
method: "GET",
|
|
1854
|
+
secure: true,
|
|
1855
|
+
format: "json",
|
|
1856
|
+
...params
|
|
1857
|
+
}),
|
|
1858
|
+
/**
|
|
1859
|
+
* @description Reinicia uma instância do WhatsApp
|
|
1860
|
+
*
|
|
1861
|
+
* @tags Instâncias
|
|
1862
|
+
* @name ManagerInstancesControllerRestartInstance
|
|
1863
|
+
* @summary Reiniciar Instância do WhatsApp
|
|
1864
|
+
* @request POST:/api/instances/{instanceId}/restart
|
|
1865
|
+
* @secure
|
|
1866
|
+
* @response `200` `EmptyResponseDto` Instância reiniciada com sucesso
|
|
1867
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1868
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1869
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1870
|
+
*/
|
|
1871
|
+
managerInstancesControllerRestartInstance: ({
|
|
1872
|
+
instanceId,
|
|
1873
|
+
...query
|
|
1874
|
+
}, params = {}) => this.request({
|
|
1875
|
+
path: `/api/instances/${instanceId}/restart`,
|
|
1876
|
+
method: "POST",
|
|
1877
|
+
secure: true,
|
|
1878
|
+
format: "json",
|
|
1879
|
+
...params
|
|
1880
|
+
}),
|
|
1881
|
+
/**
|
|
1882
|
+
* @description Desloga uma instância do WhatsApp
|
|
1883
|
+
*
|
|
1884
|
+
* @tags Instâncias
|
|
1885
|
+
* @name ManagerInstancesControllerLogoutInstance
|
|
1886
|
+
* @summary Deslogar Instância do WhatsApp
|
|
1887
|
+
* @request POST:/api/instances/{instanceId}/logout
|
|
1888
|
+
* @secure
|
|
1889
|
+
* @response `200` `EmptyResponseDto` Instância deslogada com sucesso
|
|
1890
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1891
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1892
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1893
|
+
*/
|
|
1894
|
+
managerInstancesControllerLogoutInstance: ({
|
|
1895
|
+
instanceId,
|
|
1896
|
+
...query
|
|
1897
|
+
}, params = {}) => this.request({
|
|
1898
|
+
path: `/api/instances/${instanceId}/logout`,
|
|
1899
|
+
method: "POST",
|
|
1900
|
+
secure: true,
|
|
1901
|
+
format: "json",
|
|
1902
|
+
...params
|
|
1903
|
+
}),
|
|
1904
|
+
/**
|
|
1905
|
+
* @description Exclui permanentemente uma instância do WhatsApp. Esta ação é irreversível.
|
|
1906
|
+
*
|
|
1907
|
+
* @tags Instâncias
|
|
1908
|
+
* @name ManagerInstancesControllerDeleteInstance
|
|
1909
|
+
* @summary Excluir Instância do WhatsApp (Somente Parceiros)
|
|
1910
|
+
* @request DELETE:/api/instances/{instanceId}
|
|
1911
|
+
* @secure
|
|
1912
|
+
* @response `204` `void` Instância excluída com sucesso
|
|
1913
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1914
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1915
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1916
|
+
*/
|
|
1917
|
+
managerInstancesControllerDeleteInstance: ({
|
|
1918
|
+
instanceId,
|
|
1919
|
+
...query
|
|
1920
|
+
}, params = {}) => this.request({
|
|
1921
|
+
path: `/api/instances/${instanceId}`,
|
|
1922
|
+
method: "DELETE",
|
|
1923
|
+
secure: true,
|
|
1924
|
+
...params
|
|
1925
|
+
}),
|
|
1926
|
+
/**
|
|
1927
|
+
* @description Verifica se uma lista de números de telefone está registrada no WhatsApp
|
|
1928
|
+
*
|
|
1929
|
+
* @tags Instâncias
|
|
1930
|
+
* @name ManagerInstancesControllerCheckNumbers
|
|
1931
|
+
* @summary Verificar Números no WhatsApp
|
|
1932
|
+
* @request POST:/api/instances/{instanceId}/check-numbers
|
|
1933
|
+
* @secure
|
|
1934
|
+
* @response `200` `CheckNumbersResponseDto` Números verificados com sucesso
|
|
1935
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1936
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1937
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1938
|
+
*/
|
|
1939
|
+
managerInstancesControllerCheckNumbers: ({
|
|
1940
|
+
instanceId,
|
|
1941
|
+
...query
|
|
1942
|
+
}, data, params = {}) => this.request({
|
|
1943
|
+
path: `/api/instances/${instanceId}/check-numbers`,
|
|
1944
|
+
method: "POST",
|
|
1945
|
+
body: data,
|
|
1946
|
+
secure: true,
|
|
1947
|
+
type: ContentType.Json,
|
|
1948
|
+
format: "json",
|
|
1949
|
+
...params
|
|
1950
|
+
}),
|
|
1951
|
+
/**
|
|
1952
|
+
* @description Envia um indicador de presença (digitando, gravando, online, etc.) para um contato
|
|
1953
|
+
*
|
|
1954
|
+
* @tags Instâncias
|
|
1955
|
+
* @name ManagerInstancesControllerSendPresence
|
|
1956
|
+
* @summary Enviar Indicador de Presença
|
|
1957
|
+
* @request POST:/api/instances/{instanceId}/presence
|
|
1958
|
+
* @secure
|
|
1959
|
+
* @response `204` `void` Presença enviada com sucesso
|
|
1960
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1961
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1962
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1963
|
+
*/
|
|
1964
|
+
managerInstancesControllerSendPresence: ({
|
|
1965
|
+
instanceId,
|
|
1966
|
+
...query
|
|
1967
|
+
}, data, params = {}) => this.request({
|
|
1968
|
+
path: `/api/instances/${instanceId}/presence`,
|
|
1969
|
+
method: "POST",
|
|
1970
|
+
body: data,
|
|
1971
|
+
secure: true,
|
|
1972
|
+
type: ContentType.Json,
|
|
1973
|
+
...params
|
|
1974
|
+
}),
|
|
1975
|
+
/**
|
|
1976
|
+
* @description Obtém a URL da foto de perfil de um contato
|
|
1977
|
+
*
|
|
1978
|
+
* @tags Instâncias
|
|
1979
|
+
* @name ManagerInstancesControllerGetProfilePicture
|
|
1980
|
+
* @summary Obter Foto de Perfil
|
|
1981
|
+
* @request GET:/api/instances/{instanceId}/contacts/{phone}/profile-picture
|
|
1982
|
+
* @secure
|
|
1983
|
+
* @response `200` `void` Foto de perfil obtida com sucesso
|
|
1984
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
1985
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
1986
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
1987
|
+
*/
|
|
1988
|
+
managerInstancesControllerGetProfilePicture: ({
|
|
1989
|
+
instanceId,
|
|
1990
|
+
phone,
|
|
1991
|
+
...query
|
|
1992
|
+
}, params = {}) => this.request({
|
|
1993
|
+
path: `/api/instances/${instanceId}/contacts/${phone}/profile-picture`,
|
|
1994
|
+
method: "GET",
|
|
1995
|
+
secure: true,
|
|
1996
|
+
...params
|
|
1997
|
+
}),
|
|
1998
|
+
/**
|
|
1999
|
+
* @description Bloqueia um contato no WhatsApp
|
|
2000
|
+
*
|
|
2001
|
+
* @tags Instâncias
|
|
2002
|
+
* @name ManagerInstancesControllerBlockContact
|
|
2003
|
+
* @summary Bloquear Contato
|
|
2004
|
+
* @request POST:/api/instances/{instanceId}/contacts/{phone}/block
|
|
2005
|
+
* @secure
|
|
2006
|
+
* @response `204` `void` Contato bloqueado com sucesso
|
|
2007
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
2008
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
2009
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
2010
|
+
*/
|
|
2011
|
+
managerInstancesControllerBlockContact: ({
|
|
2012
|
+
instanceId,
|
|
2013
|
+
phone,
|
|
2014
|
+
...query
|
|
2015
|
+
}, params = {}) => this.request({
|
|
2016
|
+
path: `/api/instances/${instanceId}/contacts/${phone}/block`,
|
|
2017
|
+
method: "POST",
|
|
2018
|
+
secure: true,
|
|
2019
|
+
...params
|
|
2020
|
+
}),
|
|
2021
|
+
/**
|
|
2022
|
+
* @description Desbloqueia um contato no WhatsApp
|
|
2023
|
+
*
|
|
2024
|
+
* @tags Instâncias
|
|
2025
|
+
* @name ManagerInstancesControllerUnblockContact
|
|
2026
|
+
* @summary Desbloquear Contato
|
|
2027
|
+
* @request DELETE:/api/instances/{instanceId}/contacts/{phone}/block
|
|
2028
|
+
* @secure
|
|
2029
|
+
* @response `204` `void` Contato desbloqueado com sucesso
|
|
2030
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
2031
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
2032
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
2033
|
+
*/
|
|
2034
|
+
managerInstancesControllerUnblockContact: ({
|
|
2035
|
+
instanceId,
|
|
2036
|
+
phone,
|
|
2037
|
+
...query
|
|
2038
|
+
}, params = {}) => this.request({
|
|
2039
|
+
path: `/api/instances/${instanceId}/contacts/${phone}/block`,
|
|
2040
|
+
method: "DELETE",
|
|
2041
|
+
secure: true,
|
|
2042
|
+
...params
|
|
2043
|
+
}),
|
|
2044
|
+
/**
|
|
2045
|
+
* @description Obtém informações detalhadas sobre um grupo do WhatsApp
|
|
2046
|
+
*
|
|
2047
|
+
* @tags Instâncias
|
|
2048
|
+
* @name ManagerInstancesControllerGetGroupMetadata
|
|
2049
|
+
* @summary Obter Metadados do Grupo
|
|
2050
|
+
* @request GET:/api/instances/{instanceId}/groups/{groupId}
|
|
2051
|
+
* @secure
|
|
2052
|
+
* @response `200` `void` Metadados do grupo obtidos com sucesso
|
|
2053
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
2054
|
+
* @response `403` `ForbiddenErrorDto` Acesso negado - Sem acesso ao recurso
|
|
2055
|
+
* @response `404` `NotFoundErrorDto` Recurso não encontrado
|
|
2056
|
+
*/
|
|
2057
|
+
managerInstancesControllerGetGroupMetadata: ({
|
|
2058
|
+
instanceId,
|
|
2059
|
+
groupId,
|
|
2060
|
+
...query
|
|
2061
|
+
}, params = {}) => this.request({
|
|
2062
|
+
path: `/api/instances/${instanceId}/groups/${groupId}`,
|
|
2063
|
+
method: "GET",
|
|
2064
|
+
secure: true,
|
|
2065
|
+
...params
|
|
2066
|
+
})
|
|
2067
|
+
};
|
|
2068
|
+
webhooks = {
|
|
2069
|
+
/**
|
|
2070
|
+
* @description Get the webhook configuration for the authenticated user. Returns null if no webhook is configured.
|
|
2071
|
+
*
|
|
2072
|
+
* @tags Webhooks
|
|
2073
|
+
* @name WebhookControllerGetConfig
|
|
2074
|
+
* @summary Get Webhook Configuration
|
|
2075
|
+
* @request GET:/api/webhooks/config
|
|
2076
|
+
* @secure
|
|
2077
|
+
* @response `200` `WebhookConfigResponseDto` Webhook configuration retrieved successfully
|
|
2078
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
2079
|
+
*/
|
|
2080
|
+
webhookControllerGetConfig: (params = {}) => this.request({
|
|
2081
|
+
path: `/api/webhooks/config`,
|
|
2082
|
+
method: "GET",
|
|
2083
|
+
secure: true,
|
|
2084
|
+
format: "json",
|
|
2085
|
+
...params
|
|
2086
|
+
}),
|
|
2087
|
+
/**
|
|
2088
|
+
* @description Create or update the webhook configuration for the authenticated user. Only one webhook URL can be configured per user, and all instance events will be sent to this URL.
|
|
2089
|
+
*
|
|
2090
|
+
* @tags Webhooks
|
|
2091
|
+
* @name WebhookControllerUpsertConfig
|
|
2092
|
+
* @summary Configure Webhook
|
|
2093
|
+
* @request PUT:/api/webhooks/config
|
|
2094
|
+
* @secure
|
|
2095
|
+
* @response `200` `WebhookConfigResponseDto` Webhook configuration saved successfully
|
|
2096
|
+
* @response `400` `BadRequestErrorDto` Dados da requisição inválidos
|
|
2097
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
2098
|
+
*/
|
|
2099
|
+
webhookControllerUpsertConfig: (data, params = {}) => this.request({
|
|
2100
|
+
path: `/api/webhooks/config`,
|
|
2101
|
+
method: "PUT",
|
|
2102
|
+
body: data,
|
|
2103
|
+
secure: true,
|
|
2104
|
+
type: ContentType.Json,
|
|
2105
|
+
format: "json",
|
|
2106
|
+
...params
|
|
2107
|
+
}),
|
|
2108
|
+
/**
|
|
2109
|
+
* @description Delete the webhook configuration and all queued webhooks for the authenticated user.
|
|
2110
|
+
*
|
|
2111
|
+
* @tags Webhooks
|
|
2112
|
+
* @name WebhookControllerDeleteConfig
|
|
2113
|
+
* @summary Delete Webhook Configuration
|
|
2114
|
+
* @request DELETE:/api/webhooks/config
|
|
2115
|
+
* @secure
|
|
2116
|
+
* @response `204` `void` Webhook configuration deleted successfully
|
|
2117
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
2118
|
+
*/
|
|
2119
|
+
webhookControllerDeleteConfig: (params = {}) => this.request({
|
|
2120
|
+
path: `/api/webhooks/config`,
|
|
2121
|
+
method: "DELETE",
|
|
2122
|
+
secure: true,
|
|
2123
|
+
...params
|
|
2124
|
+
}),
|
|
2125
|
+
/**
|
|
2126
|
+
* @description Get the status of the webhook delivery queue, including counts of pending, failed, paused, and delivered webhooks.
|
|
2127
|
+
*
|
|
2128
|
+
* @tags Webhooks
|
|
2129
|
+
* @name WebhookControllerGetQueueStatus
|
|
2130
|
+
* @summary Get Queue Status
|
|
2131
|
+
* @request GET:/api/webhooks/queue/status
|
|
2132
|
+
* @secure
|
|
2133
|
+
* @response `200` `WebhookQueueStatusResponseDto` Queue status retrieved successfully
|
|
2134
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
2135
|
+
*/
|
|
2136
|
+
webhookControllerGetQueueStatus: (params = {}) => this.request({
|
|
2137
|
+
path: `/api/webhooks/queue/status`,
|
|
2138
|
+
method: "GET",
|
|
2139
|
+
secure: true,
|
|
2140
|
+
format: "json",
|
|
2141
|
+
...params
|
|
2142
|
+
}),
|
|
2143
|
+
/**
|
|
2144
|
+
* @description Resume all paused and failed webhooks. This will unpause the webhook configuration and reset all paused/failed items to pending.
|
|
2145
|
+
*
|
|
2146
|
+
* @tags Webhooks
|
|
2147
|
+
* @name WebhookControllerResumeAll
|
|
2148
|
+
* @summary Resume Webhooks
|
|
2149
|
+
* @request POST:/api/webhooks/queue/resume
|
|
2150
|
+
* @secure
|
|
2151
|
+
* @response `200` `WebhookResumeResponseDto` Webhooks resumed successfully
|
|
2152
|
+
* @response `401` `UnauthorizedErrorDto` Não autorizado - API key inválida ou ausente
|
|
2153
|
+
*/
|
|
2154
|
+
webhookControllerResumeAll: (params = {}) => this.request({
|
|
2155
|
+
path: `/api/webhooks/queue/resume`,
|
|
2156
|
+
method: "POST",
|
|
2157
|
+
secure: true,
|
|
2158
|
+
format: "json",
|
|
2159
|
+
...params
|
|
2160
|
+
})
|
|
2161
|
+
};
|
|
2162
|
+
message = {
|
|
2163
|
+
/**
|
|
2164
|
+
* @description Envia uma mensagem de texto para um contato ou grupo do WhatsApp
|
|
2165
|
+
*
|
|
2166
|
+
* @tags Mensagens
|
|
2167
|
+
* @name SendMessageControllerSendTextMessage
|
|
2168
|
+
* @summary Enviar Mensagem de Texto
|
|
2169
|
+
* @request POST:/api/message/{instanceId}/text
|
|
2170
|
+
* @secure
|
|
2171
|
+
* @response `201` `CommonSendMessageResponseDto` Mensagem enviada com sucesso
|
|
2172
|
+
* @response `400` `void` Dados da requisição inválidos
|
|
2173
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2174
|
+
*/
|
|
2175
|
+
sendMessageControllerSendTextMessage: ({
|
|
2176
|
+
instanceId,
|
|
2177
|
+
...query
|
|
2178
|
+
}, data, params = {}) => this.request({
|
|
2179
|
+
path: `/api/message/${instanceId}/text`,
|
|
2180
|
+
method: "POST",
|
|
2181
|
+
body: data,
|
|
2182
|
+
secure: true,
|
|
2183
|
+
type: ContentType.Json,
|
|
2184
|
+
format: "json",
|
|
2185
|
+
...params
|
|
2186
|
+
}),
|
|
2187
|
+
/**
|
|
2188
|
+
* @description Envia uma mensagem de imagem para um contato ou grupo do WhatsApp
|
|
2189
|
+
*
|
|
2190
|
+
* @tags Mensagens
|
|
2191
|
+
* @name SendMessageControllerSendImageMessage
|
|
2192
|
+
* @summary Enviar Mensagem de Imagem
|
|
2193
|
+
* @request POST:/api/message/{instanceId}/image
|
|
2194
|
+
* @secure
|
|
2195
|
+
* @response `201` `CommonSendMessageResponseDto` Mensagem de imagem enviada com sucesso
|
|
2196
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de imagem inválido
|
|
2197
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2198
|
+
*/
|
|
2199
|
+
sendMessageControllerSendImageMessage: ({
|
|
2200
|
+
instanceId,
|
|
2201
|
+
...query
|
|
2202
|
+
}, data, params = {}) => this.request({
|
|
2203
|
+
path: `/api/message/${instanceId}/image`,
|
|
2204
|
+
method: "POST",
|
|
2205
|
+
body: data,
|
|
2206
|
+
secure: true,
|
|
2207
|
+
type: ContentType.Json,
|
|
2208
|
+
format: "json",
|
|
2209
|
+
...params
|
|
2210
|
+
}),
|
|
2211
|
+
/**
|
|
2212
|
+
* @description Envia uma mensagem de vídeo para um contato ou grupo do WhatsApp
|
|
2213
|
+
*
|
|
2214
|
+
* @tags Mensagens
|
|
2215
|
+
* @name SendMessageControllerSendVideoMessage
|
|
2216
|
+
* @summary Enviar Mensagem de Vídeo
|
|
2217
|
+
* @request POST:/api/message/{instanceId}/video
|
|
2218
|
+
* @secure
|
|
2219
|
+
* @response `201` `CommonSendMessageResponseDto` Mensagem de vídeo enviada com sucesso
|
|
2220
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de vídeo inválido
|
|
2221
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2222
|
+
*/
|
|
2223
|
+
sendMessageControllerSendVideoMessage: ({
|
|
2224
|
+
instanceId,
|
|
2225
|
+
...query
|
|
2226
|
+
}, data, params = {}) => this.request({
|
|
2227
|
+
path: `/api/message/${instanceId}/video`,
|
|
2228
|
+
method: "POST",
|
|
2229
|
+
body: data,
|
|
2230
|
+
secure: true,
|
|
2231
|
+
type: ContentType.Json,
|
|
2232
|
+
format: "json",
|
|
2233
|
+
...params
|
|
2234
|
+
}),
|
|
2235
|
+
/**
|
|
2236
|
+
* @description Envia uma nota de voz para um contato ou grupo do WhatsApp
|
|
2237
|
+
*
|
|
2238
|
+
* @tags Mensagens
|
|
2239
|
+
* @name SendMessageControllerSendAudioNoteMessage
|
|
2240
|
+
* @summary Enviar Mensagem de Áudio (Nota de Voz)
|
|
2241
|
+
* @request POST:/api/message/{instanceId}/audio-note
|
|
2242
|
+
* @secure
|
|
2243
|
+
* @response `201` `CommonSendMessageResponseDto` Nota de voz enviada com sucesso
|
|
2244
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de áudio inválido
|
|
2245
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2246
|
+
*/
|
|
2247
|
+
sendMessageControllerSendAudioNoteMessage: ({
|
|
2248
|
+
instanceId,
|
|
2249
|
+
...query
|
|
2250
|
+
}, data, params = {}) => this.request({
|
|
2251
|
+
path: `/api/message/${instanceId}/audio-note`,
|
|
2252
|
+
method: "POST",
|
|
2253
|
+
body: data,
|
|
2254
|
+
secure: true,
|
|
2255
|
+
type: ContentType.Json,
|
|
2256
|
+
format: "json",
|
|
2257
|
+
...params
|
|
2258
|
+
}),
|
|
2259
|
+
/**
|
|
2260
|
+
* @description Envia um arquivo de áudio para um contato ou grupo do WhatsApp
|
|
2261
|
+
*
|
|
2262
|
+
* @tags Mensagens
|
|
2263
|
+
* @name SendMessageControllerSendAudioFileMessage
|
|
2264
|
+
* @summary Enviar Arquivo de Áudio
|
|
2265
|
+
* @request POST:/api/message/{instanceId}/audio-file
|
|
2266
|
+
* @secure
|
|
2267
|
+
* @response `201` `CommonSendMessageResponseDto` Arquivo de áudio enviado com sucesso
|
|
2268
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de áudio inválido
|
|
2269
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2270
|
+
*/
|
|
2271
|
+
sendMessageControllerSendAudioFileMessage: ({
|
|
2272
|
+
instanceId,
|
|
2273
|
+
...query
|
|
2274
|
+
}, data, params = {}) => this.request({
|
|
2275
|
+
path: `/api/message/${instanceId}/audio-file`,
|
|
2276
|
+
method: "POST",
|
|
2277
|
+
body: data,
|
|
2278
|
+
secure: true,
|
|
2279
|
+
type: ContentType.Json,
|
|
2280
|
+
format: "json",
|
|
2281
|
+
...params
|
|
2282
|
+
}),
|
|
2283
|
+
/**
|
|
2284
|
+
* @description Envia um arquivo de documento para um contato ou grupo do WhatsApp
|
|
2285
|
+
*
|
|
2286
|
+
* @tags Mensagens
|
|
2287
|
+
* @name SendMessageControllerSendDocumentMessage
|
|
2288
|
+
* @summary Enviar Documento
|
|
2289
|
+
* @request POST:/api/message/{instanceId}/document
|
|
2290
|
+
* @secure
|
|
2291
|
+
* @response `201` `CommonSendMessageResponseDto` Documento enviado com sucesso
|
|
2292
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de documento inválido
|
|
2293
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2294
|
+
*/
|
|
2295
|
+
sendMessageControllerSendDocumentMessage: ({
|
|
2296
|
+
instanceId,
|
|
2297
|
+
...query
|
|
2298
|
+
}, data, params = {}) => this.request({
|
|
2299
|
+
path: `/api/message/${instanceId}/document`,
|
|
2300
|
+
method: "POST",
|
|
2301
|
+
body: data,
|
|
2302
|
+
secure: true,
|
|
2303
|
+
type: ContentType.Json,
|
|
2304
|
+
format: "json",
|
|
2305
|
+
...params
|
|
2306
|
+
}),
|
|
2307
|
+
/**
|
|
2308
|
+
* @description Encaminha uma mensagem existente para outro contato ou grupo do WhatsApp
|
|
2309
|
+
*
|
|
2310
|
+
* @tags Mensagens
|
|
2311
|
+
* @name SendMessageControllerForwardMessage
|
|
2312
|
+
* @summary Encaminhar Mensagem
|
|
2313
|
+
* @request POST:/api/message/{instanceId}/forward
|
|
2314
|
+
* @secure
|
|
2315
|
+
* @response `201` `CommonSendMessageResponseDto` Mensagem encaminhada com sucesso
|
|
2316
|
+
* @response `400` `void` Dados da requisição inválidos ou mensagem não encontrada
|
|
2317
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2318
|
+
*/
|
|
2319
|
+
sendMessageControllerForwardMessage: ({
|
|
2320
|
+
instanceId,
|
|
2321
|
+
...query
|
|
2322
|
+
}, data, params = {}) => this.request({
|
|
2323
|
+
path: `/api/message/${instanceId}/forward`,
|
|
2324
|
+
method: "POST",
|
|
2325
|
+
body: data,
|
|
2326
|
+
secure: true,
|
|
2327
|
+
type: ContentType.Json,
|
|
2328
|
+
format: "json",
|
|
2329
|
+
...params
|
|
2330
|
+
}),
|
|
2331
|
+
/**
|
|
2332
|
+
* @description Edita o conteúdo de uma mensagem de texto existente
|
|
2333
|
+
*
|
|
2334
|
+
* @tags Mensagens
|
|
2335
|
+
* @name SendMessageControllerEditMessage
|
|
2336
|
+
* @summary Editar Mensagem
|
|
2337
|
+
* @request POST:/api/message/{instanceId}/edit
|
|
2338
|
+
* @secure
|
|
2339
|
+
* @response `201` `CommonSendMessageResponseDto` Mensagem editada com sucesso
|
|
2340
|
+
* @response `400` `void` Dados da requisição inválidos ou mensagem não pode ser editada
|
|
2341
|
+
* @response `404` `void` Instância do WhatsApp ou mensagem não encontrada
|
|
2342
|
+
*/
|
|
2343
|
+
sendMessageControllerEditMessage: ({
|
|
2344
|
+
instanceId,
|
|
2345
|
+
...query
|
|
2346
|
+
}, data, params = {}) => this.request({
|
|
2347
|
+
path: `/api/message/${instanceId}/edit`,
|
|
2348
|
+
method: "POST",
|
|
2349
|
+
body: data,
|
|
2350
|
+
secure: true,
|
|
2351
|
+
type: ContentType.Json,
|
|
2352
|
+
format: "json",
|
|
2353
|
+
...params
|
|
2354
|
+
}),
|
|
2355
|
+
/**
|
|
2356
|
+
* @description Marca uma mensagem como lida (envia confirmação de leitura)
|
|
2357
|
+
*
|
|
2358
|
+
* @tags Mensagens
|
|
2359
|
+
* @name SendMessageControllerReadMessage
|
|
2360
|
+
* @summary Marcar Mensagem como Lida
|
|
2361
|
+
* @request POST:/api/message/{instanceId}/read
|
|
2362
|
+
* @secure
|
|
2363
|
+
* @response `201` `ReadMessageResponseDto` Mensagem marcada como lida com sucesso
|
|
2364
|
+
* @response `400` `void` Dados da requisição inválidos
|
|
2365
|
+
* @response `404` `void` Instância do WhatsApp ou mensagem não encontrada
|
|
2366
|
+
*/
|
|
2367
|
+
sendMessageControllerReadMessage: ({
|
|
2368
|
+
instanceId,
|
|
2369
|
+
...query
|
|
2370
|
+
}, data, params = {}) => this.request({
|
|
2371
|
+
path: `/api/message/${instanceId}/read`,
|
|
2372
|
+
method: "POST",
|
|
2373
|
+
body: data,
|
|
2374
|
+
secure: true,
|
|
2375
|
+
type: ContentType.Json,
|
|
2376
|
+
format: "json",
|
|
2377
|
+
...params
|
|
2378
|
+
}),
|
|
2379
|
+
/**
|
|
2380
|
+
* @description Envia uma localização geográfica para um contato ou grupo do WhatsApp
|
|
2381
|
+
*
|
|
2382
|
+
* @tags Mensagens
|
|
2383
|
+
* @name SendMessageControllerSendLocationMessage
|
|
2384
|
+
* @summary Enviar Localização
|
|
2385
|
+
* @request POST:/api/message/{instanceId}/location
|
|
2386
|
+
* @secure
|
|
2387
|
+
* @response `201` `CommonSendMessageResponseDto` Localização enviada com sucesso
|
|
2388
|
+
* @response `400` `void` Dados da requisição inválidos
|
|
2389
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2390
|
+
*/
|
|
2391
|
+
sendMessageControllerSendLocationMessage: ({
|
|
2392
|
+
instanceId,
|
|
2393
|
+
...query
|
|
2394
|
+
}, data, params = {}) => this.request({
|
|
2395
|
+
path: `/api/message/${instanceId}/location`,
|
|
2396
|
+
method: "POST",
|
|
2397
|
+
body: data,
|
|
2398
|
+
secure: true,
|
|
2399
|
+
type: ContentType.Json,
|
|
2400
|
+
format: "json",
|
|
2401
|
+
...params
|
|
2402
|
+
}),
|
|
2403
|
+
/**
|
|
2404
|
+
* @description Envia um cartão de contato para um contato ou grupo do WhatsApp
|
|
2405
|
+
*
|
|
2406
|
+
* @tags Mensagens
|
|
2407
|
+
* @name SendMessageControllerSendContactMessage
|
|
2408
|
+
* @summary Enviar Contato
|
|
2409
|
+
* @request POST:/api/message/{instanceId}/contact
|
|
2410
|
+
* @secure
|
|
2411
|
+
* @response `201` `CommonSendMessageResponseDto` Contato enviado com sucesso
|
|
2412
|
+
* @response `400` `void` Dados da requisição inválidos
|
|
2413
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2414
|
+
*/
|
|
2415
|
+
sendMessageControllerSendContactMessage: ({
|
|
2416
|
+
instanceId,
|
|
2417
|
+
...query
|
|
2418
|
+
}, data, params = {}) => this.request({
|
|
2419
|
+
path: `/api/message/${instanceId}/contact`,
|
|
2420
|
+
method: "POST",
|
|
2421
|
+
body: data,
|
|
2422
|
+
secure: true,
|
|
2423
|
+
type: ContentType.Json,
|
|
2424
|
+
format: "json",
|
|
2425
|
+
...params
|
|
2426
|
+
}),
|
|
2427
|
+
/**
|
|
2428
|
+
* @description Envia um sticker para um contato ou grupo do WhatsApp
|
|
2429
|
+
*
|
|
2430
|
+
* @tags Mensagens
|
|
2431
|
+
* @name SendMessageControllerSendStickerMessage
|
|
2432
|
+
* @summary Enviar Sticker
|
|
2433
|
+
* @request POST:/api/message/{instanceId}/sticker
|
|
2434
|
+
* @secure
|
|
2435
|
+
* @response `201` `CommonSendMessageResponseDto` Sticker enviado com sucesso
|
|
2436
|
+
* @response `400` `void` Dados da requisição inválidos ou formato de sticker inválido
|
|
2437
|
+
* @response `404` `void` Instância do WhatsApp não encontrada
|
|
2438
|
+
*/
|
|
2439
|
+
sendMessageControllerSendStickerMessage: ({
|
|
2440
|
+
instanceId,
|
|
2441
|
+
...query
|
|
2442
|
+
}, data, params = {}) => this.request({
|
|
2443
|
+
path: `/api/message/${instanceId}/sticker`,
|
|
2444
|
+
method: "POST",
|
|
2445
|
+
body: data,
|
|
2446
|
+
secure: true,
|
|
2447
|
+
type: ContentType.Json,
|
|
2448
|
+
format: "json",
|
|
2449
|
+
...params
|
|
2450
|
+
}),
|
|
2451
|
+
/**
|
|
2452
|
+
* @description Adiciona uma reação (emoji) a uma mensagem existente
|
|
2453
|
+
*
|
|
2454
|
+
* @tags Mensagens
|
|
2455
|
+
* @name SendMessageControllerSendReaction
|
|
2456
|
+
* @summary Enviar Reação
|
|
2457
|
+
* @request POST:/api/message/{instanceId}/reaction
|
|
2458
|
+
* @secure
|
|
2459
|
+
* @response `204` `void` Reação enviada com sucesso
|
|
2460
|
+
* @response `400` `void` Dados da requisição inválidos
|
|
2461
|
+
* @response `404` `void` Instância do WhatsApp ou mensagem não encontrada
|
|
2462
|
+
*/
|
|
2463
|
+
sendMessageControllerSendReaction: ({
|
|
2464
|
+
instanceId,
|
|
2465
|
+
...query
|
|
2466
|
+
}, data, params = {}) => this.request({
|
|
2467
|
+
path: `/api/message/${instanceId}/reaction`,
|
|
2468
|
+
method: "POST",
|
|
2469
|
+
body: data,
|
|
2470
|
+
secure: true,
|
|
2471
|
+
type: ContentType.Json,
|
|
2472
|
+
...params
|
|
2473
|
+
}),
|
|
2474
|
+
/**
|
|
2475
|
+
* @description Exclui uma mensagem para todos no chat
|
|
2476
|
+
*
|
|
2477
|
+
* @tags Mensagens
|
|
2478
|
+
* @name SendMessageControllerDeleteMessage
|
|
2479
|
+
* @summary Excluir Mensagem
|
|
2480
|
+
* @request DELETE:/api/message/{instanceId}/delete
|
|
2481
|
+
* @secure
|
|
2482
|
+
* @response `204` `void` Mensagem excluída com sucesso
|
|
2483
|
+
* @response `400` `void` Dados da requisição inválidos ou mensagem não pode ser excluída
|
|
2484
|
+
* @response `404` `void` Instância do WhatsApp ou mensagem não encontrada
|
|
2485
|
+
*/
|
|
2486
|
+
sendMessageControllerDeleteMessage: ({
|
|
2487
|
+
instanceId,
|
|
2488
|
+
...query
|
|
2489
|
+
}, data, params = {}) => this.request({
|
|
2490
|
+
path: `/api/message/${instanceId}/delete`,
|
|
2491
|
+
method: "DELETE",
|
|
2492
|
+
body: data,
|
|
2493
|
+
secure: true,
|
|
2494
|
+
type: ContentType.Json,
|
|
2495
|
+
...params
|
|
2496
|
+
}),
|
|
2497
|
+
/**
|
|
2498
|
+
* @description Obtém um link de download para conteúdo de mídia de uma mensagem
|
|
2499
|
+
*
|
|
2500
|
+
* @tags Mensagens
|
|
2501
|
+
* @name SendMessageControllerGetMessageMediaDownloadLink
|
|
2502
|
+
* @summary Obter Link de Download de Mídia
|
|
2503
|
+
* @request GET:/api/message/{instanceId}/media-download-link/{messageId}
|
|
2504
|
+
* @secure
|
|
2505
|
+
* @response `200` `GetMessageMediaDownloadLinkResponseDto` Link de download de mídia obtido com sucesso
|
|
2506
|
+
* @response `400` `void` Formato de ID da mensagem inválido
|
|
2507
|
+
* @response `404` `void` Instância do WhatsApp, mensagem ou mídia não encontrada
|
|
2508
|
+
*/
|
|
2509
|
+
sendMessageControllerGetMessageMediaDownloadLink: ({
|
|
2510
|
+
instanceId,
|
|
2511
|
+
messageId,
|
|
2512
|
+
...query
|
|
2513
|
+
}, params = {}) => this.request({
|
|
2514
|
+
path: `/api/message/${instanceId}/media-download-link/${messageId}`,
|
|
2515
|
+
method: "GET",
|
|
2516
|
+
secure: true,
|
|
2517
|
+
format: "json",
|
|
2518
|
+
...params
|
|
2519
|
+
})
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
export { AuthenticationError, InstanceNotFoundError, InstanceStatus, NetworkError, RateLimitError, TimeoutError, ValidationError, WebhookQueueStatus, ZapyApiError, ZapyClient, ZapyError, ZapyEventTypes, ZapyMessageStatusEnum, ZapyMessageType, Api as ZapyRestApi, createClient, extractPhone, isAudioMessage, isCallMessage, isContactMessage, isDeletedMessage, isDocumentMessage, isEditedMessage, isGroup, isImageMessage, isLiveLocationMessage, isLocationMessage, isMediaMessage, isPollMessage, isPollVoteMessage, isReactionMessage, isStickerMessage, isTextMessage, isUnsupportedMessage, isValidPhone, isVideoMessage, normalizePhone, verifyWebhookSignature, verifyWebhookSignatureAsync };
|