@warriorteam/redai-zalo-sdk 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +448 -0
  3. package/dist/clients/base-client.d.ts +67 -0
  4. package/dist/clients/base-client.d.ts.map +1 -0
  5. package/dist/clients/base-client.js +297 -0
  6. package/dist/clients/base-client.js.map +1 -0
  7. package/dist/clients/zalo-client.d.ts +131 -0
  8. package/dist/clients/zalo-client.d.ts.map +1 -0
  9. package/dist/clients/zalo-client.js +215 -0
  10. package/dist/clients/zalo-client.js.map +1 -0
  11. package/dist/index.d.ts +40 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +82 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/services/article.service.d.ts +144 -0
  16. package/dist/services/article.service.d.ts.map +1 -0
  17. package/dist/services/article.service.js +518 -0
  18. package/dist/services/article.service.js.map +1 -0
  19. package/dist/services/auth.service.d.ts +55 -0
  20. package/dist/services/auth.service.d.ts.map +1 -0
  21. package/dist/services/auth.service.js +269 -0
  22. package/dist/services/auth.service.js.map +1 -0
  23. package/dist/services/consultation.service.d.ts +73 -0
  24. package/dist/services/consultation.service.d.ts.map +1 -0
  25. package/dist/services/consultation.service.js +208 -0
  26. package/dist/services/consultation.service.js.map +1 -0
  27. package/dist/services/general-message.service.d.ts +85 -0
  28. package/dist/services/general-message.service.d.ts.map +1 -0
  29. package/dist/services/general-message.service.js +248 -0
  30. package/dist/services/general-message.service.js.map +1 -0
  31. package/dist/services/group-management.service.d.ts +220 -0
  32. package/dist/services/group-management.service.d.ts.map +1 -0
  33. package/dist/services/group-management.service.js +562 -0
  34. package/dist/services/group-management.service.js.map +1 -0
  35. package/dist/services/group-message.service.d.ts +102 -0
  36. package/dist/services/group-message.service.d.ts.map +1 -0
  37. package/dist/services/group-message.service.js +233 -0
  38. package/dist/services/group-message.service.js.map +1 -0
  39. package/dist/services/message-management.service.d.ts +135 -0
  40. package/dist/services/message-management.service.d.ts.map +1 -0
  41. package/dist/services/message-management.service.js +237 -0
  42. package/dist/services/message-management.service.js.map +1 -0
  43. package/dist/services/oa.service.d.ts +67 -0
  44. package/dist/services/oa.service.d.ts.map +1 -0
  45. package/dist/services/oa.service.js +223 -0
  46. package/dist/services/oa.service.js.map +1 -0
  47. package/dist/services/promotion.service.d.ts +114 -0
  48. package/dist/services/promotion.service.d.ts.map +1 -0
  49. package/dist/services/promotion.service.js +247 -0
  50. package/dist/services/promotion.service.js.map +1 -0
  51. package/dist/services/tag.service.d.ts +144 -0
  52. package/dist/services/tag.service.d.ts.map +1 -0
  53. package/dist/services/tag.service.js +184 -0
  54. package/dist/services/tag.service.js.map +1 -0
  55. package/dist/services/transaction.service.d.ts +110 -0
  56. package/dist/services/transaction.service.d.ts.map +1 -0
  57. package/dist/services/transaction.service.js +231 -0
  58. package/dist/services/transaction.service.js.map +1 -0
  59. package/dist/services/user-management.service.d.ts +117 -0
  60. package/dist/services/user-management.service.d.ts.map +1 -0
  61. package/dist/services/user-management.service.js +239 -0
  62. package/dist/services/user-management.service.js.map +1 -0
  63. package/dist/services/user.service.d.ts +84 -0
  64. package/dist/services/user.service.d.ts.map +1 -0
  65. package/dist/services/user.service.js +323 -0
  66. package/dist/services/user.service.js.map +1 -0
  67. package/dist/services/video-upload.service.d.ts +83 -0
  68. package/dist/services/video-upload.service.d.ts.map +1 -0
  69. package/dist/services/video-upload.service.js +267 -0
  70. package/dist/services/video-upload.service.js.map +1 -0
  71. package/dist/services/zns.service.d.ts +116 -0
  72. package/dist/services/zns.service.d.ts.map +1 -0
  73. package/dist/services/zns.service.js +234 -0
  74. package/dist/services/zns.service.js.map +1 -0
  75. package/dist/types/article.d.ts +352 -0
  76. package/dist/types/article.d.ts.map +1 -0
  77. package/dist/types/article.js +70 -0
  78. package/dist/types/article.js.map +1 -0
  79. package/dist/types/auth.d.ts +233 -0
  80. package/dist/types/auth.d.ts.map +1 -0
  81. package/dist/types/auth.js +39 -0
  82. package/dist/types/auth.js.map +1 -0
  83. package/dist/types/common.d.ts +237 -0
  84. package/dist/types/common.d.ts.map +1 -0
  85. package/dist/types/common.js +42 -0
  86. package/dist/types/common.js.map +1 -0
  87. package/dist/types/group.d.ts +523 -0
  88. package/dist/types/group.d.ts.map +1 -0
  89. package/dist/types/group.js +6 -0
  90. package/dist/types/group.js.map +1 -0
  91. package/dist/types/message.d.ts +333 -0
  92. package/dist/types/message.d.ts.map +1 -0
  93. package/dist/types/message.js +17 -0
  94. package/dist/types/message.js.map +1 -0
  95. package/dist/types/oa.d.ts +285 -0
  96. package/dist/types/oa.d.ts.map +1 -0
  97. package/dist/types/oa.js +25 -0
  98. package/dist/types/oa.js.map +1 -0
  99. package/dist/types/social.d.ts +427 -0
  100. package/dist/types/social.d.ts.map +1 -0
  101. package/dist/types/social.js +6 -0
  102. package/dist/types/social.js.map +1 -0
  103. package/dist/types/user-management.d.ts +280 -0
  104. package/dist/types/user-management.d.ts.map +1 -0
  105. package/dist/types/user-management.js +6 -0
  106. package/dist/types/user-management.js.map +1 -0
  107. package/dist/types/user.d.ts +365 -0
  108. package/dist/types/user.d.ts.map +1 -0
  109. package/dist/types/user.js +17 -0
  110. package/dist/types/user.js.map +1 -0
  111. package/dist/types/webhook.d.ts +1972 -0
  112. package/dist/types/webhook.d.ts.map +1 -0
  113. package/dist/types/webhook.js +419 -0
  114. package/dist/types/webhook.js.map +1 -0
  115. package/dist/types/zns.d.ts +277 -0
  116. package/dist/types/zns.d.ts.map +1 -0
  117. package/dist/types/zns.js +6 -0
  118. package/dist/types/zns.js.map +1 -0
  119. package/dist/zalo-sdk.d.ts +228 -0
  120. package/dist/zalo-sdk.d.ts.map +1 -0
  121. package/dist/zalo-sdk.js +307 -0
  122. package/dist/zalo-sdk.js.map +1 -0
  123. package/package.json +59 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RedAI Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,448 @@
