@scell/sdk 1.0.0 → 1.2.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.
package/dist/index.d.ts CHANGED
@@ -131,6 +131,17 @@ declare class HttpClient {
131
131
  * DELETE request
132
132
  */
133
133
  delete<T>(path: string, options?: RequestOptions): Promise<T>;
134
+ /**
135
+ * GET request that returns raw binary data as ArrayBuffer
136
+ *
137
+ * Use this for downloading files (PDF, XML, etc.)
138
+ *
139
+ * @param path - API endpoint path
140
+ * @param query - Query parameters
141
+ * @param options - Request options
142
+ * @returns ArrayBuffer containing the file content
143
+ */
144
+ getRaw(path: string, query?: Record<string, string | number | boolean | undefined>, options?: RequestOptions): Promise<ArrayBuffer>;
134
145
  }
135
146
 
136
147
  /**
@@ -996,7 +1007,7 @@ type InvoiceFormat = 'facturx' | 'ubl' | 'cii';
996
1007
  /**
997
1008
  * Invoice status
998
1009
  */
999
- type InvoiceStatus = 'draft' | 'pending' | 'validated' | 'converted' | 'transmitted' | 'accepted' | 'rejected' | 'error';
1010
+ type InvoiceStatus = 'draft' | 'pending' | 'validated' | 'converted' | 'transmitted' | 'accepted' | 'rejected' | 'paid' | 'disputed' | 'cancelled' | 'error';
1000
1011
  /**
1001
1012
  * Invoice download file type
1002
1013
  */
@@ -1049,6 +1060,12 @@ interface Invoice {
1049
1060
  validated_at: DateTimeString | null;
1050
1061
  transmitted_at: DateTimeString | null;
1051
1062
  completed_at: DateTimeString | null;
1063
+ /** Date when the invoice was marked as paid (ISO 8601) */
1064
+ paid_at: DateTimeString | null;
1065
+ /** Payment reference (bank transfer ID, check number, etc.) */
1066
+ payment_reference: string | null;
1067
+ /** Optional note about the payment */
1068
+ payment_note: string | null;
1052
1069
  }
1053
1070
  /**
1054
1071
  * Invoice line input for creation
@@ -1145,6 +1162,71 @@ interface AuditTrailResponse {
1145
1162
  data: AuditTrailEntry[];
1146
1163
  integrity_valid: boolean;
1147
1164
  }
1165
+ /**
1166
+ * Incoming invoice list filter options
1167
+ */
1168
+ interface IncomingInvoiceParams {
1169
+ status?: InvoiceStatus | undefined;
1170
+ seller_siret?: Siret | undefined;
1171
+ from?: DateString | undefined;
1172
+ to?: DateString | undefined;
1173
+ min_amount?: number | undefined;
1174
+ max_amount?: number | undefined;
1175
+ page?: number | undefined;
1176
+ per_page?: number | undefined;
1177
+ }
1178
+ /**
1179
+ * Rejection reason code for incoming invoices
1180
+ */
1181
+ type RejectionCode = 'incorrect_amount' | 'duplicate' | 'unknown_order' | 'incorrect_vat' | 'other';
1182
+ /**
1183
+ * Dispute type for incoming invoices
1184
+ */
1185
+ type DisputeType = 'amount_dispute' | 'quality_dispute' | 'delivery_dispute' | 'other';
1186
+ /**
1187
+ * Input for accepting an incoming invoice
1188
+ */
1189
+ interface AcceptInvoiceInput {
1190
+ /** Expected payment date (YYYY-MM-DD) */
1191
+ payment_date?: DateString | undefined;
1192
+ /** Optional note about the acceptance */
1193
+ note?: string | undefined;
1194
+ }
1195
+ /**
1196
+ * Input for rejecting an incoming invoice
1197
+ */
1198
+ interface RejectInvoiceInput {
1199
+ /** Reason for rejection */
1200
+ reason: string;
1201
+ /** Standardized rejection code */
1202
+ reason_code: RejectionCode;
1203
+ }
1204
+ /**
1205
+ * Input for disputing an incoming invoice
1206
+ */
1207
+ interface DisputeInvoiceInput {
1208
+ /** Reason for the dispute */
1209
+ reason: string;
1210
+ /** Type of dispute */
1211
+ dispute_type: DisputeType;
1212
+ /** Expected correct amount (if amount dispute) */
1213
+ expected_amount?: number | undefined;
1214
+ }
1215
+ /**
1216
+ * Input for marking an incoming invoice as paid
1217
+ */
1218
+ interface MarkPaidInput {
1219
+ /** Payment reference (bank transfer ID, check number, etc.) */
1220
+ payment_reference?: string | undefined;
1221
+ /** Payment date (ISO 8601) - defaults to current date/time if not provided */
1222
+ paid_at?: DateTimeString | undefined;
1223
+ /** Optional note about the payment */
1224
+ note?: string | undefined;
1225
+ }
1226
+ /**
1227
+ * Invoice file download format
1228
+ */
1229
+ type InvoiceFileFormat = 'pdf' | 'xml';
1148
1230
 
