@zapyapi/sdk 1.0.0-beta.5 → 1.0.0-beta.6

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 CHANGED
@@ -202,12 +202,16 @@ await client.webhooks.deleteConfig();
202
202
 
203
203
  ## Error Handling
204
204
 
205
+ The SDK provides detailed error classes for different failure scenarios:
206
+
205
207
  ```typescript
206
208
  import {
207
209
  ZapyClient,
208
210
  ZapyApiError,
209
211
  AuthenticationError,
210
212
  RateLimitError,
213
+ NetworkError,
214
+ TimeoutError,
211
215
  ValidationError,
212
216
  } from '@zapyapi/sdk';
213
217
 
@@ -217,17 +221,46 @@ try {
217
221
  text: 'Hello!',
218
222
  });
219
223
  } catch (error) {
220
- if (error instanceof AuthenticationError) {
224
+ if (error instanceof TimeoutError) {
225
+ // Request timed out
226
+ console.error(`Request timed out after ${error.timeout}ms`);
227
+ console.error(`Request: ${error.method} ${error.url}`);
228
+ } else if (error instanceof NetworkError) {
229
+ // Network failure (no response received)
230
+ console.error(`Network error: ${error.message}`);
231
+ console.error(`Error code: ${error.code}`); // e.g., ECONNREFUSED
232
+ } else if (error instanceof AuthenticationError) {
221
233
  console.error('Invalid API key');
222
234
  } else if (error instanceof RateLimitError) {
223
235
  console.error(`Rate limited. Retry after: ${error.retryAfter}ms`);
236
+ console.error(`Retry at: ${error.getRetryAfterDate()}`);
224
237
  } else if (error instanceof ZapyApiError) {
225
238
  console.error(`API Error [${error.code}]: ${error.message}`);
239
+ console.error(`Status: ${error.statusCode}`);
226
240
  console.error(`Request ID: ${error.requestId}`);
241
+ console.error(`Request: ${error.method} ${error.url}`);
242
+
243
+ // For debugging/logging
244
+ console.error(error.toDetailedString());
245
+ // Or serialize to JSON
246
+ console.error(JSON.stringify(error.toJSON(), null, 2));
227
247
  }
228
248
  }
229
249
  ```
230
250
 
251
+ ### Error Classes
252
+
253
+ | Error Class | Description |
254
+ |-------------|-------------|
255
+ | `ZapyError` | Base error class for all SDK errors |
256
+ | `ZapyApiError` | API returned an error response (4xx, 5xx) |
257
+ | `AuthenticationError` | Invalid or missing API key (401) |
258
+ | `RateLimitError` | Rate limit exceeded (429) |
259
+ | `NetworkError` | Network failure, no response received |
260
+ | `TimeoutError` | Request timed out |
261
+ | `ValidationError` | Input validation failed |
262
+ | `InstanceNotFoundError` | Instance not found (404) |
263
+
231
264
  ## Utilities
232
265
 
233
266
  ```typescript
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.5';
6
+ const SDK_VERSION = '1.0.0-beta.6';
7
7
 
8
8
  /**
9
9
  * Custom error classes for @zapyapi/sdk
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
2
 
3
3
  /** SDK version - auto-generated from package.json */
4
- const SDK_VERSION = '1.0.0-beta.5';
4
+ const SDK_VERSION = '1.0.0-beta.6';
5
5
 
6
6
  /**
7
7
  * Custom error classes for @zapyapi/sdk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapyapi/sdk",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "Official TypeScript SDK for ZapyAPI - WhatsApp API",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
package/src/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** SDK version - auto-generated from package.json */
2
- export declare const SDK_VERSION = "1.0.0-beta.5";
2
+ export declare const SDK_VERSION = "1.0.0-beta.6";
3
3
  //# sourceMappingURL=version.d.ts.map