@tapsilat/tapsilat-js 1.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial SDK implementation
12
+ - Payment operations (create, get, list, cancel)
13
+ - Refund operations (create, get, list)
14
+ - Customer operations (CRUD)
15
+ - Webhook verification
16
+ - TypeScript support
17
+ - Comprehensive error handling
18
+ - Input validation and sanitization
19
+ - Retry mechanism with exponential backoff
20
+ - Zero external dependencies
21
+
22
+ ### Security
23
+ - Automatic metadata sanitization
24
+ - HMAC-SHA256 webhook verification
25
+ - Input validation for all requests
26
+
27
+ ## [1.0.0] - 2024-12-XX
28
+
29
+ ### Added
30
+ - Initial release of Tapsilat JS SDK
31
+ - Full TypeScript support
32
+ - Modern fetch-based HTTP client
33
+ - Comprehensive test suite
34
+ - Documentation and examples
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tapsilat
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,257 @@
1
+ # Tapsilat TypeScript SDK
2
+
3
+ <div align="center">
4
+
5
+ [![Tapsilat Logo](https://tapsilat.dev/assets/logo.png)](https://tapsilat.dev)
6
+
7
+ **Enterprise-grade TypeScript SDK for Tapsilat Payment Processing Platform**
8
+
9
+ [![npm version](https://img.shields.io/npm/v/tapsilat-js.svg?style=flat-square)](https://www.npmjs.com/package/tapsilat-js)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
11
+ [![MIT License](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](LICENSE)
12
+
13
+ </div>
14
+
15
+ ## 🏢 About Tapsilat
16
+
17
+ **Tapsilat** is Turkey's leading fintech platform providing comprehensive payment processing solutions for businesses of all sizes. Our cutting-edge technology enables secure, fast, and reliable payment transactions with support for multiple payment methods, currencies, and advanced fraud protection.
18
+
19
+ ---
20
+
21
+ ## 🚀 Installation
22
+
23
+ ```bash
24
+ npm install @tapsilat/tapsilat-js
25
+ ```
26
+
27
+ ---
28
+
29
+ ## ⚡ Quick Start
30
+
31
+ ### Initialize the SDK
32
+
33
+ ```typescript
34
+ import { TapsilatSDK } from "@tapsilat/tapsilat-js";
35
+
36
+ const tapsilat = new TapsilatSDK({
37
+ bearerToken: process.env.TAPSILAT_BEARER_TOKEN!,
38
+ baseURL: "https://acquiring.tapsilat.dev/api/v1",
39
+ });
40
+ ```
41
+
42
+ ### Create an Order
43
+
44
+ ```typescript
45
+ const order = await tapsilat.createOrder({
46
+ amount: 150.75,
47
+ currency: "TRY",
48
+ locale: "tr",
49
+ buyer: {
50
+ name: "John",
51
+ surname: "Doe",
52
+ email: "john.doe@example.com",
53
+ phone: "+905551234567",
54
+ },
55
+ description: "Premium subscription - Monthly plan",
56
+ });
57
+ ```
58
+
59
+ ### Check Order Status
60
+
61
+ ```typescript
62
+ const status = await tapsilat.getOrderStatus(order.reference_id);
63
+ console.log("Order status:", status.status);
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 📖 API Methods & Examples
69
+
70
+ ### Order Management
71
+
72
+ #### Create Order
73
+ ```typescript
74
+ const order = await tapsilat.createOrder({
75
+ amount: 299.99,
76
+ currency: 'TRY',
77
+ locale: 'tr',
78
+ buyer: {
79
+ name: 'Ahmet',
80
+ surname: 'Yılmaz',
81
+ email: 'ahmet@example.com',
82
+ phone: '+905551234567'
83
+ },
84
+ description: 'Product purchase',
85
+ callbackUrl: 'https://mystore.com/success',
86
+ metadata: {
87
+ productId: 'PROD_123',
88
+ campaignCode: 'DISCOUNT20'
89
+ }
90
+ });
91
+ ```
92
+
93
+ #### Get Order Details
94
+ ```typescript
95
+ const order = await tapsilat.getOrder('order-reference-id');
96
+ console.log('Order amount:', order.amount);
97
+ console.log('Order status:', order.status);
98
+ ```
99
+
100
+ #### Check Order Status
101
+ ```typescript
102
+ const status = await tapsilat.getOrderStatus('order-reference-id');
103
+ if (status.status === 'completed') {
104
+ console.log('Payment successful!');
105
+ }
106
+ ```
107
+
108
+ #### List Orders
109
+ ```typescript
110
+ const orders = await tapsilat.getOrders({ page: 1, per_page: 10 });
111
+ orders.rows.forEach(order => {
112
+ console.log(`Order ${order.reference_id}: ${order.amount} ${order.currency}`);
113
+ });
114
+ ```
115
+
116
+ #### Cancel Order
117
+ ```typescript
118
+ try {
119
+ await tapsilat.cancelOrder('order-reference-id');
120
+ console.log('Order cancelled successfully');
121
+ } catch (error) {
122
+ console.error('Cannot cancel order:', error.message);
123
+ }
124
+ ```
125
+
126
+ ### Payment Operations
127
+
128
+ #### Get Payment Details
129
+ ```typescript
130
+ const paymentDetails = await tapsilat.getOrderPaymentDetails('order-reference-id');
131
+ paymentDetails.forEach(detail => {
132
+ console.log(`Payment: ${detail.amount} ${detail.currency}`);
133
+ });
134
+ ```
135
+
136
+ #### Get Transaction History
137
+ ```typescript
138
+ const transactions = await tapsilat.getOrderTransactions('order-reference-id');
139
+ transactions.forEach(tx => {
140
+ console.log(`${tx.type}: ${tx.amount} on ${tx.created_at}`);
141
+ });
142
+ ```
143
+
144
+ #### Get Checkout URL
145
+ ```typescript
146
+ const checkoutUrl = await tapsilat.getCheckoutUrl('order-reference-id');
147
+ // Redirect customer to checkout
148
+ window.location.href = checkoutUrl;
149
+ ```
150
+
151
+ ### Refund Operations
152
+
153
+ #### Process Partial Refund
154
+ ```typescript
155
+ const refund = await tapsilat.refundOrder({
156
+ reference_id: 'order-reference-id',
157
+ amount: 50.00,
158
+ reason: 'Customer request',
159
+ metadata: {
160
+ refundType: 'partial',
161
+ ticketId: 'TICKET_789'
162
+ }
163
+ });
164
+ console.log('Refund ID:', refund.id);
165
+ ```
166
+
167
+ #### Process Full Refund
168
+ ```typescript
169
+ const fullRefund = await tapsilat.refundAllOrder('order-reference-id');
170
+ console.log('Full refund processed:', fullRefund.amount);
171
+ ```
172
+
173
+ ### Webhook Handling
174
+
175
+ #### Verify Webhook Signature
176
+ ```typescript
177
+ import express from 'express';
178
+
179
+ const app = express();
180
+ app.use(express.raw({ type: 'application/json' }));
181
+
182
+ app.post('/webhooks/tapsilat', async (req, res) => {
183
+ const payload = req.body.toString();
184
+ const signature = req.headers['x-tapsilat-signature'];
185
+
186
+ const isValid = await tapsilat.verifyWebhook(
187
+ payload,
188
+ signature,
189
+ process.env.WEBHOOK_SECRET
190
+ );
191
+
192
+ if (!isValid) {
193
+ return res.status(401).json({ error: 'Invalid signature' });
194
+ }
195
+
196
+ const event = JSON.parse(payload);
197
+
198
+ switch (event.type) {
199
+ case 'order.completed':
200
+ console.log('Order completed:', event.data.reference_id);
201
+ // Process successful payment
202
+ break;
203
+ case 'order.failed':
204
+ console.log('Order failed:', event.data.reference_id);
205
+ // Handle failed payment
206
+ break;
207
+ }
208
+
209
+ res.json({ received: true });
210
+ });
211
+ ```
212
+
213
+ ### Health Monitoring
214
+
215
+ #### API Health Check
216
+ ```typescript
217
+ const health = await tapsilat.healthCheck();
218
+ console.log('API Status:', health.status);
219
+ console.log('Timestamp:', health.timestamp);
220
+ ```
221
+
222
+ ---
223
+
224
+ ## 🔐 Authentication
225
+
226
+ Use Bearer Token authentication:
227
+
228
+ ```typescript
229
+ const tapsilat = new TapsilatSDK({
230
+ bearerToken: process.env.TAPSILAT_BEARER_TOKEN!,
231
+ });
232
+ ```
233
+
234
+ Get your API token from the [Tapsilat Dashboard](https://tapsilat.dev) → Settings → API Keys
235
+
236
+ ---
237
+
238
+ ## 📜 License
239
+
240
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
241
+
242
+ ---
243
+
244
+ ## 🔗 Resources
245
+
246
+ - 🌐 **Website**: [https://tapsilat.dev](https://tapsilat.dev)
247
+ - 📚 **API Documentation**: [https://docs.tapsilat.dev](https://docs.tapsilat.dev)
248
+ - 📞 **Support**: [support@tapsilat.dev](mailto:support@tapsilat.dev)
249
+ - 🐛 **Issues**: [GitHub Issues](https://github.com/tapsilat/tapsilat-js/issues)
250
+
251
+ ---
252
+
253
+ <div align="center">
254
+
255
+ [![Tapsilat](https://img.shields.io/badge/Tapsilat-Payment%20Solutions-blue?style=for-the-badge)](https://tapsilat.dev)
256
+
257
+ </div>
@@ -0,0 +1,293 @@
1
+ import { TapsilatConfig, PaginatedResponse, Order, OrderRefundRequest, OrderRefundResponse, OrderStatusResponse, OrderPaymentDetail, Address, Currency } from "./types";
2
+ /**
3
+ * Supported locales for the Tapsilat API.
4
+ */
5
+ export type Locale = "tr" | "en";
6
+ /**
7
+ * Represents the buyer information.
8
+ * Based on BuyerDTO from the Python SDK.
9
+ */
10
+ export interface Buyer {
11
+ name: string;
12
+ surname: string;
13
+ email: string;
14
+ phone?: string;
15
+ identityNumber?: string;
16
+ shippingAddress?: Address;
17
+ billingAddress?: Address;
18
+ }
19
+ /**
20
+ * Represents the data required to create a new order.
21
+ * Based on OrderCreateDTO from the Python SDK.
22
+ */
23
+ export interface OrderCreateRequest {
24
+ amount: number;
25
+ currency: Currency;
26
+ locale: Locale;
27
+ buyer: Buyer;
28
+ description?: string;
29
+ callbackUrl?: string;
30
+ conversationId?: string;
31
+ metadata?: Record<string, unknown>;
32
+ }
33
+ /**
34
+ * Represents the response received after creating an order.
35
+ */
36
+ export interface OrderCreateResponse {
37
+ referenceId: string;
38
+ conversationId: string;
39
+ checkoutUrl: string;
40
+ status: string;
41
+ qrCodeUrl?: string;
42
+ }
43
+ /**
44
+ * Main SDK class for Tapsilat payment operations
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const tapsilat = new TapsilatSDK({
49
+ * bearerToken: 'your-bearer-token',
50
+ * baseURL: 'https://api.tapsilat.com/v1'
51
+ * });
52
+ *
53
+ * const payment = await tapsilat.createPayment({
54
+ * amount: 100.50,
55
+ * currency: 'TRY',
56
+ * paymentMethod: 'credit_card'
57
+ * });
58
+ * ```
59
+ */
60
+ export declare class TapsilatSDK {
61
+ private readonly httpClient;
62
+ private readonly config;
63
+ /**
64
+ * Creates a new TapsilatSDK instance
65
+ *
66
+ * @param config - SDK configuration options
67
+ * @throws {TapsilatValidationError} When Bearer token is invalid
68
+ */
69
+ constructor(config: TapsilatConfig);
70
+ /**
71
+ * Creates a new order and returns a checkout URL.
72
+ *
73
+ * @param orderRequest - The order details including amount, currency, and buyer information
74
+ * @returns Promise resolving to the created order response including reference ID and checkout URL
75
+ * @throws {TapsilatValidationError} When order request data is invalid
76
+ * @throws {TapsilatNetworkError} When API request fails due to network issues
77
+ * @throws {TapsilatError} When API returns an error response
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * try {
82
+ * const orderResponse = await tapsilat.createOrder({
83
+ * amount: 100.50,
84
+ * currency: 'TRY',
85
+ * locale: 'en',
86
+ * buyer: {
87
+ * name: 'John',
88
+ * surname: 'Doe',
89
+ * email: 'john.doe@example.com'
90
+ * }
91
+ * });
92
+ * console.log(`Checkout URL: ${orderResponse.checkoutUrl}`);
93
+ * } catch (error) {
94
+ * console.error(`Order creation failed: ${error.message}`);
95
+ * }
96
+ * ```
97
+ */
98
+ createOrder(orderRequest: OrderCreateRequest): Promise<OrderCreateResponse>;
99
+ /**
100
+ * Validates an order request object
101
+ * @private
102
+ */
103
+ private validateOrderRequest;
104
+ /**
105
+ * Basic email validation
106
+ * @private
107
+ */
108
+ private isValidEmail;
109
+ /**
110
+ * Generic response handler - consistent way to handle API responses across SDK methods
111
+ * @private
112
+ *
113
+ * @param response - The API response to process
114
+ * @param errorContext - Descriptive context for error messages
115
+ * @returns The data from a successful response
116
+ * @throws {TapsilatError} On any response error
117
+ */
118
+ private handleResponse;
119
+ /**
120
+ * Generic error handler - consistent way to handle errors across SDK methods
121
+ * @private
122
+ *
123
+ * @param error - The caught error to process
124
+ * @param errorContext - Descriptive context for error messages
125
+ * @throws {TapsilatError} Always throws an appropriate error type
126
+ */
127
+ private handleError;
128
+ /**
129
+ * Gets an order by reference ID.
130
+ *
131
+ * @param referenceId - The unique reference ID of the order
132
+ * @returns Promise resolving to the complete order details
133
+ * @throws {TapsilatValidationError} When referenceId is invalid
134
+ * @throws {TapsilatNetworkError} When API request fails due to network issues
135
+ * @throws {TapsilatError} When API returns an error response
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * try {
140
+ * const order = await tapsilat.getOrder("ord_123456789");
141
+ * console.log(`Order amount: ${order.amount} ${order.currency}`);
142
+ * } catch (error) {
143
+ * console.error(`Failed to get order: ${error.message}`);
144
+ * }
145
+ * ```
146
+ */
147
+ getOrder(referenceId: string): Promise<Order>;
148
+ /**
149
+ * Lists orders with pagination support.
150
+ *
151
+ * @param params - Optional pagination parameters (page number and items per page)
152
+ * @returns Promise resolving to paginated list of orders
153
+ * @throws {TapsilatNetworkError} When API request fails due to network issues
154
+ * @throws {TapsilatError} When API returns an error response
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * try {
159
+ * // Get the second page with 20 items per page
160
+ * const orderList = await tapsilat.getOrders({ page: 2, per_page: 20 });
161
+ * console.log(`Total orders: ${orderList.total}`);
162
+ * orderList.rows.forEach(order => {
163
+ * console.log(`Order ${order.referenceId}: ${order.amount} ${order.currency}`);
164
+ * });
165
+ * } catch (error) {
166
+ * console.error(`Failed to list orders: ${error.message}`);
167
+ * }
168
+ * ```
169
+ */
170
+ getOrders(params?: {
171
+ page?: number;
172
+ per_page?: number;
173
+ }): Promise<PaginatedResponse<Order>>;
174
+ /**
175
+ * Cancels an order by reference_id.
176
+ */
177
+ cancelOrder(referenceId: string): Promise<Order>;
178
+ /**
179
+ * Gets the status of an order by reference ID.
180
+ *
181
+ * @param referenceId - The unique reference ID of the order
182
+ * @returns Promise resolving to the current order status, including status code and last update time
183
+ * @throws {TapsilatValidationError} When referenceId is invalid
184
+ * @throws {TapsilatNetworkError} When API request fails due to network issues
185
+ * @throws {TapsilatError} When API returns an error response
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * try {
190
+ * const orderStatus = await tapsilat.getOrderStatus("ord_123456789");
191
+ * console.log(`Order status: ${orderStatus.status}`);
192
+ * } catch (error) {
193
+ * if (error instanceof TapsilatValidationError) {
194
+ * console.error("Invalid reference ID format");
195
+ * } else if (error instanceof TapsilatError) {
196
+ * console.error(`API error: ${error.message}`);
197
+ * }
198
+ * }
199
+ * ```
200
+ */
201
+ getOrderStatus(referenceId: string): Promise<OrderStatusResponse>;
202
+ /**
203
+ * Partially refunds an order.
204
+ * Based on `refund_order` from the Python SDK.
205
+ *
206
+ * @param refundData - The refund details, including referenceId and amount.
207
+ * @returns Promise resolving to the refund transaction details.
208
+ */
209
+ refundOrder(refundData: OrderRefundRequest): Promise<OrderRefundResponse>;
210
+ /**
211
+ * Fully refunds an order by its reference ID.
212
+ * Based on `refund_all_order` from the Python SDK.
213
+ *
214
+ * @param referenceId - The unique identifier of the order to fully refund.
215
+ * @returns Promise resolving to the refund transaction details.
216
+ */
217
+ refundAllOrder(referenceId: string): Promise<OrderRefundResponse>;
218
+ /**
219
+ * Retrieves the payment details for an order.
220
+ * Based on `get_order_payment_details` from the Python SDK.
221
+ *
222
+ * @param referenceId - The unique identifier of the order.
223
+ * @param conversationId - Optional conversation ID for more specific querying.
224
+ * @returns Promise resolving to a list of payment details.
225
+ */
226
+ getOrderPaymentDetails(referenceId: string, conversationId?: string): Promise<OrderPaymentDetail[]>;
227
+ /**
228
+ * Gets an order by conversation_id.
229
+ * Based on `get_order_by_conversation_id` from the Python SDK.
230
+ */
231
+ getOrderByConversationId(conversationId: string): Promise<Order>;
232
+ /**
233
+ * Gets order transactions by reference_id.
234
+ * Based on `get_order_transactions` from the Python SDK.
235
+ */
236
+ getOrderTransactions(referenceId: string): Promise<any[]>;
237
+ /**
238
+ * Gets order submerchants with pagination.
239
+ * Based on `get_order_submerchants` from the Python SDK.
240
+ */
241
+ getOrderSubmerchants(params?: {
242
+ page?: number;
243
+ per_page?: number;
244
+ }): Promise<any>;
245
+ /**
246
+ * Gets checkout URL for an order.
247
+ * Based on `get_checkout_url` from the Python SDK.
248
+ */
249
+ getCheckoutUrl(referenceId: string): Promise<string>;
250
+ /**
251
+ * Verifies webhook signature for security
252
+ *
253
+ * @param payload - Raw webhook payload string
254
+ * @param signature - Webhook signature from headers
255
+ * @param secret - Your webhook secret key
256
+ * @returns Promise resolving to true if signature is valid
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * const isValid = await sdk.verifyWebhook(
261
+ * JSON.stringify(req.body),
262
+ * req.headers['x-tapsilat-signature'],
263
+ * 'your-webhook-secret'
264
+ * );
265
+ * ```
266
+ */
267
+ verifyWebhook(payload: string, signature: string, secret: string): Promise<boolean>;
268
+ /**
269
+ * Checks API service health and availability
270
+ *
271
+ * @returns Promise resolving to service status
272
+ */
273
+ healthCheck(): Promise<{
274
+ status: string;
275
+ timestamp: string;
276
+ }>;
277
+ /**
278
+ * Gets current SDK configuration (without sensitive data)
279
+ *
280
+ * @returns Copy of current configuration
281
+ */
282
+ getConfig(): Omit<TapsilatConfig, "bearerToken"> & {
283
+ hasBearerToken: boolean;
284
+ };
285
+ /**
286
+ * Updates SDK configuration
287
+ *
288
+ * @param newConfig - Partial configuration to update
289
+ * @throws {TapsilatValidationError} When Bearer token is invalid
290
+ */
291
+ updateConfig(newConfig: Partial<TapsilatConfig>): void;
292
+ }
293
+ //# sourceMappingURL=TapsilatSDK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TapsilatSDK.d.ts","sourceRoot":"","sources":["../src/TapsilatSDK.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,cAAc,EACd,iBAAiB,EACjB,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,QAAQ,EACT,MAAM,SAAS,CAAC;AAOjB;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAA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3
+ readonly code: string;
4
+ readonly details?: Record<string, any>;
5
+ constructor(message: string, code: string, details?: Record<string, any>);
6
+ static fromAPIError(apiError: APIError): TapsilatError;
7
+ }
8
+ export declare class TapsilatNetworkError extends TapsilatError {
9
+ readonly statusCode?: number;
10
+ constructor(message: string, code: string, statusCode?: number, details?: Record<string, any>);
11
+ }
12
+ export declare class TapsilatValidationError extends TapsilatError {
13
+ constructor(message: string, details?: Record<string, any>);
14
+ }
15
+ export declare class TapsilatAuthenticationError extends TapsilatError {
16
+ constructor(message?: string);
17
+ }
18
+ export declare class TapsilatRateLimitError extends TapsilatError {
19
+ readonly retryAfter?: number;
20
+ constructor(message?: string, retryAfter?: number);
21
+ }
22
+ //# sourceMappingURL=TapsilatError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TapsilatError.d.ts","sourceRoot":"","sources":["../../src/errors/TapsilatError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAElC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAYxE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa;CAGvD;AAED,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAK9F;AAED,qBAAa,uBAAwB,SAAQ,aAAa;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAI3D;AAED,qBAAa,2BAA4B,SAAQ,aAAa;gBAChD,OAAO,GAAE,MAAgC;CAItD;AAED,qBAAa,sBAAuB,SAAQ,aAAa;IACvD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,GAAE,MAA8B,EAAE,UAAU,CAAC,EAAE,MAAM;CAKzE"}