1149
1231
  /**
1150
1232
  * Invoices Resource
@@ -1319,6 +1401,152 @@ declare class InvoicesResource {
1319
1401
  invoice_id: string;
1320
1402
  target_format: string;
1321
1403
  }>;
1404
+ /**
1405
+ * List incoming invoices (from suppliers)
1406
+ *
1407
+ * Returns invoices where your company is the buyer.
1408
+ *
1409
+ * @param params - Filter and pagination options
1410
+ * @param requestOptions - Request options
1411
+ * @returns Paginated list of incoming invoices
1412
+ *
1413
+ * @example
1414
+ * ```typescript
1415
+ * // List all incoming invoices
1416
+ * const { data, meta } = await client.invoices.incoming({
1417
+ * status: 'pending',
1418
+ * per_page: 50
1419
+ * });
1420
+ * console.log(`Found ${meta.total} incoming invoices`);
1421
+ *
1422
+ * // Filter by seller
1423
+ * const fromSupplier = await client.invoices.incoming({
1424
+ * seller_siret: '12345678901234'
1425
+ * });
1426
+ * ```
1427
+ */
1428
+ incoming(params?: IncomingInvoiceParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Invoice>>;
1429
+ /**
1430
+ * Accept an incoming invoice
1431
+ *
1432
+ * Mark an incoming invoice as accepted, optionally specifying a payment date.
1433
+ *
1434
+ * @param id - Invoice UUID
1435
+ * @param data - Optional acceptance data
1436
+ * @param requestOptions - Request options
1437
+ * @returns Updated invoice
1438
+ *
1439
+ * @example
1440
+ * ```typescript
1441
+ * // Accept with payment date
1442
+ * const { data: invoice } = await client.invoices.accept('invoice-uuid', {
1443
+ * payment_date: '2024-02-15',
1444
+ * note: 'Approved by accounting'
1445
+ * });
1446
+ *
1447
+ * // Simple acceptance
1448
+ * await client.invoices.accept('invoice-uuid');
1449
+ * ```
1450
+ */
1451
+ accept(id: string, data?: AcceptInvoiceInput, requestOptions?: RequestOptions): Promise<SingleResponse<Invoice>>;
1452
+ /**
1453
+ * Reject an incoming invoice
1454
+ *
1455
+ * Mark an incoming invoice as rejected with a reason.
1456
+ *
1457
+ * @param id - Invoice UUID
1458
+ * @param data - Rejection details
1459
+ * @param requestOptions - Request options
1460
+ * @returns Updated invoice
1461
+ *
1462
+ * @example
1463
+ * ```typescript
1464
+ * const { data: invoice } = await client.invoices.reject('invoice-uuid', {
1465
+ * reason: 'Invoice amount does not match purchase order',
1466
+ * reason_code: 'incorrect_amount'
1467
+ * });
1468
+ * ```
1469
+ */
1470
+ reject(id: string, data: RejectInvoiceInput, requestOptions?: RequestOptions): Promise<SingleResponse<Invoice>>;
1471
+ /**
1472
+ * Dispute an incoming invoice
1473
+ *
1474
+ * Open a dispute on an incoming invoice for resolution.
1475
+ *
1476
+ * @param id - Invoice UUID
1477
+ * @param data - Dispute details
1478
+ * @param requestOptions - Request options
1479
+ * @returns Updated invoice
1480
+ *
1481
+ * @example
1482
+ * ```typescript
1483
+ * const { data: invoice } = await client.invoices.dispute('invoice-uuid', {
1484
+ * reason: 'Billed amount exceeds agreed price',
1485
+ * dispute_type: 'amount_dispute',
1486
+ * expected_amount: 950.00
1487
+ * });
1488
+ * ```
1489
+ */
1490
+ dispute(id: string, data: DisputeInvoiceInput, requestOptions?: RequestOptions): Promise<SingleResponse<Invoice>>;
1491
+ /**
1492
+ * Mark an incoming invoice as paid
1493
+ *
1494
+ * This is a mandatory step in the French e-invoicing lifecycle for incoming invoices.
1495
+ * Once marked as paid, the invoice status changes to 'paid' and payment details are recorded.
1496
+ *
1497
+ * @param id - Invoice UUID
1498
+ * @param data - Optional payment details (reference, date, note)
1499
+ * @param requestOptions - Request options
1500
+ * @returns Updated invoice with payment information
1501
+ *
1502
+ * @example
1503
+ * ```typescript
1504
+ * // Mark as paid with payment details
1505
+ * const { data: invoice } = await client.invoices.markPaid('invoice-uuid', {
1506
+ * payment_reference: 'VIR-2026-0124',
1507
+ * paid_at: '2026-01-24T10:30:00Z',
1508
+ * note: 'Payment received via bank transfer'
1509
+ * });
1510
+ *
1511
+ * // Simple mark as paid (uses current date/time)
1512
+ * await client.invoices.markPaid('invoice-uuid');
1513
+ * ```
1514
+ */
1515
+ markPaid(id: string, data?: MarkPaidInput, requestOptions?: RequestOptions): Promise<SingleResponse<Invoice>>;
1516
+ /**
1517
+ * Download invoice source file as binary content
1518
+ *
1519
+ * Downloads the original invoice file (PDF with embedded XML for Factur-X,
1520
+ * or standalone XML for UBL/CII formats).
1521
+ *
1522
+ * @param id - Invoice UUID
1523
+ * @param format - File format to download: 'pdf' (default) or 'xml'
1524
+ * @param requestOptions - Request options
1525
+ * @returns ArrayBuffer containing the file content
1526
+ *
1527
+ * @example
1528
+ * ```typescript
1529
+ * // Download invoice as PDF (Factur-X)
1530
+ * const pdfBuffer = await client.invoices.downloadFile('invoice-uuid');
1531
+ *
1532
+ * // In Node.js, save to file:
1533
+ * import { writeFileSync } from 'fs';
1534
+ * writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
1535
+ *
1536
+ * // Download XML version (UBL/CII)
1537
+ * const xmlBuffer = await client.invoices.downloadFile('invoice-uuid', 'xml');
1538
+ * writeFileSync('invoice.xml', Buffer.from(xmlBuffer));
1539
+ *
1540
+ * // In browser, trigger download:
1541
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
1542
+ * const url = URL.createObjectURL(blob);
1543
+ * const a = document.createElement('a');
1544
+ * a.href = url;
1545
+ * a.download = 'invoice.pdf';
1546
+ * a.click();
1547
+ * ```
1548
+ */
1549
+ downloadFile(id: string, format?: InvoiceFileFormat, requestOptions?: RequestOptions): Promise<ArrayBuffer>;
1322
1550
  }
