@scell/sdk 1.0.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.
@@ -0,0 +1,2292 @@
1
+ /**
2
+ * Retry utility with exponential backoff and jitter
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Retry configuration options
8
+ */
9
+ interface RetryOptions {
10
+ /** Maximum number of retry attempts (default: 3) */
11
+ maxRetries?: number | undefined;
12
+ /** Base delay in milliseconds (default: 1000) */
13
+ baseDelay?: number | undefined;
14
+ /** Maximum delay in milliseconds (default: 30000) */
15
+ maxDelay?: number | undefined;
16
+ /** Jitter factor (0-1, default: 0.1) */
17
+ jitterFactor?: number | undefined;
18
+ /** Custom function to determine if error is retryable */
19
+ isRetryable?: ((error: unknown) => boolean) | undefined;
20
+ }
21
+ /**
22
+ * Execute a function with retry logic
23
+ *
24
+ * @param fn - Async function to execute
25
+ * @param options - Retry options
26
+ * @returns Result of the function
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const result = await withRetry(
31
+ * () => client.invoices.create(data),
32
+ * { maxRetries: 5 }
33
+ * );
34
+ * ```
35
+ */
36
+ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
37
+ /**
38
+ * Create a retry wrapper with pre-configured options
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const retry = createRetryWrapper({ maxRetries: 5 });
43
+ * const result = await retry(() => client.invoices.create(data));
44
+ * ```
45
+ */
46
+ declare function createRetryWrapper(defaultOptions?: RetryOptions): <T>(fn: () => Promise<T>, options?: RetryOptions) => Promise<T>;
47
+
48
+ /**
49
+ * Scell HTTP Client
50
+ *
51
+ * @packageDocumentation
52
+ */
53
+
54
+ /**
55
+ * Authentication mode
56
+ */
57
+ type AuthMode = 'bearer' | 'api-key';
58
+ /**
59
+ * Client configuration options
60
+ */
61
+ interface ClientConfig {
62
+ /** Base URL for the API (default: https://api.scell.io/api/v1) */
63
+ baseUrl?: string | undefined;
64
+ /** Request timeout in milliseconds (default: 30000) */
65
+ timeout?: number | undefined;
66
+ /** Retry configuration */
67
+ retry?: RetryOptions | undefined;
68
+ /** Enable automatic retries (default: true) */
69
+ enableRetry?: boolean | undefined;
70
+ /** Custom fetch implementation */
71
+ fetch?: typeof fetch | undefined;
72
+ }
73
+ /**
74
+ * Request options for individual requests
75
+ */
76
+ interface RequestOptions {
77
+ /** Override timeout for this request */
78
+ timeout?: number | undefined;
79
+ /** Skip retry for this request */
80
+ skipRetry?: boolean | undefined;
81
+ /** Additional headers */
82
+ headers?: Record<string, string> | undefined;
83
+ /** Abort signal */
84
+ signal?: AbortSignal | undefined;
85
+ }
86
+ /**
87
+ * HTTP client for Scell API
88
+ */
89
+ declare class HttpClient {
90
+ private readonly baseUrl;
91
+ private readonly timeout;
92
+ private readonly retryOptions;
93
+ private readonly enableRetry;
94
+ private readonly fetchFn;
95
+ private readonly authMode;
96
+ private readonly authToken;
97
+ constructor(authMode: AuthMode, authToken: string, config?: ClientConfig);
98
+ /**
99
+ * Build URL with query parameters
100
+ */
101
+ private buildUrl;
102
+ /**
103
+ * Build headers for request
104
+ */
105
+ private buildHeaders;
106
+ /**
107
+ * Execute HTTP request
108
+ */
109
+ private executeRequest;
110
+ /**
111
+ * Execute request with optional retry
112
+ */
113
+ private request;
114
+ /**
115
+ * GET request
116
+ */
117
+ get<T>(path: string, query?: Record<string, string | number | boolean | undefined>, options?: RequestOptions): Promise<T>;
118
+ /**
119
+ * POST request
120
+ */
121
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
122
+ /**
123
+ * PUT request
124
+ */
125
+ put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
126
+ /**
127
+ * PATCH request
128
+ */
129
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
130
+ /**
131
+ * DELETE request
132
+ */
133
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
134
+ }
135
+
136
+ /**
137
+ * Common types used across the SDK
138
+ */
139
+ /**
140
+ * Environment mode for API operations
141
+ */
142
+ type Environment = 'sandbox' | 'production';
143
+ /**
144
+ * ISO 8601 date string (YYYY-MM-DD)
145
+ */
146
+ type DateString = string;
147
+ /**
148
+ * ISO 8601 datetime string
149
+ */
150
+ type DateTimeString = string;
151
+ /**
152
+ * UUID string
153
+ */
154
+ type UUID = string;
155
+ /**
156
+ * French SIRET number (14 digits)
157
+ */
158
+ type Siret = string;
159
+ /**
160
+ * French SIREN number (9 digits)
161
+ */
162
+ type Siren = string;
163
+ /**
164
+ * Currency code (ISO 4217)
165
+ */
166
+ type CurrencyCode = string;
167
+ /**
168
+ * Address structure
169
+ */
170
+ interface Address {
171
+ line1: string;
172
+ line2?: string | undefined;
173
+ postal_code: string;
174
+ city: string;
175
+ country?: string | undefined;
176
+ }
177
+ /**
178
+ * Pagination metadata
179
+ */
180
+ interface PaginationMeta {
181
+ current_page: number;
182
+ last_page: number;
183
+ per_page: number;
184
+ total: number;
185
+ }
186
+ /**
187
+ * Paginated response wrapper
188
+ */
189
+ interface PaginatedResponse<T> {
190
+ data: T[];
191
+ meta: PaginationMeta;
192
+ }
193
+ /**
194
+ * Single item response wrapper
195
+ */
196
+ interface SingleResponse<T> {
197
+ data: T;
198
+ }
199
+ /**
200
+ * Message response
201
+ */
202
+ interface MessageResponse {
203
+ message: string;
204
+ }
205
+ /**
206
+ * Message with data response
207
+ */
208
+ interface MessageWithDataResponse<T> {
209
+ message: string;
210
+ data: T;
211
+ }
212
+ /**
213
+ * Pagination options for list requests
214
+ */
215
+ interface PaginationOptions {
216
+ page?: number | undefined;
217
+ per_page?: number | undefined;
218
+ }
219
+ /**
220
+ * Date range filter options
221
+ */
222
+ interface DateRangeOptions {
223
+ from?: DateString | undefined;
224
+ to?: DateString | undefined;
225
+ }
226
+ /**
227
+ * API error response structure
228
+ */
229
+ interface ApiErrorResponse {
230
+ message: string;
231
+ errors?: Record<string, string[]> | undefined;
232
+ code?: string | undefined;
233
+ }
234
+
235
+ /**
236
+ * API Key entity
237
+ */
238
+ interface ApiKey {
239
+ id: UUID;
240
+ name: string;
241
+ company_id: UUID;
242
+ key_prefix: string;
243
+ environment: Environment;
244
+ permissions: string[];
245
+ rate_limit: number;
246
+ last_used_at: DateTimeString | null;
247
+ expires_at: DateTimeString | null;
248
+ created_at: DateTimeString;
249
+ }
250
+ /**
251
+ * API Key with full key (returned on creation only)
252
+ */
253
+ interface ApiKeyWithSecret extends ApiKey {
254
+ key: string;
255
+ }
256
+ /**
257
+ * API Key creation input
258
+ */
259
+ interface CreateApiKeyInput {
260
+ name: string;
261
+ company_id: UUID;
262
+ environment: Environment;
263
+ permissions?: string[] | undefined;
264
+ expires_at?: DateTimeString | undefined;
265
+ }
266
+
267
+ /**
268
+ * API Keys Resource
269
+ *
270
+ * @packageDocumentation
271
+ */
272
+
273
+ /**
274
+ * API Keys resource
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * // Create an API key for a company
279
+ * const apiKey = await client.apiKeys.create({
280
+ * name: 'Production Key',
281
+ * company_id: 'company-uuid',
282
+ * environment: 'production'
283
+ * });
284
+ *
285
+ * // Store the key securely!
286
+ * console.log('API Key:', apiKey.key);
287
+ * ```
288
+ */
289
+ declare class ApiKeysResource {
290
+ private readonly http;
291
+ constructor(http: HttpClient);
292
+ /**
293
+ * List all API keys
294
+ *
295
+ * @param requestOptions - Request options
296
+ * @returns List of API keys (without secrets)
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const { data: keys } = await client.apiKeys.list();
301
+ * keys.forEach(key => {
302
+ * console.log(`${key.name}: ${key.key_prefix}...`);
303
+ * });
304
+ * ```
305
+ */
306
+ list(requestOptions?: RequestOptions): Promise<{
307
+ data: ApiKey[];
308
+ }>;
309
+ /**
310
+ * Get a specific API key
311
+ *
312
+ * @param id - API Key UUID
313
+ * @param requestOptions - Request options
314
+ * @returns API key details (without secret)
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const { data: key } = await client.apiKeys.get('key-uuid');
319
+ * console.log(`Last used: ${key.last_used_at}`);
320
+ * ```
321
+ */
322
+ get(id: string, requestOptions?: RequestOptions): Promise<SingleResponse<ApiKey>>;
323
+ /**
324
+ * Create a new API key
325
+ *
326
+ * Important: The full key is only returned once during creation.
327
+ * Store it securely - you won't be able to retrieve it again.
328
+ *
329
+ * @param input - API key configuration
330
+ * @param requestOptions - Request options
331
+ * @returns Created API key with full key value
332
+ *
333
+ * @example
334
+ * ```typescript
335
+ * const { data: apiKey } = await client.apiKeys.create({
336
+ * name: 'Production Integration',
337
+ * company_id: 'company-uuid',
338
+ * environment: 'production',
339
+ * permissions: ['invoices:write', 'signatures:write']
340
+ * });
341
+ *
342
+ * // IMPORTANT: Store this key securely!
343
+ * // You won't be able to see it again.
344
+ * console.log('Save this key:', apiKey.key);
345
+ * ```
346
+ */
347
+ create(input: CreateApiKeyInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<ApiKeyWithSecret>>;
348
+ /**
349
+ * Delete an API key
350
+ *
351
+ * Warning: This will immediately revoke the key and all
352
+ * requests using it will fail.
353
+ *
354
+ * @param id - API Key UUID
355
+ * @param requestOptions - Request options
356
+ * @returns Deletion confirmation
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * await client.apiKeys.delete('key-uuid');
361
+ * console.log('API key revoked');
362
+ * ```
363
+ */
364
+ delete(id: string, requestOptions?: RequestOptions): Promise<MessageResponse>;
365
+ }
366
+
367
+ /**
368
+ * User entity
369
+ */
370
+ interface User {
371
+ id: UUID;
372
+ name: string;
373
+ email: string;
374
+ email_verified_at: DateTimeString | null;
375
+ is_admin: boolean;
376
+ created_at: DateTimeString;
377
+ updated_at: DateTimeString;
378
+ }
379
+ /**
380
+ * Login credentials
381
+ */
382
+ interface LoginCredentials {
383
+ email: string;
384
+ password: string;
385
+ }
386
+ /**
387
+ * Registration input
388
+ */
389
+ interface RegisterInput {
390
+ name: string;
391
+ email: string;
392
+ password: string;
393
+ password_confirmation: string;
394
+ }
395
+ /**
396
+ * Auth response with token
397
+ */
398
+ interface AuthResponse {
399
+ message: string;
400
+ user: User;
401
+ token: string;
402
+ }
403
+ /**
404
+ * Password reset request input
405
+ */
406
+ interface ForgotPasswordInput {
407
+ email: string;
408
+ }
409
+ /**
410
+ * Password reset input
411
+ */
412
+ interface ResetPasswordInput {
413
+ email: string;
414
+ token: string;
415
+ password: string;
416
+ password_confirmation: string;
417
+ }
418
+
419
+ /**
420
+ * Auth Resource
421
+ *
422
+ * @packageDocumentation
423
+ */
424
+
425
+ /**
426
+ * Auth API resource
427
+ *
428
+ * Note: Most auth endpoints are only used during initial setup.
429
+ * After login, use the returned token to create a ScellClient.
430
+ *
431
+ * @example
432
+ * ```typescript
433
+ * // Login and get token
434
+ * const auth = await ScellAuth.login({
435
+ * email: 'user@example.com',
436
+ * password: 'password'
437
+ * });
438
+ *
439
+ * // Create client with token
440
+ * const client = new ScellClient(auth.token);
441
+ *
442
+ * // Get current user
443
+ * const user = await client.auth.me();
444
+ * ```
445
+ */
446
+ declare class AuthResource {
447
+ private readonly http;
448
+ constructor(http: HttpClient);
449
+ /**
450
+ * Get current authenticated user
451
+ *
452
+ * @param requestOptions - Request options
453
+ * @returns Current user details
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * const { data: user } = await client.auth.me();
458
+ * console.log(`Logged in as: ${user.name} (${user.email})`);
459
+ * ```
460
+ */
461
+ me(requestOptions?: RequestOptions): Promise<SingleResponse<User>>;
462
+ /**
463
+ * Logout (revoke current token)
464
+ *
465
+ * @param requestOptions - Request options
466
+ * @returns Logout confirmation
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * await client.auth.logout();
471
+ * // Token is now invalid
472
+ * ```
473
+ */
474
+ logout(requestOptions?: RequestOptions): Promise<MessageResponse>;
475
+ }
476
+ /**
477
+ * Static auth methods (don't require authentication)
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * import { ScellAuth } from '@scell/sdk';
482
+ *
483
+ * // Register new user
484
+ * const auth = await ScellAuth.register({
485
+ * name: 'John Doe',
486
+ * email: 'john@example.com',
487
+ * password: 'securepassword123',
488
+ * password_confirmation: 'securepassword123'
489
+ * });
490
+ *
491
+ * // Login existing user
492
+ * const auth = await ScellAuth.login({
493
+ * email: 'john@example.com',
494
+ * password: 'securepassword123'
495
+ * });
496
+ *
497
+ * // Use the token
498
+ * const client = new ScellClient(auth.token);
499
+ * ```
500
+ */
501
+ declare const ScellAuth: {
502
+ /**
503
+ * Default base URL for auth requests
504
+ */
505
+ baseUrl: string;
506
+ /**
507
+ * Register a new user
508
+ *
509
+ * @param input - Registration data
510
+ * @param baseUrl - Optional base URL override
511
+ * @returns Auth response with token
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * const auth = await ScellAuth.register({
516
+ * name: 'Jane Doe',
517
+ * email: 'jane@example.com',
518
+ * password: 'MySecurePassword123!',
519
+ * password_confirmation: 'MySecurePassword123!'
520
+ * });
521
+ *
522
+ * console.log('Welcome,', auth.user.name);
523
+ * const client = new ScellClient(auth.token);
524
+ * ```
525
+ */
526
+ register(input: RegisterInput, baseUrl?: string): Promise<AuthResponse>;
527
+ /**
528
+ * Login an existing user
529
+ *
530
+ * @param credentials - Login credentials
531
+ * @param baseUrl - Optional base URL override
532
+ * @returns Auth response with token
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * const auth = await ScellAuth.login({
537
+ * email: 'user@example.com',
538
+ * password: 'password'
539
+ * });
540
+ *
541
+ * // Store the token securely
542
+ * localStorage.setItem('scell_token', auth.token);
543
+ *
544
+ * // Create client
545
+ * const client = new ScellClient(auth.token);
546
+ * ```
547
+ */
548
+ login(credentials: LoginCredentials, baseUrl?: string): Promise<AuthResponse>;
549
+ /**
550
+ * Request password reset email
551
+ *
552
+ * @param input - Email address
553
+ * @param baseUrl - Optional base URL override
554
+ * @returns Confirmation message
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * await ScellAuth.forgotPassword({
559
+ * email: 'user@example.com'
560
+ * });
561
+ * console.log('Check your email for reset link');
562
+ * ```
563
+ */
564
+ forgotPassword(input: ForgotPasswordInput, baseUrl?: string): Promise<MessageResponse>;
565
+ /**
566
+ * Reset password with token from email
567
+ *
568
+ * @param input - Reset password data
569
+ * @param baseUrl - Optional base URL override
570
+ * @returns Confirmation message
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * await ScellAuth.resetPassword({
575
+ * email: 'user@example.com',
576
+ * token: 'reset-token-from-email',
577
+ * password: 'NewSecurePassword123!',
578
+ * password_confirmation: 'NewSecurePassword123!'
579
+ * });
580
+ * ```
581
+ */
582
+ resetPassword(input: ResetPasswordInput, baseUrl?: string): Promise<MessageResponse>;
583
+ };
584
+
585
+ /**
586
+ * Transaction type
587
+ */
588
+ type TransactionType = 'credit' | 'debit';
589
+ /**
590
+ * Transaction service
591
+ */
592
+ type TransactionService = 'invoice' | 'signature' | 'manual' | 'admin';
593
+ /**
594
+ * Balance entity
595
+ */
596
+ interface Balance {
597
+ amount: number;
598
+ currency: CurrencyCode;
599
+ auto_reload_enabled: boolean;
600
+ auto_reload_threshold: number | null;
601
+ auto_reload_amount: number | null;
602
+ low_balance_alert_threshold: number;
603
+ critical_balance_alert_threshold: number;
604
+ }
605
+ /**
606
+ * Transaction entity
607
+ */
608
+ interface Transaction {
609
+ id: UUID;
610
+ type: TransactionType;
611
+ service: TransactionService;
612
+ amount: number;
613
+ balance_before: number;
614
+ balance_after: number;
615
+ description: string;
616
+ reference_type: string | null;
617
+ reference_id: UUID | null;
618
+ created_at: DateTimeString;
619
+ }
620
+ /**
621
+ * Balance reload input
622
+ */
623
+ interface ReloadBalanceInput {
624
+ /** Amount to reload (10-10000 EUR) */
625
+ amount: number;
626
+ }
627
+ /**
628
+ * Balance reload response
629
+ */
630
+ interface ReloadBalanceResponse {
631
+ message: string;
632
+ transaction: {
633
+ id: UUID;
634
+ amount: number;
635
+ balance_after: number;
636
+ };
637
+ }
638
+ /**
639
+ * Balance settings update input
640
+ */
641
+ interface UpdateBalanceSettingsInput {
642
+ auto_reload_enabled?: boolean | undefined;
643
+ auto_reload_threshold?: number | undefined;
644
+ auto_reload_amount?: number | undefined;
645
+ low_balance_alert_threshold?: number | undefined;
646
+ critical_balance_alert_threshold?: number | undefined;
647
+ }
648
+ /**
649
+ * Transaction list filter options
650
+ */
651
+ interface TransactionListOptions extends PaginationOptions, DateRangeOptions {
652
+ type?: TransactionType | undefined;
653
+ service?: TransactionService | undefined;
654
+ }
655
+
656
+ /**
657
+ * Balance Resource
658
+ *
659
+ * @packageDocumentation
660
+ */
661
+
662
+ /**
663
+ * Balance API resource
664
+ *
665
+ * @example
666
+ * ```typescript
667
+ * // Check balance
668
+ * const balance = await client.balance.get();
669
+ * console.log(`Current balance: ${balance.amount} ${balance.currency}`);
670
+ *
671
+ * // Reload balance
672
+ * await client.balance.reload({ amount: 100 });
673
+ *
674
+ * // View transactions
675
+ * const transactions = await client.balance.transactions({
676
+ * type: 'debit',
677
+ * service: 'invoice'
678
+ * });
679
+ * ```
680
+ */
681
+ declare class BalanceResource {
682
+ private readonly http;
683
+ constructor(http: HttpClient);
684
+ /**
685
+ * Get current balance and settings
686
+ *
687
+ * @param requestOptions - Request options
688
+ * @returns Current balance details
689
+ *
690
+ * @example
691
+ * ```typescript
692
+ * const { data: balance } = await client.balance.get();
693
+ * console.log(`Balance: ${balance.amount} ${balance.currency}`);
694
+ *
695
+ * if (balance.amount < balance.low_balance_alert_threshold) {
696
+ * console.log('Warning: Low balance!');
697
+ * }
698
+ * ```
699
+ */
700
+ get(requestOptions?: RequestOptions): Promise<SingleResponse<Balance>>;
701
+ /**
702
+ * Reload balance
703
+ *
704
+ * Note: This is a simulation endpoint. In production, use Stripe integration.
705
+ *
706
+ * @param input - Reload amount (10-10000 EUR)
707
+ * @param requestOptions - Request options
708
+ * @returns Reload transaction details
709
+ *
710
+ * @example
711
+ * ```typescript
712
+ * const { transaction } = await client.balance.reload({ amount: 100 });
713
+ * console.log(`New balance: ${transaction.balance_after}`);
714
+ * ```
715
+ */
716
+ reload(input: ReloadBalanceInput, requestOptions?: RequestOptions): Promise<ReloadBalanceResponse>;
717
+ /**
718
+ * Update balance settings
719
+ *
720
+ * Configure auto-reload and alert thresholds.
721
+ *
722
+ * @param input - Settings to update
723
+ * @param requestOptions - Request options
724
+ * @returns Updated settings
725
+ *
726
+ * @example
727
+ * ```typescript
728
+ * await client.balance.updateSettings({
729
+ * auto_reload_enabled: true,
730
+ * auto_reload_threshold: 50,
731
+ * auto_reload_amount: 200,
732
+ * low_balance_alert_threshold: 100,
733
+ * critical_balance_alert_threshold: 25
734
+ * });
735
+ * ```
736
+ */
737
+ updateSettings(input: UpdateBalanceSettingsInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Partial<Balance>>>;
738
+ /**
739
+ * List balance transactions
740
+ *
741
+ * @param options - Filter and pagination options
742
+ * @param requestOptions - Request options
743
+ * @returns Paginated list of transactions
744
+ *
745
+ * @example
746
+ * ```typescript
747
+ * // List all invoice debits
748
+ * const { data, meta } = await client.balance.transactions({
749
+ * type: 'debit',
750
+ * service: 'invoice',
751
+ * from: '2024-01-01',
752
+ * to: '2024-01-31'
753
+ * });
754
+ *
755
+ * data.forEach(tx => {
756
+ * console.log(`${tx.description}: -${tx.amount} EUR`);
757
+ * });
758
+ * ```
759
+ */
760
+ transactions(options?: TransactionListOptions, requestOptions?: RequestOptions): Promise<PaginatedResponse<Transaction>>;
761
+ }
762
+
763
+ /**
764
+ * Company KYC status
765
+ */
766
+ type CompanyStatus = 'pending_kyc' | 'active' | 'suspended';
767
+ /**
768
+ * Company entity
769
+ */
770
+ interface Company {
771
+ id: UUID;
772
+ name: string;
773
+ siret: Siret;
774
+ siren: Siren | null;
775
+ vat_number: string | null;
776
+ legal_form: string | null;
777
+ address_line1: string;
778
+ address_line2: string | null;
779
+ postal_code: string;
780
+ city: string;
781
+ country: string;
782
+ phone: string | null;
783
+ email: string | null;
784
+ website: string | null;
785
+ logo_url: string | null;
786
+ status: CompanyStatus;
787
+ kyc_completed_at: DateTimeString | null;
788
+ created_at: DateTimeString;
789
+ updated_at: DateTimeString;
790
+ }
791
+ /**
792
+ * Company creation input
793
+ */
794
+ interface CreateCompanyInput {
795
+ name: string;
796
+ siret: Siret;
797
+ vat_number?: string | undefined;
798
+ legal_form?: string | undefined;
799
+ address_line1: string;
800
+ address_line2?: string | undefined;
801
+ postal_code: string;
802
+ city: string;
803
+ country?: string | undefined;
804
+ phone?: string | undefined;
805
+ email?: string | undefined;
806
+ website?: string | undefined;
807
+ }
808
+ /**
809
+ * Company update input
810
+ */
811
+ interface UpdateCompanyInput {
812
+ name?: string | undefined;
813
+ siret?: Siret | undefined;
814
+ vat_number?: string | undefined;
815
+ legal_form?: string | undefined;
816
+ address_line1?: string | undefined;
817
+ address_line2?: string | undefined;
818
+ postal_code?: string | undefined;
819
+ city?: string | undefined;
820
+ country?: string | undefined;
821
+ phone?: string | undefined;
822
+ email?: string | undefined;
823
+ website?: string | undefined;
824
+ }
825
+ /**
826
+ * KYC initiation response
827
+ */
828
+ interface KycInitiateResponse {
829
+ message: string;
830
+ kyc_reference: string;
831
+ redirect_url: string;
832
+ }
833
+ /**
834
+ * KYC status response
835
+ */
836
+ interface KycStatusResponse {
837
+ status: CompanyStatus;
838
+ kyc_reference: string | null;
839
+ kyc_completed_at: DateTimeString | null;
840
+ message: string;
841
+ }
842
+
843
+ /**
844
+ * Companies Resource
845
+ *
846
+ * @packageDocumentation
847
+ */
848
+
849
+ /**
850
+ * Companies API resource
851
+ *
852
+ * @example
853
+ * ```typescript
854
+ * // Create a company
855
+ * const company = await client.companies.create({
856
+ * name: 'My Company',
857
+ * siret: '12345678901234',
858
+ * address_line1: '1 Rue de la Paix',
859
+ * postal_code: '75001',
860
+ * city: 'Paris'
861
+ * });
862
+ *
863
+ * // Initiate KYC
864
+ * const kyc = await client.companies.initiateKyc(company.id);
865
+ * console.log('KYC URL:', kyc.redirect_url);
866
+ * ```
867
+ */
868
+ declare class CompaniesResource {
869
+ private readonly http;
870
+ constructor(http: HttpClient);
871
+ /**
872
+ * List all companies for the authenticated user
873
+ *
874
+ * @param requestOptions - Request options
875
+ * @returns List of companies
876
+ *
877
+ * @example
878
+ * ```typescript
879
+ * const { data: companies } = await client.companies.list();
880
+ * companies.forEach(c => console.log(c.name, c.status));
881
+ * ```
882
+ */
883
+ list(requestOptions?: RequestOptions): Promise<{
884
+ data: Company[];
885
+ }>;
886
+ /**
887
+ * Get a specific company by ID
888
+ *
889
+ * @param id - Company UUID
890
+ * @param requestOptions - Request options
891
+ * @returns Company details
892
+ *
893
+ * @example
894
+ * ```typescript
895
+ * const { data: company } = await client.companies.get('uuid');
896
+ * console.log(company.name, company.siret);
897
+ * ```
898
+ */
899
+ get(id: string, requestOptions?: RequestOptions): Promise<SingleResponse<Company>>;
900
+ /**
901
+ * Create a new company
902
+ *
903
+ * @param input - Company creation data
904
+ * @param requestOptions - Request options
905
+ * @returns Created company
906
+ *
907
+ * @example
908
+ * ```typescript
909
+ * const { data: company } = await client.companies.create({
910
+ * name: 'Acme Corp',
911
+ * siret: '12345678901234',
912
+ * vat_number: 'FR12345678901',
913
+ * legal_form: 'SAS',
914
+ * address_line1: '123 Business Street',
915
+ * postal_code: '75001',
916
+ * city: 'Paris',
917
+ * country: 'FR',
918
+ * email: 'contact@acme.com',
919
+ * phone: '+33 1 23 45 67 89'
920
+ * });
921
+ * ```
922
+ */
923
+ create(input: CreateCompanyInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Company>>;
924
+ /**
925
+ * Update a company
926
+ *
927
+ * @param id - Company UUID
928
+ * @param input - Fields to update
929
+ * @param requestOptions - Request options
930
+ * @returns Updated company
931
+ *
932
+ * @example
933
+ * ```typescript
934
+ * const { data: company } = await client.companies.update('uuid', {
935
+ * email: 'new-email@acme.com',
936
+ * phone: '+33 1 98 76 54 32'
937
+ * });
938
+ * ```
939
+ */
940
+ update(id: string, input: UpdateCompanyInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Company>>;
941
+ /**
942
+ * Delete a company
943
+ *
944
+ * @param id - Company UUID
945
+ * @param requestOptions - Request options
946
+ * @returns Deletion confirmation
947
+ *
948
+ * @example
949
+ * ```typescript
950
+ * await client.companies.delete('company-uuid');
951
+ * ```
952
+ */
953
+ delete(id: string, requestOptions?: RequestOptions): Promise<MessageResponse>;
954
+ /**
955
+ * Initiate KYC verification for a company
956
+ *
957
+ * @param id - Company UUID
958
+ * @param requestOptions - Request options
959
+ * @returns KYC reference and redirect URL
960
+ *
961
+ * @example
962
+ * ```typescript
963
+ * const { kyc_reference, redirect_url } = await client.companies.initiateKyc(
964
+ * 'company-uuid'
965
+ * );
966
+ * // Redirect user to redirect_url for KYC verification
967
+ * ```
968
+ */
969
+ initiateKyc(id: string, requestOptions?: RequestOptions): Promise<KycInitiateResponse>;
970
+ /**
971
+ * Get KYC verification status
972
+ *
973
+ * @param id - Company UUID
974
+ * @param requestOptions - Request options
975
+ * @returns Current KYC status
976
+ *
977
+ * @example
978
+ * ```typescript
979
+ * const status = await client.companies.kycStatus('company-uuid');
980
+ * if (status.status === 'active') {
981
+ * console.log('KYC completed at:', status.kyc_completed_at);
982
+ * }
983
+ * ```
984
+ */
985
+ kycStatus(id: string, requestOptions?: RequestOptions): Promise<KycStatusResponse>;
986
+ }
987
+
988
+ /**
989
+ * Invoice direction
990
+ */
991
+ type InvoiceDirection = 'outgoing' | 'incoming';
992
+ /**
993
+ * Invoice output format
994
+ */
995
+ type InvoiceFormat = 'facturx' | 'ubl' | 'cii';
996
+ /**
997
+ * Invoice status
998
+ */
999
+ type InvoiceStatus = 'draft' | 'pending' | 'validated' | 'converted' | 'transmitted' | 'accepted' | 'rejected' | 'error';
1000
+ /**
1001
+ * Invoice download file type
1002
+ */
1003
+ type InvoiceDownloadType = 'original' | 'converted' | 'pdf';
1004
+ /**
1005
+ * Invoice line item
1006
+ */
1007
+ interface InvoiceLine {
1008
+ line_number: number;
1009
+ description: string;
1010
+ quantity: number;
1011
+ unit_price: number;
1012
+ tax_rate: number;
1013
+ total_ht: number;
1014
+ total_tax: number;
1015
+ total_ttc: number;
1016
+ }
1017
+ /**
1018
+ * Invoice party (seller or buyer)
1019
+ */
1020
+ interface InvoiceParty {
1021
+ siret: Siret;
1022
+ name: string;
1023
+ address: Address;
1024
+ }
1025
+ /**
1026
+ * Invoice entity
1027
+ */
1028
+ interface Invoice {
1029
+ id: UUID;
1030
+ external_id: string | null;
1031
+ invoice_number: string;
1032
+ direction: InvoiceDirection;
1033
+ output_format: InvoiceFormat;
1034
+ issue_date: DateString;
1035
+ due_date: DateString | null;
1036
+ currency: CurrencyCode;
1037
+ total_ht: number;
1038
+ total_tax: number;
1039
+ total_ttc: number;
1040
+ seller: InvoiceParty;
1041
+ buyer: InvoiceParty;
1042
+ lines: InvoiceLine[] | null;
1043
+ status: InvoiceStatus;
1044
+ status_message: string | null;
1045
+ environment: Environment;
1046
+ archive_enabled: boolean;
1047
+ amount_charged: number | null;
1048
+ created_at: DateTimeString;
1049
+ validated_at: DateTimeString | null;
1050
+ transmitted_at: DateTimeString | null;
1051
+ completed_at: DateTimeString | null;
1052
+ }
1053
+ /**
1054
+ * Invoice line input for creation
1055
+ */
1056
+ interface InvoiceLineInput {
1057
+ description: string;
1058
+ quantity: number;
1059
+ unit_price: number;
1060
+ tax_rate: number;
1061
+ total_ht: number;
1062
+ total_tax: number;
1063
+ total_ttc: number;
1064
+ }
1065
+ /**
1066
+ * Invoice creation input
1067
+ */
1068
+ interface CreateInvoiceInput {
1069
+ /** Your external reference ID */
1070
+ external_id?: string | undefined;
1071
+ /** Invoice number (required) */
1072
+ invoice_number: string;
1073
+ /** Direction: outgoing (sale) or incoming (purchase) */
1074
+ direction: InvoiceDirection;
1075
+ /** Output format for electronic invoice */
1076
+ output_format: InvoiceFormat;
1077
+ /** Issue date (YYYY-MM-DD) */
1078
+ issue_date: DateString;
1079
+ /** Due date (YYYY-MM-DD) */
1080
+ due_date?: DateString | undefined;
1081
+ /** Currency code (default: EUR) */
1082
+ currency?: CurrencyCode | undefined;
1083
+ /** Total excluding tax */
1084
+ total_ht: number;
1085
+ /** Total tax amount */
1086
+ total_tax: number;
1087
+ /** Total including tax */
1088
+ total_ttc: number;
1089
+ /** Seller SIRET (14 digits) */
1090
+ seller_siret: Siret;
1091
+ /** Seller company name */
1092
+ seller_name: string;
1093
+ /** Seller address */
1094
+ seller_address: Address;
1095
+ /** Buyer SIRET (14 digits) */
1096
+ buyer_siret: Siret;
1097
+ /** Buyer company name */
1098
+ buyer_name: string;
1099
+ /** Buyer address */
1100
+ buyer_address: Address;
1101
+ /** Invoice line items */
1102
+ lines: InvoiceLineInput[];
1103
+ /** Enable 10-year archiving */
1104
+ archive_enabled?: boolean | undefined;
1105
+ }
1106
+ /**
1107
+ * Invoice list filter options
1108
+ */
1109
+ interface InvoiceListOptions {
1110
+ company_id?: UUID | undefined;
1111
+ direction?: InvoiceDirection | undefined;
1112
+ status?: InvoiceStatus | undefined;
1113
+ environment?: Environment | undefined;
1114
+ from?: DateString | undefined;
1115
+ to?: DateString | undefined;
1116
+ per_page?: number | undefined;
1117
+ }
1118
+ /**
1119
+ * Invoice conversion input
1120
+ */
1121
+ interface ConvertInvoiceInput {
1122
+ invoice_id: UUID;
1123
+ target_format: InvoiceFormat;
1124
+ }
1125
+ /**
1126
+ * Invoice download response
1127
+ */
1128
+ interface InvoiceDownloadResponse {
1129
+ url: string;
1130
+ expires_at: DateTimeString;
1131
+ }
1132
+ /**
1133
+ * Audit trail entry
1134
+ */
1135
+ interface AuditTrailEntry {
1136
+ action: string;
1137
+ details: string;
1138
+ actor_ip: string | null;
1139
+ created_at: DateTimeString;
1140
+ }
1141
+ /**
1142
+ * Audit trail response
1143
+ */
1144
+ interface AuditTrailResponse {
1145
+ data: AuditTrailEntry[];
1146
+ integrity_valid: boolean;
1147
+ }
1148
+
1149
+ /**
1150
+ * Invoices Resource
1151
+ *
1152
+ * @packageDocumentation
1153
+ */
1154
+
1155
+ /**
1156
+ * Invoices API resource
1157
+ *
1158
+ * @example
1159
+ * ```typescript
1160
+ * // List invoices
1161
+ * const invoices = await client.invoices.list({
1162
+ * direction: 'outgoing',
1163
+ * status: 'validated'
1164
+ * });
1165
+ *
1166
+ * // Create an invoice
1167
+ * const invoice = await client.invoices.create({
1168
+ * invoice_number: 'FACT-2024-001',
1169
+ * direction: 'outgoing',
1170
+ * output_format: 'facturx',
1171
+ * // ...
1172
+ * });
1173
+ *
1174
+ * // Download invoice
1175
+ * const download = await client.invoices.download(invoice.id, 'pdf');
1176
+ * console.log('Download URL:', download.url);
1177
+ * ```
1178
+ */
1179
+ declare class InvoicesResource {
1180
+ private readonly http;
1181
+ constructor(http: HttpClient);
1182
+ /**
1183
+ * List invoices with optional filtering
1184
+ *
1185
+ * @param options - Filter and pagination options
1186
+ * @param requestOptions - Request options
1187
+ * @returns Paginated list of invoices
1188
+ *
1189
+ * @example
1190
+ * ```typescript
1191
+ * // List all outgoing invoices
1192
+ * const { data, meta } = await client.invoices.list({
1193
+ * direction: 'outgoing',
1194
+ * per_page: 50
1195
+ * });
1196
+ * console.log(`Found ${meta.total} invoices`);
1197
+ * ```
1198
+ */
1199
+ list(options?: InvoiceListOptions, requestOptions?: RequestOptions): Promise<PaginatedResponse<Invoice>>;
1200
+ /**
1201
+ * Get a specific invoice by ID
1202
+ *
1203
+ * @param id - Invoice UUID
1204
+ * @param requestOptions - Request options
1205
+ * @returns Invoice details
1206
+ *
1207
+ * @example
1208
+ * ```typescript
1209
+ * const { data: invoice } = await client.invoices.get('uuid-here');
1210
+ * console.log('Invoice number:', invoice.invoice_number);
1211
+ * ```
1212
+ */
1213
+ get(id: string, requestOptions?: RequestOptions): Promise<SingleResponse<Invoice>>;
1214
+ /**
1215
+ * Create a new invoice
1216
+ *
1217
+ * Note: This endpoint requires API key authentication.
1218
+ * Creating an invoice in production mode will debit your balance.
1219
+ *
1220
+ * @param input - Invoice creation data
1221
+ * @param requestOptions - Request options
1222
+ * @returns Created invoice
1223
+ *
1224
+ * @example
1225
+ * ```typescript
1226
+ * const { data: invoice } = await client.invoices.create({
1227
+ * invoice_number: 'FACT-2024-001',
1228
+ * direction: 'outgoing',
1229
+ * output_format: 'facturx',
1230
+ * issue_date: '2024-01-15',
1231
+ * total_ht: 100.00,
1232
+ * total_tax: 20.00,
1233
+ * total_ttc: 120.00,
1234
+ * seller_siret: '12345678901234',
1235
+ * seller_name: 'My Company',
1236
+ * seller_address: {
1237
+ * line1: '1 Rue Example',
1238
+ * postal_code: '75001',
1239
+ * city: 'Paris',
1240
+ * country: 'FR'
1241
+ * },
1242
+ * buyer_siret: '98765432109876',
1243
+ * buyer_name: 'Client Company',
1244
+ * buyer_address: {
1245
+ * line1: '2 Avenue Test',
1246
+ * postal_code: '75002',
1247
+ * city: 'Paris',
1248
+ * country: 'FR'
1249
+ * },
1250
+ * lines: [{
1251
+ * description: 'Service prestation',
1252
+ * quantity: 1,
1253
+ * unit_price: 100.00,
1254
+ * tax_rate: 20.00,
1255
+ * total_ht: 100.00,
1256
+ * total_tax: 20.00,
1257
+ * total_ttc: 120.00
1258
+ * }]
1259
+ * });
1260
+ * ```
1261
+ */
1262
+ create(input: CreateInvoiceInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Invoice>>;
1263
+ /**
1264
+ * Download invoice file
1265
+ *
1266
+ * @param id - Invoice UUID
1267
+ * @param type - File type to download
1268
+ * @param requestOptions - Request options
1269
+ * @returns Temporary download URL
1270
+ *
1271
+ * @example
1272
+ * ```typescript
1273
+ * // Download PDF version
1274
+ * const { url, expires_at } = await client.invoices.download(
1275
+ * 'invoice-uuid',
1276
+ * 'pdf'
1277
+ * );
1278
+ * console.log('Download before:', expires_at);
1279
+ * ```
1280
+ */
1281
+ download(id: string, type: InvoiceDownloadType, requestOptions?: RequestOptions): Promise<InvoiceDownloadResponse>;
1282
+ /**
1283
+ * Get invoice audit trail (Piste d'Audit Fiable)
1284
+ *
1285
+ * @param id - Invoice UUID
1286
+ * @param requestOptions - Request options
1287
+ * @returns Audit trail entries with integrity validation
1288
+ *
1289
+ * @example
1290
+ * ```typescript
1291
+ * const { data: entries, integrity_valid } = await client.invoices.auditTrail(
1292
+ * 'invoice-uuid'
1293
+ * );
1294
+ *
1295
+ * if (integrity_valid) {
1296
+ * console.log('Audit trail is valid');
1297
+ * entries.forEach(e => console.log(e.action, e.created_at));
1298
+ * }
1299
+ * ```
1300
+ */
1301
+ auditTrail(id: string, requestOptions?: RequestOptions): Promise<AuditTrailResponse>;
1302
+ /**
1303
+ * Convert invoice to another format
1304
+ *
1305
+ * @param input - Conversion parameters
1306
+ * @param requestOptions - Request options
1307
+ * @returns Conversion status
1308
+ *
1309
+ * @example
1310
+ * ```typescript
1311
+ * await client.invoices.convert({
1312
+ * invoice_id: 'invoice-uuid',
1313
+ * target_format: 'ubl'
1314
+ * });
1315
+ * ```
1316
+ */
1317
+ convert(input: ConvertInvoiceInput, requestOptions?: RequestOptions): Promise<{
1318
+ message: string;
1319
+ invoice_id: string;
1320
+ target_format: string;
1321
+ }>;
1322
+ }
1323
+
1324
+ /**
1325
+ * Signer authentication method
1326
+ */
1327
+ type SignerAuthMethod = 'email' | 'sms' | 'both';
1328
+ /**
1329
+ * Signer status
1330
+ */
1331
+ type SignerStatus = 'pending' | 'signed' | 'refused';
1332
+ /**
1333
+ * Signature status
1334
+ */
1335
+ type SignatureStatus = 'pending' | 'waiting_signers' | 'partially_signed' | 'completed' | 'refused' | 'expired' | 'error';
1336
+ /**
1337
+ * Signature download file type
1338
+ */
1339
+ type SignatureDownloadType = 'original' | 'signed' | 'audit_trail';
1340
+ /**
1341
+ * Signature position on document
1342
+ */
1343
+ interface SignaturePosition {
1344
+ page: number;
1345
+ x: number;
1346
+ y: number;
1347
+ width?: number | undefined;
1348
+ height?: number | undefined;
1349
+ }
1350
+ /**
1351
+ * UI customization for signature page (white-label)
1352
+ */
1353
+ interface SignatureUIConfig {
1354
+ logo_url?: string | undefined;
1355
+ primary_color?: string | undefined;
1356
+ company_name?: string | undefined;
1357
+ }
1358
+ /**
1359
+ * Signer entity
1360
+ */
1361
+ interface Signer {
1362
+ id: UUID;
1363
+ first_name: string;
1364
+ last_name: string;
1365
+ full_name: string;
1366
+ email: string | null;
1367
+ phone: string | null;
1368
+ auth_method: SignerAuthMethod;
1369
+ status: SignerStatus;
1370
+ signing_url: string | null;
1371
+ signed_at: DateTimeString | null;
1372
+ refused_at: DateTimeString | null;
1373
+ }
1374
+ /**
1375
+ * Signature entity
1376
+ */
1377
+ interface Signature {
1378
+ id: UUID;
1379
+ external_id: string | null;
1380
+ title: string;
1381
+ description: string | null;
1382
+ document_name: string;
1383
+ document_size: number;
1384
+ signers: Signer[] | null;
1385
+ status: SignatureStatus;
1386
+ status_message: string | null;
1387
+ environment: Environment;
1388
+ archive_enabled: boolean;
1389
+ amount_charged: number | null;
1390
+ expires_at: DateTimeString | null;
1391
+ created_at: DateTimeString;
1392
+ completed_at: DateTimeString | null;
1393
+ }
1394
+ /**
1395
+ * Signer input for creation
1396
+ */
1397
+ interface SignerInput {
1398
+ first_name: string;
1399
+ last_name: string;
1400
+ email?: string | undefined;
1401
+ phone?: string | undefined;
1402
+ auth_method: SignerAuthMethod;
1403
+ }
1404
+ /**
1405
+ * Signature creation input
1406
+ */
1407
+ interface CreateSignatureInput {
1408
+ /** Your external reference ID */
1409
+ external_id?: string | undefined;
1410
+ /** Document title */
1411
+ title: string;
1412
+ /** Document description */
1413
+ description?: string | undefined;
1414
+ /** Base64-encoded document content */
1415
+ document: string;
1416
+ /** Document filename */
1417
+ document_name: string;
1418
+ /** List of signers (1-10) */
1419
+ signers: SignerInput[];
1420
+ /** Signature positions on the document */
1421
+ signature_positions?: SignaturePosition[] | undefined;
1422
+ /** White-label UI customization */
1423
+ ui_config?: SignatureUIConfig | undefined;
1424
+ /** Redirect URL after completion */
1425
+ redirect_complete_url?: string | undefined;
1426
+ /** Redirect URL after cancellation */
1427
+ redirect_cancel_url?: string | undefined;
1428
+ /** Expiration date (default: 30 days) */
1429
+ expires_at?: DateTimeString | undefined;
1430
+ /** Enable 10-year archiving */
1431
+ archive_enabled?: boolean | undefined;
1432
+ }
1433
+ /**
1434
+ * Signature list filter options
1435
+ */
1436
+ interface SignatureListOptions {
1437
+ company_id?: UUID | undefined;
1438
+ status?: SignatureStatus | undefined;
1439
+ environment?: Environment | undefined;
1440
+ per_page?: number | undefined;
1441
+ }
1442
+ /**
1443
+ * Signature download response
1444
+ */
1445
+ interface SignatureDownloadResponse {
1446
+ url: string;
1447
+ expires_at: DateTimeString;
1448
+ }
1449
+ /**
1450
+ * Signature reminder response
1451
+ */
1452
+ interface SignatureRemindResponse {
1453
+ message: string;
1454
+ signers_reminded: number;
1455
+ }
1456
+
1457
+ /**
1458
+ * Signatures Resource
1459
+ *
1460
+ * @packageDocumentation
1461
+ */
1462
+
1463
+ /**
1464
+ * Signatures API resource
1465
+ *
1466
+ * @example
1467
+ * ```typescript
1468
+ * // Create a signature request
1469
+ * const signature = await client.signatures.create({
1470
+ * title: 'Employment Contract',
1471
+ * document: btoa(pdfContent), // Base64 encoded
1472
+ * document_name: 'contract.pdf',
1473
+ * signers: [{
1474
+ * first_name: 'John',
1475
+ * last_name: 'Doe',
1476
+ * email: 'john@example.com',
1477
+ * auth_method: 'email'
1478
+ * }]
1479
+ * });
1480
+ *
1481
+ * // Send reminder
1482
+ * await client.signatures.remind(signature.id);
1483
+ * ```
1484
+ */
1485
+ declare class SignaturesResource {
1486
+ private readonly http;
1487
+ constructor(http: HttpClient);
1488
+ /**
1489
+ * List signature requests with optional filtering
1490
+ *
1491
+ * @param options - Filter and pagination options
1492
+ * @param requestOptions - Request options
1493
+ * @returns Paginated list of signatures
1494
+ *
1495
+ * @example
1496
+ * ```typescript
1497
+ * const { data, meta } = await client.signatures.list({
1498
+ * status: 'pending',
1499
+ * per_page: 25
1500
+ * });
1501
+ * console.log(`${meta.total} pending signatures`);
1502
+ * ```
1503
+ */
1504
+ list(options?: SignatureListOptions, requestOptions?: RequestOptions): Promise<PaginatedResponse<Signature>>;
1505
+ /**
1506
+ * Get a specific signature by ID
1507
+ *
1508
+ * @param id - Signature UUID
1509
+ * @param requestOptions - Request options
1510
+ * @returns Signature details with signers
1511
+ *
1512
+ * @example
1513
+ * ```typescript
1514
+ * const { data: signature } = await client.signatures.get('uuid-here');
1515
+ * signature.signers?.forEach(signer => {
1516
+ * console.log(`${signer.full_name}: ${signer.status}`);
1517
+ * });
1518
+ * ```
1519
+ */
1520
+ get(id: string, requestOptions?: RequestOptions): Promise<SingleResponse<Signature>>;
1521
+ /**
1522
+ * Create a new signature request
1523
+ *
1524
+ * Note: This endpoint requires API key authentication.
1525
+ * Creating a signature in production mode will debit your balance.
1526
+ *
1527
+ * @param input - Signature creation data
1528
+ * @param requestOptions - Request options
1529
+ * @returns Created signature
1530
+ *
1531
+ * @example
1532
+ * ```typescript
1533
+ * import { readFileSync } from 'fs';
1534
+ *
1535
+ * const pdfContent = readFileSync('contract.pdf');
1536
+ * const { data: signature } = await client.signatures.create({
1537
+ * title: 'Service Agreement',
1538
+ * description: 'Annual service contract',
1539
+ * document: pdfContent.toString('base64'),
1540
+ * document_name: 'contract.pdf',
1541
+ * signers: [
1542
+ * {
1543
+ * first_name: 'Alice',
1544
+ * last_name: 'Smith',
1545
+ * email: 'alice@example.com',
1546
+ * auth_method: 'email'
1547
+ * },
1548
+ * {
1549
+ * first_name: 'Bob',
1550
+ * last_name: 'Jones',
1551
+ * phone: '+33612345678',
1552
+ * auth_method: 'sms'
1553
+ * }
1554
+ * ],
1555
+ * ui_config: {
1556
+ * logo_url: 'https://mycompany.com/logo.png',
1557
+ * primary_color: '#3b82f6',
1558
+ * company_name: 'My Company'
1559
+ * },
1560
+ * redirect_complete_url: 'https://myapp.com/signed',
1561
+ * redirect_cancel_url: 'https://myapp.com/cancelled'
1562
+ * });
1563
+ *
1564
+ * // Send signing URLs to signers
1565
+ * signature.signers?.forEach(signer => {
1566
+ * console.log(`${signer.email}: ${signer.signing_url}`);
1567
+ * });
1568
+ * ```
1569
+ */
1570
+ create(input: CreateSignatureInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Signature>>;
1571
+ /**
1572
+ * Download signature files
1573
+ *
1574
+ * @param id - Signature UUID
1575
+ * @param type - File type to download
1576
+ * @param requestOptions - Request options
1577
+ * @returns Temporary download URL
1578
+ *
1579
+ * @example
1580
+ * ```typescript
1581
+ * // Download signed document
1582
+ * const { url } = await client.signatures.download(
1583
+ * 'signature-uuid',
1584
+ * 'signed'
1585
+ * );
1586
+ *
1587
+ * // Download audit trail (proof file)
1588
+ * const { url: auditUrl } = await client.signatures.download(
1589
+ * 'signature-uuid',
1590
+ * 'audit_trail'
1591
+ * );
1592
+ * ```
1593
+ */
1594
+ download(id: string, type: SignatureDownloadType, requestOptions?: RequestOptions): Promise<SignatureDownloadResponse>;
1595
+ /**
1596
+ * Send reminder to pending signers
1597
+ *
1598
+ * @param id - Signature UUID
1599
+ * @param requestOptions - Request options
1600
+ * @returns Number of signers reminded
1601
+ *
1602
+ * @example
1603
+ * ```typescript
1604
+ * const { signers_reminded } = await client.signatures.remind('uuid');
1605
+ * console.log(`Reminded ${signers_reminded} signers`);
1606
+ * ```
1607
+ */
1608
+ remind(id: string, requestOptions?: RequestOptions): Promise<SignatureRemindResponse>;
1609
+ /**
1610
+ * Cancel a signature request
1611
+ *
1612
+ * Note: Cannot cancel completed signatures.
1613
+ *
1614
+ * @param id - Signature UUID
1615
+ * @param requestOptions - Request options
1616
+ * @returns Cancellation confirmation
1617
+ *
1618
+ * @example
1619
+ * ```typescript
1620
+ * await client.signatures.cancel('signature-uuid');
1621
+ * console.log('Signature cancelled');
1622
+ * ```
1623
+ */
1624
+ cancel(id: string, requestOptions?: RequestOptions): Promise<MessageResponse>;
1625
+ }
1626
+
1627
+ /**
1628
+ * Available webhook events
1629
+ */
1630
+ type WebhookEvent = 'invoice.created' | 'invoice.validated' | 'invoice.transmitted' | 'invoice.accepted' | 'invoice.rejected' | 'invoice.error' | 'signature.created' | 'signature.waiting' | 'signature.signed' | 'signature.completed' | 'signature.refused' | 'signature.expired' | 'signature.error' | 'balance.low' | 'balance.critical';
1631
+ /**
1632
+ * Webhook entity
1633
+ */
1634
+ interface Webhook {
1635
+ id: UUID;
1636
+ company_id: UUID | null;
1637
+ url: string;
1638
+ events: WebhookEvent[];
1639
+ is_active: boolean;
1640
+ environment: Environment;
1641
+ retry_count: number;
1642
+ timeout_seconds: number;
1643
+ failure_count: number;
1644
+ last_triggered_at: DateTimeString | null;
1645
+ last_success_at: DateTimeString | null;
1646
+ last_failure_at: DateTimeString | null;
1647
+ created_at: DateTimeString;
1648
+ }
1649
+ /**
1650
+ * Webhook with secret (returned on creation)
1651
+ */
1652
+ interface WebhookWithSecret extends Webhook {
1653
+ secret: string;
1654
+ }
1655
+ /**
1656
+ * Webhook creation input
1657
+ */
1658
+ interface CreateWebhookInput {
1659
+ url: string;
1660
+ events: WebhookEvent[];
1661
+ environment: Environment;
1662
+ headers?: Record<string, string> | undefined;
1663
+ retry_count?: number | undefined;
1664
+ timeout_seconds?: number | undefined;
1665
+ }
1666
+ /**
1667
+ * Webhook update input
1668
+ */
1669
+ interface UpdateWebhookInput {
1670
+ url?: string | undefined;
1671
+ events?: WebhookEvent[] | undefined;
1672
+ is_active?: boolean | undefined;
1673
+ headers?: Record<string, string> | undefined;
1674
+ retry_count?: number | undefined;
1675
+ timeout_seconds?: number | undefined;
1676
+ }
1677
+ /**
1678
+ * Webhook list filter options
1679
+ */
1680
+ interface WebhookListOptions {
1681
+ company_id?: UUID | undefined;
1682
+ }
1683
+ /**
1684
+ * Webhook test response
1685
+ */
1686
+ interface WebhookTestResponse {
1687
+ success: boolean;
1688
+ status_code?: number | undefined;
1689
+ response_time_ms?: number | undefined;
1690
+ error?: string | undefined;
1691
+ }
1692
+ /**
1693
+ * Webhook log entry
1694
+ */
1695
+ interface WebhookLog {
1696
+ id: UUID;
1697
+ event: string;
1698
+ payload: Record<string, unknown>;
1699
+ response_status: number | null;
1700
+ response_body: string | null;
1701
+ response_time_ms: number | null;
1702
+ success: boolean;
1703
+ error_message: string | null;
1704
+ created_at: DateTimeString;
1705
+ }
1706
+ /**
1707
+ * Webhook payload structure (received by your endpoint)
1708
+ */
1709
+ interface WebhookPayload<T = unknown> {
1710
+ event: WebhookEvent;
1711
+ timestamp: DateTimeString;
1712
+ data: T;
1713
+ }
1714
+ /**
1715
+ * Invoice webhook payload data
1716
+ */
1717
+ interface InvoiceWebhookData {
1718
+ id: UUID;
1719
+ invoice_number: string;
1720
+ status: string;
1721
+ environment: Environment;
1722
+ }
1723
+ /**
1724
+ * Signature webhook payload data
1725
+ */
1726
+ interface SignatureWebhookData {
1727
+ id: UUID;
1728
+ title: string;
1729
+ status: string;
1730
+ environment: Environment;
1731
+ signer_id?: UUID | undefined;
1732
+ signer_email?: string | undefined;
1733
+ }
1734
+ /**
1735
+ * Balance webhook payload data
1736
+ */
1737
+ interface BalanceWebhookData {
1738
+ amount: number;
1739
+ currency: string;
1740
+ threshold: number;
1741
+ }
1742
+
1743
+ /**
1744
+ * Webhooks Resource
1745
+ *
1746
+ * @packageDocumentation
1747
+ */
1748
+
1749
+ /**
1750
+ * Webhooks API resource
1751
+ *
1752
+ * @example
1753
+ * ```typescript
1754
+ * // Create a webhook
1755
+ * const webhook = await client.webhooks.create({
1756
+ * url: 'https://myapp.com/webhooks/scell',
1757
+ * events: ['invoice.validated', 'signature.completed'],
1758
+ * environment: 'production'
1759
+ * });
1760
+ *
1761
+ * // Store the secret securely!
1762
+ * console.log('Webhook secret:', webhook.secret);
1763
+ *
1764
+ * // Test the webhook
1765
+ * const test = await client.webhooks.test(webhook.id);
1766
+ * console.log('Test success:', test.success);
1767
+ * ```
1768
+ */
1769
+ declare class WebhooksResource {
1770
+ private readonly http;
1771
+ constructor(http: HttpClient);
1772
+ /**
1773
+ * List all webhooks
1774
+ *
1775
+ * @param options - Filter options
1776
+ * @param requestOptions - Request options
1777
+ * @returns List of webhooks
1778
+ *
1779
+ * @example
1780
+ * ```typescript
1781
+ * const { data: webhooks } = await client.webhooks.list();
1782
+ * webhooks.forEach(wh => {
1783
+ * console.log(`${wh.url}: ${wh.is_active ? 'active' : 'inactive'}`);
1784
+ * });
1785
+ * ```
1786
+ */
1787
+ list(options?: WebhookListOptions, requestOptions?: RequestOptions): Promise<{
1788
+ data: Webhook[];
1789
+ }>;
1790
+ /**
1791
+ * Create a new webhook
1792
+ *
1793
+ * Important: The secret is only returned once during creation.
1794
+ * Store it securely - you'll need it to verify webhook signatures.
1795
+ *
1796
+ * @param input - Webhook configuration
1797
+ * @param requestOptions - Request options
1798
+ * @returns Created webhook with secret
1799
+ *
1800
+ * @example
1801
+ * ```typescript
1802
+ * const { data: webhook } = await client.webhooks.create({
1803
+ * url: 'https://myapp.com/webhooks/scell',
1804
+ * events: [
1805
+ * 'invoice.created',
1806
+ * 'invoice.validated',
1807
+ * 'signature.completed',
1808
+ * 'balance.low'
1809
+ * ],
1810
+ * environment: 'production',
1811
+ * headers: {
1812
+ * 'X-Custom-Auth': 'my-secret-token'
1813
+ * },
1814
+ * retry_count: 5,
1815
+ * timeout_seconds: 30
1816
+ * });
1817
+ *
1818
+ * // IMPORTANT: Store this secret securely!
1819
+ * await saveWebhookSecret(webhook.id, webhook.secret);
1820
+ * ```
1821
+ */
1822
+ create(input: CreateWebhookInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<WebhookWithSecret>>;
1823
+ /**
1824
+ * Update a webhook
1825
+ *
1826
+ * @param id - Webhook UUID
1827
+ * @param input - Fields to update
1828
+ * @param requestOptions - Request options
1829
+ * @returns Updated webhook
1830
+ *
1831
+ * @example
1832
+ * ```typescript
1833
+ * // Disable a webhook temporarily
1834
+ * await client.webhooks.update('webhook-uuid', {
1835
+ * is_active: false
1836
+ * });
1837
+ *
1838
+ * // Update events
1839
+ * await client.webhooks.update('webhook-uuid', {
1840
+ * events: ['invoice.validated', 'signature.completed']
1841
+ * });
1842
+ * ```
1843
+ */
1844
+ update(id: string, input: UpdateWebhookInput, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<Webhook>>;
1845
+ /**
1846
+ * Delete a webhook
1847
+ *
1848
+ * @param id - Webhook UUID
1849
+ * @param requestOptions - Request options
1850
+ * @returns Deletion confirmation
1851
+ *
1852
+ * @example
1853
+ * ```typescript
1854
+ * await client.webhooks.delete('webhook-uuid');
1855
+ * ```
1856
+ */
1857
+ delete(id: string, requestOptions?: RequestOptions): Promise<MessageResponse>;
1858
+ /**
1859
+ * Regenerate webhook secret
1860
+ *
1861
+ * Use this if your secret has been compromised.
1862
+ * The old secret will immediately stop working.
1863
+ *
1864
+ * @param id - Webhook UUID
1865
+ * @param requestOptions - Request options
1866
+ * @returns Webhook with new secret
1867
+ *
1868
+ * @example
1869
+ * ```typescript
1870
+ * const { data: webhook } = await client.webhooks.regenerateSecret(
1871
+ * 'webhook-uuid'
1872
+ * );
1873
+ *
1874
+ * // Update your stored secret
1875
+ * await updateWebhookSecret(webhook.id, webhook.secret);
1876
+ * ```
1877
+ */
1878
+ regenerateSecret(id: string, requestOptions?: RequestOptions): Promise<MessageWithDataResponse<WebhookWithSecret>>;
1879
+ /**
1880
+ * Test webhook by sending a test event
1881
+ *
1882
+ * @param id - Webhook UUID
1883
+ * @param requestOptions - Request options
1884
+ * @returns Test result
1885
+ *
1886
+ * @example
1887
+ * ```typescript
1888
+ * const result = await client.webhooks.test('webhook-uuid');
1889
+ *
1890
+ * if (result.success) {
1891
+ * console.log(`Success! Response time: ${result.response_time_ms}ms`);
1892
+ * } else {
1893
+ * console.log(`Failed: ${result.error}`);
1894
+ * }
1895
+ * ```
1896
+ */
1897
+ test(id: string, requestOptions?: RequestOptions): Promise<WebhookTestResponse>;
1898
+ /**
1899
+ * Get webhook delivery logs
1900
+ *
1901
+ * @param id - Webhook UUID
1902
+ * @param options - Pagination options
1903
+ * @param requestOptions - Request options
1904
+ * @returns Paginated list of logs
1905
+ *
1906
+ * @example
1907
+ * ```typescript
1908
+ * const { data: logs } = await client.webhooks.logs('webhook-uuid', {
1909
+ * per_page: 50
1910
+ * });
1911
+ *
1912
+ * logs.forEach(log => {
1913
+ * const status = log.success ? 'OK' : 'FAILED';
1914
+ * console.log(`${log.event} - ${status} (${log.response_time_ms}ms)`);
1915
+ * });
1916
+ * ```
1917
+ */
1918
+ logs(id: string, options?: {
1919
+ per_page?: number;
1920
+ }, requestOptions?: RequestOptions): Promise<PaginatedResponse<WebhookLog>>;
1921
+ }
1922
+
1923
+ /**
1924
+ * Webhook signature verification utility
1925
+ *
1926
+ * @packageDocumentation
1927
+ */
1928
+
1929
+ /**
1930
+ * Signature verification options
1931
+ */
1932
+ interface VerifySignatureOptions {
1933
+ /** Tolerance in seconds for timestamp validation (default: 300 = 5 minutes) */
1934
+ tolerance?: number | undefined;
1935
+ }
1936
+ /**
1937
+ * Scell Webhook signature verification utilities
1938
+ *
1939
+ * @example
1940
+ * ```typescript
1941
+ * import { ScellWebhooks } from '@scell/sdk';
1942
+ *
1943
+ * // In your webhook endpoint
1944
+ * app.post('/webhooks/scell', async (req, res) => {
1945
+ * const signature = req.headers['x-scell-signature'];
1946
+ * const payload = JSON.stringify(req.body);
1947
+ *
1948
+ * const isValid = await ScellWebhooks.verifySignature(
1949
+ * payload,
1950
+ * signature,
1951
+ * process.env.WEBHOOK_SECRET
1952
+ * );
1953
+ *
1954
+ * if (!isValid) {
1955
+ * return res.status(401).send('Invalid signature');
1956
+ * }
1957
+ *
1958
+ * // Process the webhook
1959
+ * const event = ScellWebhooks.parsePayload(payload);
1960
+ * console.log('Received event:', event.event);
1961
+ * });
1962
+ * ```
1963
+ */
1964
+ declare const ScellWebhooks: {
1965
+ /**
1966
+ * Verify webhook signature
1967
+ *
1968
+ * @param payload - Raw request body as string
1969
+ * @param signature - Value of X-Scell-Signature header
1970
+ * @param secret - Your webhook secret (whsec_...)
1971
+ * @param options - Verification options
1972
+ * @returns True if signature is valid
1973
+ *
1974
+ * @example
1975
+ * ```typescript
1976
+ * const isValid = await ScellWebhooks.verifySignature(
1977
+ * rawBody,
1978
+ * req.headers['x-scell-signature'],
1979
+ * 'whsec_abc123...'
1980
+ * );
1981
+ * ```
1982
+ */
1983
+ verifySignature(payload: string, signature: string, secret: string, options?: VerifySignatureOptions): Promise<boolean>;
1984
+ /**
1985
+ * Verify webhook signature synchronously using Node.js crypto
1986
+ * (Only works in Node.js environment)
1987
+ *
1988
+ * @param payload - Raw request body as string
1989
+ * @param signature - Value of X-Scell-Signature header
1990
+ * @param secret - Your webhook secret (whsec_...)
1991
+ * @param options - Verification options
1992
+ * @returns True if signature is valid
1993
+ */
1994
+ verifySignatureSync(payload: string, signature: string, secret: string, options?: VerifySignatureOptions): boolean;
1995
+ /**
1996
+ * Parse webhook payload
1997
+ *
1998
+ * @param payload - Raw request body as string
1999
+ * @returns Parsed webhook payload
2000
+ *
2001
+ * @example
2002
+ * ```typescript
2003
+ * const event = ScellWebhooks.parsePayload<InvoiceWebhookData>(rawBody);
2004
+ * if (event.event === 'invoice.validated') {
2005
+ * console.log('Invoice validated:', event.data.invoice_number);
2006
+ * }
2007
+ * ```
2008
+ */
2009
+ parsePayload<T = unknown>(payload: string): WebhookPayload<T>;
2010
+ /**
2011
+ * Construct a test webhook event for local testing
2012
+ *
2013
+ * @param event - Event type
2014
+ * @param data - Event data
2015
+ * @param secret - Webhook secret for signing
2016
+ * @returns Object with payload and headers for testing
2017
+ */
2018
+ constructTestEvent<T>(event: string, data: T, secret: string): Promise<{
2019
+ payload: string;
2020
+ headers: Record<string, string>;
2021
+ }>;
2022
+ };
2023
+
2024
+ /**
2025
+ * Scell SDK Error Classes
2026
+ *
2027
+ * @packageDocumentation
2028
+ */
2029
+ /**
2030
+ * Base error class for all Scell API errors
2031
+ */
2032
+ declare class ScellError extends Error {
2033
+ /** HTTP status code */
2034
+ readonly status: number;
2035
+ /** Error code from API */
2036
+ readonly code: string | undefined;
2037
+ /** Original response body */
2038
+ readonly body: unknown;
2039
+ constructor(message: string, status: number, code?: string, body?: unknown);
2040
+ }
2041
+ /**
2042
+ * Error thrown when authentication fails (401)
2043
+ *
2044
+ * @example
2045
+ * ```typescript
2046
+ * try {
2047
+ * await client.invoices.list();
2048
+ * } catch (error) {
2049
+ * if (error instanceof ScellAuthenticationError) {
2050
+ * console.log('Invalid or expired token');
2051
+ * }
2052
+ * }
2053
+ * ```
2054
+ */
2055
+ declare class ScellAuthenticationError extends ScellError {
2056
+ constructor(message?: string, body?: unknown);
2057
+ }
2058
+ /**
2059
+ * Error thrown when authorization fails (403)
2060
+ *
2061
+ * @example
2062
+ * ```typescript
2063
+ * try {
2064
+ * await client.admin.users();
2065
+ * } catch (error) {
2066
+ * if (error instanceof ScellAuthorizationError) {
2067
+ * console.log('Insufficient permissions');
2068
+ * }
2069
+ * }
2070
+ * ```
2071
+ */
2072
+ declare class ScellAuthorizationError extends ScellError {
2073
+ constructor(message?: string, body?: unknown);
2074
+ }
2075
+ /**
2076
+ * Error thrown when validation fails (422)
2077
+ *
2078
+ * @example
2079
+ * ```typescript
2080
+ * try {
2081
+ * await client.invoices.create(invalidData);
2082
+ * } catch (error) {
2083
+ * if (error instanceof ScellValidationError) {
2084
+ * console.log('Validation errors:', error.errors);
2085
+ * }
2086
+ * }
2087
+ * ```
2088
+ */
2089
+ declare class ScellValidationError extends ScellError {
2090
+ /** Field-level validation errors */
2091
+ readonly errors: Record<string, string[]>;
2092
+ constructor(message: string, errors?: Record<string, string[]>, body?: unknown);
2093
+ /**
2094
+ * Get all error messages as a flat array
2095
+ */
2096
+ getAllMessages(): string[];
2097
+ /**
2098
+ * Get error messages for a specific field
2099
+ */
2100
+ getFieldErrors(field: string): string[];
2101
+ /**
2102
+ * Check if a specific field has errors
2103
+ */
2104
+ hasFieldError(field: string): boolean;
2105
+ }
2106
+ /**
2107
+ * Error thrown when rate limit is exceeded (429)
2108
+ *
2109
+ * @example
2110
+ * ```typescript
2111
+ * try {
2112
+ * await client.invoices.create(data);
2113
+ * } catch (error) {
2114
+ * if (error instanceof ScellRateLimitError) {
2115
+ * console.log(`Retry after ${error.retryAfter} seconds`);
2116
+ * }
2117
+ * }
2118
+ * ```
2119
+ */
2120
+ declare class ScellRateLimitError extends ScellError {
2121
+ /** Seconds to wait before retrying */
2122
+ readonly retryAfter: number | undefined;
2123
+ constructor(message?: string, retryAfter?: number, body?: unknown);
2124
+ }
2125
+ /**
2126
+ * Error thrown when a resource is not found (404)
2127
+ */
2128
+ declare class ScellNotFoundError extends ScellError {
2129
+ constructor(message?: string, body?: unknown);
2130
+ }
2131
+ /**
2132
+ * Error thrown when the API returns a server error (5xx)
2133
+ */
2134
+ declare class ScellServerError extends ScellError {
2135
+ constructor(message?: string, status?: number, body?: unknown);
2136
+ }
2137
+ /**
2138
+ * Error thrown when insufficient balance for an operation
2139
+ */
2140
+ declare class ScellInsufficientBalanceError extends ScellError {
2141
+ constructor(message?: string, body?: unknown);
2142
+ }
2143
+ /**
2144
+ * Error thrown for network-related issues
2145
+ */
2146
+ declare class ScellNetworkError extends ScellError {
2147
+ readonly originalError: Error;
2148
+ constructor(message: string, originalError: Error);
2149
+ }
2150
+ /**
2151
+ * Error thrown when request times out
2152
+ */
2153
+ declare class ScellTimeoutError extends ScellError {
2154
+ constructor(message?: string);
2155
+ }
2156
+
2157
+ /**
2158
+ * Scell.io Official TypeScript SDK
2159
+ *
2160
+ * @packageDocumentation
2161
+ *
2162
+ * @example
2163
+ * ```typescript
2164
+ * import { ScellClient, ScellApiClient, ScellAuth, ScellWebhooks } from '@scell/sdk';
2165
+ *
2166
+ * // Dashboard client (Bearer token)
2167
+ * const auth = await ScellAuth.login({ email, password });
2168
+ * const client = new ScellClient(auth.token);
2169
+ *
2170
+ * // API client (X-API-Key)
2171
+ * const apiClient = new ScellApiClient('your-api-key');
2172
+ *
2173
+ * // Create invoice
2174
+ * const invoice = await apiClient.invoices.create({...});
2175
+ *
2176
+ * // Verify webhook
2177
+ * const isValid = await ScellWebhooks.verifySignature(payload, signature, secret);
2178
+ * ```
2179
+ */
2180
+
2181
+ /**
2182
+ * Scell Dashboard Client
2183
+ *
2184
+ * Use this client for dashboard/user operations with Bearer token authentication.
2185
+ *
2186
+ * @example
2187
+ * ```typescript
2188
+ * import { ScellClient, ScellAuth } from '@scell/sdk';
2189
+ *
2190
+ * // Login first
2191
+ * const auth = await ScellAuth.login({
2192
+ * email: 'user@example.com',
2193
+ * password: 'password'
2194
+ * });
2195
+ *
2196
+ * // Create client
2197
+ * const client = new ScellClient(auth.token);
2198
+ *
2199
+ * // Use the client
2200
+ * const companies = await client.companies.list();
2201
+ * const balance = await client.balance.get();
2202
+ * ```
2203
+ */
2204
+ declare class ScellClient {
2205
+ private readonly http;
2206
+ /** Authentication operations */
2207
+ readonly auth: AuthResource;
2208
+ /** Company management */
2209
+ readonly companies: CompaniesResource;
2210
+ /** API key management */
2211
+ readonly apiKeys: ApiKeysResource;
2212
+ /** Balance and transactions */
2213
+ readonly balance: BalanceResource;
2214
+ /** Webhook management */
2215
+ readonly webhooks: WebhooksResource;
2216
+ /** Invoice listing (read-only via dashboard) */
2217
+ readonly invoices: InvoicesResource;
2218
+ /** Signature listing (read-only via dashboard) */
2219
+ readonly signatures: SignaturesResource;
2220
+ /**
2221
+ * Create a new Scell Dashboard Client
2222
+ *
2223
+ * @param token - Bearer token from login
2224
+ * @param config - Client configuration
2225
+ *
2226
+ * @example
2227
+ * ```typescript
2228
+ * const client = new ScellClient('your-bearer-token', {
2229
+ * baseUrl: 'https://api.scell.io/api/v1',
2230
+ * timeout: 30000,
2231
+ * retry: { maxRetries: 3 }
2232
+ * });
2233
+ * ```
2234
+ */
2235
+ constructor(token: string, config?: ClientConfig);
2236
+ }
2237
+ /**
2238
+ * Scell API Client
2239
+ *
2240
+ * Use this client for external API operations with X-API-Key authentication.
2241
+ * This is the client you'll use for creating invoices and signatures.
2242
+ *
2243
+ * @example
2244
+ * ```typescript
2245
+ * import { ScellApiClient } from '@scell/sdk';
2246
+ *
2247
+ * const client = new ScellApiClient('your-api-key');
2248
+ *
2249
+ * // Create an invoice
2250
+ * const invoice = await client.invoices.create({
2251
+ * invoice_number: 'FACT-2024-001',
2252
+ * direction: 'outgoing',
2253
+ * output_format: 'facturx',
2254
+ * // ...
2255
+ * });
2256
+ *
2257
+ * // Create a signature request
2258
+ * const signature = await client.signatures.create({
2259
+ * title: 'Contract',
2260
+ * document: btoa(pdfContent),
2261
+ * document_name: 'contract.pdf',
2262
+ * signers: [{...}]
2263
+ * });
2264
+ * ```
2265
+ */
2266
+ declare class ScellApiClient {
2267
+ private readonly http;
2268
+ /** Invoice operations (create, download, convert) */
2269
+ readonly invoices: InvoicesResource;
2270
+ /** Signature operations (create, download, remind, cancel) */
2271
+ readonly signatures: SignaturesResource;
2272
+ /**
2273
+ * Create a new Scell API Client
2274
+ *
2275
+ * @param apiKey - Your API key (from dashboard)
2276
+ * @param config - Client configuration
2277
+ *
2278
+ * @example
2279
+ * ```typescript
2280
+ * // Production client
2281
+ * const client = new ScellApiClient('sk_live_xxx');
2282
+ *
2283
+ * // Sandbox client
2284
+ * const sandboxClient = new ScellApiClient('sk_test_xxx', {
2285
+ * baseUrl: 'https://api.scell.io/api/v1/sandbox'
2286
+ * });
2287
+ * ```
2288
+ */
2289
+ constructor(apiKey: string, config?: ClientConfig);
2290
+ }
2291
+
2292
+ export { type Address, type ApiErrorResponse, type ApiKey, type ApiKeyWithSecret, type AuditTrailEntry, type AuditTrailResponse, type AuthResponse, type Balance, type BalanceWebhookData, type ClientConfig, type Company, type CompanyStatus, type ConvertInvoiceInput, type CreateApiKeyInput, type CreateCompanyInput, type CreateInvoiceInput, type CreateSignatureInput, type CreateWebhookInput, type CurrencyCode, type DateRangeOptions, type DateString, type DateTimeString, type Environment, type ForgotPasswordInput, type Invoice, type InvoiceDirection, type InvoiceDownloadResponse, type InvoiceDownloadType, type InvoiceFormat, type InvoiceLine, type InvoiceLineInput, type InvoiceListOptions, type InvoiceParty, type InvoiceStatus, type InvoiceWebhookData, type KycInitiateResponse, type KycStatusResponse, type LoginCredentials, type MessageResponse, type MessageWithDataResponse, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type RegisterInput, type ReloadBalanceInput, type ReloadBalanceResponse, type ResetPasswordInput, type RetryOptions, ScellApiClient, ScellAuth, ScellAuthenticationError, ScellAuthorizationError, ScellClient, ScellError, ScellInsufficientBalanceError, ScellNetworkError, ScellNotFoundError, ScellRateLimitError, ScellServerError, ScellTimeoutError, ScellValidationError, ScellWebhooks, type Signature, type SignatureDownloadResponse, type SignatureDownloadType, type SignatureListOptions, type SignaturePosition, type SignatureRemindResponse, type SignatureStatus, type SignatureUIConfig, type SignatureWebhookData, type Signer, type SignerAuthMethod, type SignerInput, type SignerStatus, type SingleResponse, type Siren, type Siret, type Transaction, type TransactionListOptions, type TransactionService, type TransactionType, type UUID, type UpdateBalanceSettingsInput, type UpdateCompanyInput, type UpdateWebhookInput, type User, type VerifySignatureOptions, type Webhook, type WebhookEvent, type WebhookListOptions, type WebhookLog, type WebhookPayload, type WebhookTestResponse, type WebhookWithSecret, createRetryWrapper, withRetry };