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