1323
1551
 
1324
1552
  /**
@@ -1627,7 +1855,7 @@ declare class SignaturesResource {
1627
1855
  /**
1628
1856
  * Available webhook events
1629
1857
  */
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';
1858
+ type WebhookEvent = 'invoice.created' | 'invoice.validated' | 'invoice.transmitted' | 'invoice.accepted' | 'invoice.rejected' | 'invoice.error' | 'invoice.incoming.received' | 'invoice.incoming.validated' | 'invoice.incoming.accepted' | 'invoice.incoming.rejected' | 'invoice.incoming.disputed' | 'invoice.incoming.paid' | 'signature.created' | 'signature.waiting' | 'signature.signed' | 'signature.completed' | 'signature.refused' | 'signature.expired' | 'signature.error' | 'balance.low' | 'balance.critical';
1631
1859
  /**
1632
1860
  * Webhook entity
1633
1861
  */
@@ -1739,6 +1967,27 @@ interface BalanceWebhookData {
1739
1967
  currency: string;
1740
1968
  threshold: number;
1741
1969
  }
1970
+ /**
1971
+ * Invoice incoming paid webhook payload data
1972
+ */
1973
+ interface InvoiceIncomingPaidPayload {
1974
+ /** Invoice UUID */
1975
+ invoice_id: string;
1976
+ /** Invoice number */
1977
+ invoice_number: string;
1978
+ /** Seller company name */
1979
+ seller_name: string;
1980
+ /** Seller SIRET (14 digits) */
1981
+ seller_siret: string;
1982
+ /** Total amount including tax */
1983
+ total_amount: number;
1984
+ /** Currency code (ISO 4217) */
1985
+ currency: string;
1986
+ /** Date when the invoice was marked as paid (ISO 8601) */
1987
+ paid_at: string;
1988
+ /** Payment reference (if provided) */
1989
+ payment_reference?: string | undefined;
1990
+ }
1742
1991
 