1
+ # RedAI Zalo SDK
2
+
3
+ A comprehensive TypeScript/JavaScript SDK for Zalo APIs, providing easy-to-use interfaces for:
4
+
5
+ - **Official Account (OA) API** - Manage your Zalo Official Account
6
+ - **Zalo Notification Service (ZNS)** - Send template-based notification messages
7
+ - **Social API** - Access user social information and authentication
8
+ - **Group Message Framework (GMF)** - Send messages to Zalo groups
9
+ - **User Management** - Comprehensive user profile and tag management
10
+ - **Content Management** - Upload and manage media content (images, files, articles)
11
+ - **Video Upload** - Upload and manage video content with processing
12
+ - **Tag Management** - User tagging and segmentation
13
+ - **Webhook handling** - Process Zalo webhook events
14
+
15
+ ## Features
16
+
17
+ - 🚀 **TypeScript Support** - Full type safety and IntelliSense
18
+ - 🔐 **OAuth 2.0 Flow** - Complete authentication handling
19
+ - 🔄 **Auto Retry** - Built-in retry mechanism for failed requests
20
+ - 📝 **Comprehensive Logging** - Debug and monitor API calls
21
+ - 🛡️ **Error Handling** - Detailed error information and handling
22
+ - 📦 **Zero Dependencies** - Only requires axios and form-data
23
+ - 🎯 **Promise-based** - Modern async/await support
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install redai-zalo-sdk
29
+ ```
30
+
31
+ ## Development
32
+
33
+ ### Build from source
34
+
35
+ ```bash
36
+ # Clone the repository
37
+ git clone https://github.com/redai/redai-zalo-sdk.git
38
+ cd redai-zalo-sdk
39
+
40
+ # Install dependencies
41
+ npm install
42
+
43
+ # Build the SDK
44
+ npm run build
45
+
46
+ # Run examples
47
+ npm run dev
48
+ ```
49
+
50
+ ## Quick Start
51
+
52
+ ### Initialize the SDK
53
+
54
+ ```typescript
55
+ import { ZaloSDK } from "redai-zalo-sdk";
56
+
57
+ const zalo = new ZaloSDK({
58
+ appId: "your-app-id",
59
+ appSecret: "your-app-secret",
60
+ debug: true, // Enable debug logging
61
+ });
62
+ ```
63
+
64
+ ### Authentication Flow
65
+
66
+ #### Official Account (OA) Authentication
67
+
68
+ ```typescript
69
+ // 1. Create authorization URL
70
+ const authUrl = zalo.createOAAuthUrl("https://your-app.com/callback");
71
+ console.log("Visit:", authUrl);
72
+
73
+ // 2. Exchange authorization code for access token
74
+ const accessToken = await zalo.getOAAccessToken(
75
+ "authorization-code-from-callback",
76
+ "https://your-app.com/callback"
77
+ );
78
+
79
+ console.log("Access Token:", accessToken.access_token);
80
+ ```
81
+
82
+ #### Social API Authentication
83
+
84
+ ```typescript
85
+ // 1. Generate PKCE for security (recommended)
86
+ const pkce = zalo.generatePKCE();
87
+
88
+ // 2. Create authorization URL
89
+ const authUrl = zalo.createSocialAuthUrl("https://your-app.com/callback");
90
+
91
+ // 3. Exchange code for access token
92
+ const accessToken = await zalo.getSocialAccessToken(
93
+ "authorization-code",
94
+ "https://your-app.com/callback",
95
+ pkce.code_verifier
96
+ );
97
+ ```
98
+
99
+ ### Official Account Operations
100
+
101
+ ```typescript
102
+ // Get OA information
103
+ const oaInfo = await zalo.getOAInfo(accessToken.access_token);
104
+ console.log("OA Name:", oaInfo.name);
105
+ console.log("Followers:", oaInfo.num_follower);
106
+
107
+ // Check message quota
108
+ const quota = await zalo.getMessageQuota(accessToken.access_token);
109
+ console.log("Daily Quota:", quota.daily_quota);
110
+ console.log("Remaining:", quota.remaining_quota);
111
+
112
+ // Get detailed quota information
113
+ const detailedQuota = await zalo.oa.getQuotaSummary(accessToken.access_token);
114
+ console.log("Consultation Quota:", detailedQuota.consultation);
115
+ console.log("Transaction Quota:", detailedQuota.transaction);
116
+ ```
117
+
118
+ ### Social API Operations
119
+
120
+ ```typescript
121
+ // Get user information
122
+ const userInfo = await zalo.getSocialUserInfo(
123
+ accessToken.access_token,
124
+ "id,name,picture,birthday"
125
+ );
126
+
127
+ console.log("User ID:", userInfo.id);
128
+ console.log("Name:", userInfo.name);
129
+ console.log("Avatar:", userInfo.picture?.data.url);
130
+ ```
131
+
132
+ ### Token Management
133
+
134
+ ```typescript
135
+ // Refresh OA access token
136
+ const newOAToken = await zalo.refreshOAAccessToken(refreshToken);
137
+
138
+ // Refresh Social access token
139
+ const newSocialToken = await zalo.refreshSocialAccessToken(refreshToken);
140
+
141
+ // Validate token
142
+ const isValid = await zalo.validateAccessToken(accessToken.access_token, "oa");
143
+ ```
144
+
145
+ ## Advanced Usage
146
+
147
+ ### Custom API Requests
148
+
149
+ ```typescript
150
+ // Make custom API calls
151
+ const customData = await zalo.customRequest(
152
+ "POST",
153
+ "/v3.0/oa/message/cs",
154
+ accessToken.access_token,
155
+ {
156
+ recipient: { user_id: "user-id" },
157
+ message: { text: "Hello from SDK!" },
158
+ }
159
+ );
160
+ ```
161
+
162
+ ### File Upload
163
+
164
+ ```typescript
165
+ import fs from "fs";
166
+
167
+ // Upload image
168
+ const fileBuffer = fs.readFileSync("image.jpg");
169
+ const uploadResult = await zalo.uploadFile(
170
+ "/v2.0/oa/upload/image",
171
+ accessToken.access_token,
172
+ fileBuffer,
173
+ "image.jpg"
174
+ );
175
+
176
+ console.log("Uploaded URL:", uploadResult.data.url);
177
+ ```
178
+
179
+ ### Error Handling
180
+
181
+ ```typescript
182
+ import { ZaloSDKError } from "redai-zalo-sdk";
183
+
184
+ try {
185
+ const oaInfo = await zalo.getOAInfo(accessToken.access_token);
186
+ } catch (error) {
187
+ if (error instanceof ZaloSDKError) {
188
+ console.error("Zalo API Error:", error.message);
189
+ console.error("Error Code:", error.code);
190
+ console.error("Details:", error.details);
191
+ } else {
192
+ console.error("Unexpected error:", error);
193
+ }
194
+ }
195
+ ```
196
+
197
+ ## Configuration Options
198
+
199
+ ```typescript
200
+ const zalo = new ZaloSDK({
201
+ appId: "your-app-id",
202
+ appSecret: "your-app-secret",
203
+
204
+ // Optional configurations
205
+ timeout: 30000, // Request timeout in ms (default: 30000)
206
+ debug: false, // Enable debug logging (default: false)
207
+ apiBaseUrl: "https://openapi.zalo.me", // Custom API base URL
208
+
209
+ // Retry configuration
210
+ retry: {
211
+ attempts: 3, // Number of retry attempts (default: 3)
212
+ delay: 1000, // Delay between retries in ms (default: 1000)
213
+ },
214
+ });
215
+ ```
216
+
217
+ ## API Reference
218
+
219
+ ### ZaloSDK Class
220
+
221
+ #### Constructor
222
+
223
+ - `new ZaloSDK(config: ZaloSDKConfig)`
224
+
225
+ #### Authentication Methods
226
+
227
+ - `createOAAuthUrl(redirectUri: string, state?: string): string`
228
+ - `createSocialAuthUrl(redirectUri: string, state?: string): string`
229
+ - `getOAAccessToken(code: string, redirectUri: string): Promise<AccessToken>`
230
+ - `getSocialAccessToken(code: string, redirectUri: string, codeVerifier?: string): Promise<AccessToken>`
231
+ - `refreshOAAccessToken(refreshToken: string): Promise<AccessToken>`
232
+ - `refreshSocialAccessToken(refreshToken: string): Promise<AccessToken>`
233
+
234
+ #### OA Methods
235
+
236
+ - `getOAInfo(accessToken: string): Promise<OAInfo>`
237
+ - `getMessageQuota(accessToken: string): Promise<MessageQuota>`
238
+
239
+ #### Social Methods
240
+
241
+ - `getSocialUserInfo(accessToken: string, fields?: string): Promise<SocialUserInfo>`
242
+
243
+ #### Utility Methods
244
+
245
+ - `validateAccessToken(accessToken: string, scope?: 'oa' | 'social'): Promise<boolean>`
246
+ - `generatePKCE(): PKCEConfig`
247
+ - `testConnection(): Promise<boolean>`
248
+
249
+ ### Services
250
+
251
+ #### AuthService
252
+
253
+ - Complete OAuth 2.0 flow handling
254
+ - PKCE support for Social API
255
+ - Token validation and refresh
256
+
257
+ #### OAService
258
+
259
+ - Official Account information management
260
+ - Quota monitoring and management
261
+ - Profile updates
262
+
263
+ ## Error Handling
264
+
265
+ The SDK throws `ZaloSDKError` for all Zalo API related errors:
266
+
267
+ ```typescript
268
+ class ZaloSDKError extends Error {
269
+ code: number; // Zalo API error code
270
+ details?: any; // Additional error details
271
+ }
272
+ ```
273
+
274
+ Common error codes:
275
+
276
+ - `-216`: Invalid access token
277
+ - `-201`: Invalid parameters
278
+ - `-223`: Quota exceeded
279
+
280
+ ## TypeScript Support
281
+
282
+ The SDK is written in TypeScript and provides comprehensive type definitions:
283
+
284
+ ```typescript
285
+ import {
286
+ ZaloSDK,
287
+ ZaloSDKConfig,
288
+ AccessToken,
289
+ OAInfo,
290
+ SocialUserInfo,
291
+ ZaloSDKError,
292
+ } from "redai-zalo-sdk";
293
+ ```
294
+
295
+ ## Contributing
296
+
297
+ 1. Fork the repository
298
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
299
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
300
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
301
+ 5. Open a Pull Request
302
+
303
+ ## License
304
+
305
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
306
+
307
+ ## Support
308
+
309
+ For support and questions:
310
+
311
+ - Create an issue on GitHub
312
+ - Contact RedAI team
313
+
314
+ ### ZNS (Zalo Notification Service)
315
+
316
+ ```typescript
317
+ // Send ZNS notification
318
+ await zalo.zns.sendMessage(accessToken, {
319
+ phone: "0123456789",
320
+ template_id: "your-template-id",
321
+ template_data: {
322
+ customer_name: "John Doe",
323
+ order_id: "12345",
324
+ },
325
+ });
326
+
327
+ // Get ZNS quota
328
+ const quota = await zalo.zns.getQuotaInfo(accessToken);
329
+
330
+ // Manage ZNS templates
331
+ const templates = await zalo.zns.getTemplateList(accessToken);
332
+ const template = await zalo.zns.createTemplate(accessToken, {
333
+ templateName: "Order Confirmation",
334
+ templateContent:
335
+ "Hello {{customer_name}}, your order {{order_id}} is confirmed.",
336
+ templateType: 3, // Confirmation type
337
+ });
338
+ ```
339
+
340
+ ### Group Messaging
341
+
342
+ ```typescript
343
+ // Send text message to group
344
+ await zalo.groupMessage.sendTextMessage(accessToken, groupId, {
345
+ type: "text",
346
+ text: "Hello everyone!",
347
+ });
348
+
349
+ // Send image to group
350
+ await zalo.groupMessage.sendImageMessage(accessToken, groupId, {
351
+ type: "image",
352
+ imageUrl: "https://example.com/image.jpg",
353
+ caption: "Check this out!",
354
+ });
355
+
356
+ // Get group information
357
+ const groupInfo = await zalo.groupMessage.getGroupInfo(accessToken, groupId);
358
+ const members = await zalo.groupMessage.getGroupMembers(accessToken, groupId);
359
+ ```
360
+
361
+ ### User Management
362
+
363
+ ```typescript
364
+ // Get user profile
365
+ const profile = await zalo.userManagement.getUserProfile(accessToken, userId);
366
+
367
+ // Tag management
368
+ await zalo.tag.createTag(accessToken, "VIP Customer");
369
+ await zalo.tag.tagUser(accessToken, userId, ["VIP Customer", "Premium"]);
370
+ const userTags = await zalo.tag.getUserTags(accessToken, userId);
371
+
372
+ // Get followers list
373
+ const followers = await zalo.userManagement.getFollowersList(accessToken);
374
+ ```
375
+
376
+ ### Content Management
377
+
378
+ ```typescript
379
+ // Upload image
380
+ const imageResult = await zalo.content.uploadImage(accessToken, imageBuffer);
381
+
382
+ // Create article
383
+ const article = await zalo.content.createArticle(accessToken, {
384
+ title: "Welcome to our service",
385
+ body: "Article content here...",
386
+ cover_photo_id: imageResult.data.attachment_id,
387
+ });
388
+
389
+ // Share article to user
390
+ await zalo.content.shareArticle(accessToken, userId, article.data.id);
391
+ ```
392
+
393
+ ### Video Upload
394
+
395
+ ```typescript
396
+ // Upload video
397
+ const uploadResult = await zalo.videoUpload.uploadVideo(
398
+ accessToken,
399
+ videoBuffer,
400
+ "video.mp4"
401
+ );
402
+
403
+ // Wait for processing completion
404
+ const finalResult = await zalo.videoUpload.waitForUploadCompletion(
405
+ accessToken,
406
+ uploadResult.data.token
407
+ );
408
+
409
+ if (finalResult.status === "ready") {
410
+ // Send video message
411
+ await zalo.videoUpload.sendVideoMessage(
412
+ accessToken,
413
+ userId,
414
+ finalResult.attachment_id,
415
+ "Check out this video!"
416
+ );
417
+ }
418
+ ```
419
+
420
+ ### Social API
421
+
422
+ ```typescript
423
+ // Get user social information
424
+ const userInfo = await zalo.social.getUserInfo(accessToken);
425
+
426
+ // Get friends list
427
+ const friends = await zalo.social.getFriendsList(accessToken);
428
+
429
+ // Post to timeline
430
+ await zalo.social.postToTimeline(accessToken, "Hello from Zalo SDK!");
431
+ ```
432
+
433
+ ## Changelog
434
+
435
+ ### v1.0.0
436
+
437
+ - Initial release
438
+ - Official Account API support
439
+ - ZNS (Zalo Notification Service) support
440
+ - Group Message Framework (GMF) support
441
+ - Social API support
442
+ - User Management features
443
+ - Content and Video Upload capabilities
444
+ - Tag Management system
445
+ - Comprehensive webhook handling
446
+ - Social API support
447
+ - Authentication flow
448
+ - TypeScript support
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Base HTTP client for Zalo API
3
+ */
4
+ import { AxiosInstance } from "axios";
5
+ import { ZaloSDKConfig, Logger, RequestConfig } from "../types/common";
6
+ /**
7
+ * Base client for making HTTP requests to Zalo API
8
+ */
9
+ export declare class BaseClient {
10
+ protected readonly axios: AxiosInstance;
11
+ protected readonly logger: Logger;
12
+ protected readonly config: Required<ZaloSDKConfig>;
13
+ constructor(config: ZaloSDKConfig);
14
+ /**
15
+ * Setup axios interceptors for logging and error handling
16
+ */
17
+ private setupInterceptors;
18
+ /**
19
+ * Sanitize headers for logging (remove sensitive information)
20
+ */
21
+ private sanitizeHeaders;
22
+ /**
23
+ * Handle axios errors and log them
24
+ */
25
+ private handleAxiosError;
26
+ /**
27
+ * Make a GET request
28
+ */
29
+ protected get<T = any>(url: string, accessToken?: string, params?: Record<string, any>): Promise<T>;
30
+ /**
31
+ * Make a POST request
32
+ */
33
+ protected post<T = any>(url: string, accessToken?: string, data?: any, params?: Record<string, any>): Promise<T>;
34
+ /**
35
+ * Make a PUT request
36
+ */
37
+ protected put<T = any>(url: string, accessToken?: string, data?: any, params?: Record<string, any>): Promise<T>;
38
+ /**
39
+ * Make a DELETE request
40
+ */
41
+ protected delete<T = any>(url: string, accessToken?: string, params?: Record<string, any>): Promise<T>;
42
+ /**
43
+ * Upload file using FormData
44
+ */
45
+ protected uploadFile<T = any>(url: string, accessToken: string, file: Buffer | NodeJS.ReadableStream, filename: string, additionalFields?: Record<string, any>): Promise<T>;
46
+ /**
47
+ * Make a generic HTTP request with retry logic
48
+ */
49
+ protected request<T = any>(config: RequestConfig): Promise<T>;
50
+ /**
51
+ * Validate Zalo API response for errors
52
+ */
53
+ private validateZaloResponse;
54
+ /**
55
+ * Determine if request should be retried
56
+ */
57
+ private shouldRetry;
58
+ /**
59
+ * Create SDK error from axios error
60
+ */
61
+ private createSDKError;
62
+ /**
63
+ * Delay execution for specified milliseconds
64
+ */
65
+ private delay;
66
+ }
67
+ //# sourceMappingURL=base-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-client.d.ts","sourceRoot":"","sources":["../../src/clients/base-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAc,EACZ,aAAa,EAId,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,aAAa,EAEb,MAAM,EAEN,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CA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