1743
1992
  /**
1744
1993
  * Webhooks Resource
@@ -2289,4 +2538,4 @@ declare class ScellApiClient {
2289
2538
  constructor(apiKey: string, config?: ClientConfig);
2290
2539
  }
2291
2540
 
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 };
2541
+ export { type AcceptInvoiceInput, 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 DisputeInvoiceInput, type DisputeType, type Environment, type ForgotPasswordInput, type IncomingInvoiceParams, type Invoice, type InvoiceDirection, type InvoiceDownloadResponse, type InvoiceDownloadType, type InvoiceFileFormat, type InvoiceFormat, type InvoiceIncomingPaidPayload, type InvoiceLine, type InvoiceLineInput, type InvoiceListOptions, type InvoiceParty, type InvoiceStatus, type InvoiceWebhookData, type KycInitiateResponse, type KycStatusResponse, type LoginCredentials, type MarkPaidInput, type MessageResponse, type MessageWithDataResponse, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type RegisterInput, type RejectInvoiceInput, type RejectionCode, 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 };
package/dist/index.js CHANGED
@@ -403,6 +403,60 @@ var HttpClient = class {
403
403
  ...options
404
404
  });
405
405
  }
406
+ /**
407
+ * GET request that returns raw binary data as ArrayBuffer
408
+ *
409
+ * Use this for downloading files (PDF, XML, etc.)
410
+ *
411
+ * @param path - API endpoint path
412
+ * @param query - Query parameters
413
+ * @param options - Request options
414
+ * @returns ArrayBuffer containing the file content
415
+ */
416
+ async getRaw(path, query, options) {
417
+ const url = this.buildUrl(path, query);
418
+ const requestHeaders = this.buildHeaders(options?.headers);
419
+ const requestTimeout = options?.timeout ?? this.timeout;
420
+ delete requestHeaders["Content-Type"];
421
+ requestHeaders["Accept"] = "*/*";
422
+ const controller = new AbortController();
423
+ const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
424
+ if (options?.signal) {
425
+ options.signal.addEventListener("abort", () => controller.abort());
426
+ }
427
+ try {
428
+ const response = await this.fetchFn(url, {
429
+ method: "GET",
430
+ headers: requestHeaders,
431
+ signal: controller.signal
432
+ });
433
+ clearTimeout(timeoutId);
434
+ if (!response.ok) {
435
+ const contentType = response.headers.get("Content-Type") ?? "";
436
+ let responseBody;
437
+ if (contentType.includes("application/json")) {
438
+ responseBody = await response.json();
439
+ } else {
440
+ responseBody = await response.text();
441
+ }
442
+ parseApiError(response.status, responseBody, response.headers);
443
+ }
444
+ return response.arrayBuffer();
445
+ } catch (error) {
446
+ clearTimeout(timeoutId);
447
+ if (error instanceof Error) {
448
+ if (error.name === "AbortError") {
449
+ throw new exports.ScellTimeoutError(
450
+ `Request timed out after ${requestTimeout}ms`
451
+ );
452
+ }
453
+ if (error.name === "TypeError" && error.message.includes("fetch")) {
454
+ throw new exports.ScellNetworkError("Network request failed", error);
455
+ }
456
+ }
457
+ throw error;
458
+ }
459
+ }
406
460
  };
407
461
 
408
462
  // src/resources/api-keys.ts
@@ -1137,6 +1191,188 @@ var InvoicesResource = class {
1137
1191
  async convert(input, requestOptions) {
1138
1192
  return this.http.post("/invoices/convert", input, requestOptions);
1139
1193
  }
1194
+ /**
1195
+ * List incoming invoices (from suppliers)
1196
+ *
1197
+ * Returns invoices where your company is the buyer.
1198
+ *
1199
+ * @param params - Filter and pagination options
1200
+ * @param requestOptions - Request options
1201
+ * @returns Paginated list of incoming invoices
1202
+ *
1203
+ * @example
1204
+ * ```typescript
1205
+ * // List all incoming invoices
1206
+ * const { data, meta } = await client.invoices.incoming({
1207
+ * status: 'pending',
1208
+ * per_page: 50
1209
+ * });
1210
+ * console.log(`Found ${meta.total} incoming invoices`);
1211
+ *
1212
+ * // Filter by seller
1213
+ * const fromSupplier = await client.invoices.incoming({
1214
+ * seller_siret: '12345678901234'
1215
+ * });
1216
+ * ```
1217
+ */
1218
+ async incoming(params = {}, requestOptions) {
1219
+ return this.http.get(
1220
+ "/invoices/incoming",
1221
+ params,
1222
+ requestOptions
1223
+ );
1224
+ }
1225
+ /**
1226
+ * Accept an incoming invoice
1227
+ *
1228
+ * Mark an incoming invoice as accepted, optionally specifying a payment date.
1229
+ *
1230
+ * @param id - Invoice UUID
1231
+ * @param data - Optional acceptance data
1232
+ * @param requestOptions - Request options
1233
+ * @returns Updated invoice
1234
+ *
1235
+ * @example
1236
+ * ```typescript
1237
+ * // Accept with payment date
1238
+ * const { data: invoice } = await client.invoices.accept('invoice-uuid', {
1239
+ * payment_date: '2024-02-15',
1240
+ * note: 'Approved by accounting'
1241
+ * });
1242
+ *
1243
+ * // Simple acceptance
1244
+ * await client.invoices.accept('invoice-uuid');
1245
+ * ```
1246
+ */
1247
+ async accept(id, data, requestOptions) {
1248
+ return this.http.post(
1249
+ `/invoices/${id}/accept`,
1250
+ data,
1251
+ requestOptions
1252
+ );
1253
+ }
1254
+ /**
1255
+ * Reject an incoming invoice
1256
+ *
1257
+ * Mark an incoming invoice as rejected with a reason.
1258
+ *
1259
+ * @param id - Invoice UUID
1260
+ * @param data - Rejection details
1261
+ * @param requestOptions - Request options
1262
+ * @returns Updated invoice
1263
+ *
1264
+ * @example
1265
+ * ```typescript
1266
+ * const { data: invoice } = await client.invoices.reject('invoice-uuid', {
1267
+ * reason: 'Invoice amount does not match purchase order',
1268
+ * reason_code: 'incorrect_amount'
1269
+ * });
1270
+ * ```
1271
+ */
1272
+ async reject(id, data, requestOptions) {
1273
+ return this.http.post(
1274
+ `/invoices/${id}/reject`,
1275
+ data,
1276
+ requestOptions
1277
+ );
1278
+ }
1279
+ /**
1280
+ * Dispute an incoming invoice
1281
+ *
1282
+ * Open a dispute on an incoming invoice for resolution.
1283
+ *
1284
+ * @param id - Invoice UUID
1285
+ * @param data - Dispute details
1286
+ * @param requestOptions - Request options
1287
+ * @returns Updated invoice
1288
+ *
1289
+ * @example
1290
+ * ```typescript
1291
+ * const { data: invoice } = await client.invoices.dispute('invoice-uuid', {
1292
+ * reason: 'Billed amount exceeds agreed price',
1293
+ * dispute_type: 'amount_dispute',
1294
+ * expected_amount: 950.00
1295
+ * });
1296
+ * ```
1297
+ */
1298
+ async dispute(id, data, requestOptions) {
1299
+ return this.http.post(
1300
+ `/invoices/${id}/dispute`,
1301
+ data,
1302
+ requestOptions
1303
+ );
1304
+ }
1305
+ /**
1306
+ * Mark an incoming invoice as paid
1307
+ *
1308
+ * This is a mandatory step in the French e-invoicing lifecycle for incoming invoices.
1309
+ * Once marked as paid, the invoice status changes to 'paid' and payment details are recorded.
1310
+ *
1311
+ * @param id - Invoice UUID
1312
+ * @param data - Optional payment details (reference, date, note)
1313
+ * @param requestOptions - Request options
1314
+ * @returns Updated invoice with payment information
1315
+ *
1316
+ * @example
1317
+ * ```typescript
1318
+ * // Mark as paid with payment details
1319
+ * const { data: invoice } = await client.invoices.markPaid('invoice-uuid', {
1320
+ * payment_reference: 'VIR-2026-0124',
1321
+ * paid_at: '2026-01-24T10:30:00Z',
1322
+ * note: 'Payment received via bank transfer'
1323
+ * });
1324
+ *
1325
+ * // Simple mark as paid (uses current date/time)
1326
+ * await client.invoices.markPaid('invoice-uuid');
1327
+ * ```
1328
+ */
1329
+ async markPaid(id, data, requestOptions) {
1330
+ return this.http.post(
1331
+ `/invoices/${id}/mark-paid`,
1332
+ data,
1333
+ requestOptions
1334
+ );
1335
+ }
1336
+ /**
1337
+ * Download invoice source file as binary content
1338
+ *
1339
+ * Downloads the original invoice file (PDF with embedded XML for Factur-X,
1340
+ * or standalone XML for UBL/CII formats).
1341
+ *
1342
+ * @param id - Invoice UUID
1343
+ * @param format - File format to download: 'pdf' (default) or 'xml'
1344
+ * @param requestOptions - Request options
1345
+ * @returns ArrayBuffer containing the file content
1346
+ *
1347
+ * @example
1348
+ * ```typescript
1349
+ * // Download invoice as PDF (Factur-X)
1350
+ * const pdfBuffer = await client.invoices.downloadFile('invoice-uuid');
1351
+ *
1352
+ * // In Node.js, save to file:
1353
+ * import { writeFileSync } from 'fs';
1354
+ * writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
1355
+ *
1356
+ * // Download XML version (UBL/CII)
1357
+ * const xmlBuffer = await client.invoices.downloadFile('invoice-uuid', 'xml');
1358
+ * writeFileSync('invoice.xml', Buffer.from(xmlBuffer));
1359
+ *
1360
+ * // In browser, trigger download:
1361
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
1362
+ * const url = URL.createObjectURL(blob);
1363
+ * const a = document.createElement('a');
1364
+ * a.href = url;
1365
+ * a.download = 'invoice.pdf';
1366
+ * a.click();
1367
+ * ```
1368
+ */
1369
+ async downloadFile(id, format = "pdf", requestOptions) {
1370
+ return this.http.getRaw(
1371
+ `/invoices/${id}/download`,
1372
+ { format },
1373
+ requestOptions
1374
+ );
1375
+ }
1140
1376
  };
1141
1377
 
1142
1378
  // src/resources/signatures.ts