@pimia/sdk 0.5.0 → 0.7.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/README.md +50 -0
- package/dist/api.d.ts +9926 -5013
- package/dist/api.js +4 -0
- package/dist/client.d.ts +244 -145
- package/dist/client.js +160 -4
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/package.json +2 -2
package/dist/api.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by openapi-typescript.
|
|
3
3
|
* Do not make direct changes to the file.
|
|
4
|
+
*
|
|
5
|
+
* Generado con `npm run generate:types` (scripts/generate-types.mjs), que
|
|
6
|
+
* añade UN transform al generador: `format: binary` sale como `Blob` y no
|
|
7
|
+
* como `string`. El porqué, en ese fichero.
|
|
4
8
|
*/
|
|
5
9
|
export {};
|
package/dist/client.d.ts
CHANGED
|
@@ -64,8 +64,43 @@ export interface RequestOptions {
|
|
|
64
64
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
65
65
|
/** Query string. Los `undefined`/`null` se omiten; los arrays se repiten. */
|
|
66
66
|
query?: Record<string, string | number | boolean | undefined | null | Array<string | number>>;
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* El cuerpo de la petición.
|
|
69
|
+
*
|
|
70
|
+
* Por defecto se manda como **JSON**, que es lo que pide casi toda la API.
|
|
71
|
+
*
|
|
72
|
+
* Diez operaciones del contrato son `multipart/form-data` —el justificante
|
|
73
|
+
* de un gasto, el documento de una factura recibida, importar un extracto
|
|
74
|
+
* bancario, el membrete de una plantilla, el certificado de firma…—, y para
|
|
75
|
+
* ésas se pasa un {@link FormData}: el cliente lo manda **tal cual** y **no
|
|
76
|
+
* le pone `content-type`**, para que el runtime escriba el suyo con su
|
|
77
|
+
* `boundary`. {@link toFormData} lo arma con las conversiones que el
|
|
78
|
+
* servidor espera.
|
|
79
|
+
*
|
|
80
|
+
* También pasan sin tocar `Blob`, `URLSearchParams`, `ArrayBuffer` y las
|
|
81
|
+
* vistas de `ArrayBuffer`.
|
|
82
|
+
*
|
|
83
|
+
* ⛔ Un `ReadableStream` **no**, y es a propósito: este cliente reintenta
|
|
84
|
+
* ante un 401 (tras refrescar) y ante un 429, y un stream ya consumido no se
|
|
85
|
+
* puede volver a mandar — el reintento fallaría con un error que no se
|
|
86
|
+
* parece en nada a su causa. Los cinco de arriba se pueden releer.
|
|
87
|
+
*/
|
|
68
88
|
body?: unknown;
|
|
89
|
+
/**
|
|
90
|
+
* Cómo leer una respuesta **correcta**.
|
|
91
|
+
*
|
|
92
|
+
* `'json'` (el defecto) es lo de siempre. `'blob'` es para las dos
|
|
93
|
+
* operaciones que devuelven un fichero (`application/octet-stream`):
|
|
94
|
+
* descargar el membrete de una plantilla y el documento escaneado de una
|
|
95
|
+
* factura recibida.
|
|
96
|
+
*
|
|
97
|
+
* ⚠️ Sin esto, un PDF se lee con `response.text()` y **se corrompe en
|
|
98
|
+
* silencio**: el fichero «llega», pesa lo suyo y no se abre.
|
|
99
|
+
*
|
|
100
|
+
* Los errores se siguen leyendo como JSON aunque pidas `'blob'` — cuando la
|
|
101
|
+
* API falla contesta su sobre de error, no el fichero.
|
|
102
|
+
*/
|
|
103
|
+
responseType?: 'json' | 'blob';
|
|
69
104
|
headers?: Record<string, string>;
|
|
70
105
|
signal?: AbortSignal;
|
|
71
106
|
/**
|
|
@@ -146,6 +181,11 @@ export declare class PimiaClient {
|
|
|
146
181
|
meta: {
|
|
147
182
|
invoice_total_count: number;
|
|
148
183
|
};
|
|
184
|
+
} | {
|
|
185
|
+
data: components["schemas"]["InvoiceSummaryResource"][];
|
|
186
|
+
meta: {
|
|
187
|
+
invoice_total_count: number;
|
|
188
|
+
};
|
|
149
189
|
}>;
|
|
150
190
|
get: (id: number | string, options?: ReadOptions) => Promise<{
|
|
151
191
|
data: components["schemas"]["InvoiceResource"] & Record<string, never>;
|
|
@@ -155,175 +195,177 @@ export declare class PimiaClient {
|
|
|
155
195
|
* `200` de `invoices.store` está vacío ahí (ver {@link ResourceEnvelope}).
|
|
156
196
|
*/
|
|
157
197
|
create: (body: InvoicesRequest, options?: WriteOptions) => Promise<ResourceEnvelope<{
|
|
158
|
-
id:
|
|
198
|
+
id: number;
|
|
159
199
|
invoice_date: string;
|
|
160
|
-
due_date: string;
|
|
161
|
-
invoice_number: string;
|
|
200
|
+
due_date: string | null;
|
|
201
|
+
invoice_number: string | null;
|
|
162
202
|
reference_number: string;
|
|
163
203
|
status: string;
|
|
164
204
|
paid_status: string;
|
|
165
205
|
tax_per_item: string;
|
|
166
206
|
tax_included: string;
|
|
167
207
|
discount_per_item: string;
|
|
168
|
-
notes: string;
|
|
169
|
-
discount_type: string;
|
|
170
|
-
discount:
|
|
171
|
-
discount_val:
|
|
172
|
-
sub_total:
|
|
173
|
-
total:
|
|
208
|
+
notes: string | null;
|
|
209
|
+
discount_type: string | null;
|
|
210
|
+
discount: number;
|
|
211
|
+
discount_val: number;
|
|
212
|
+
sub_total: number;
|
|
213
|
+
total: number;
|
|
174
214
|
effective_total: string;
|
|
175
|
-
tax:
|
|
215
|
+
tax: number;
|
|
176
216
|
due_amount: string;
|
|
177
217
|
effective_due_amount: string;
|
|
178
218
|
sent: string;
|
|
179
219
|
viewed: string;
|
|
180
|
-
|
|
181
|
-
|
|
220
|
+
sent_at: string;
|
|
221
|
+
viewed_at: string;
|
|
222
|
+
unique_hash: string | null;
|
|
223
|
+
template_name: string | null;
|
|
182
224
|
invoice_series_id: string;
|
|
183
|
-
customer_id:
|
|
225
|
+
customer_id: number | null;
|
|
184
226
|
external_ref: string | null;
|
|
185
227
|
payment_method_id: string;
|
|
186
228
|
recurring_invoice_id: string;
|
|
187
|
-
sequence_number:
|
|
188
|
-
exchange_rate:
|
|
189
|
-
base_discount_val: string;
|
|
190
|
-
base_sub_total: string;
|
|
191
|
-
base_total: string;
|
|
192
|
-
creator_id:
|
|
193
|
-
base_tax: string;
|
|
194
|
-
base_due_amount: string;
|
|
229
|
+
sequence_number: number | null;
|
|
230
|
+
exchange_rate: number | null;
|
|
231
|
+
base_discount_val: string | null;
|
|
232
|
+
base_sub_total: string | null;
|
|
233
|
+
base_total: string | null;
|
|
234
|
+
creator_id: number | null;
|
|
235
|
+
base_tax: string | null;
|
|
236
|
+
base_due_amount: string | null;
|
|
195
237
|
effective_base_total: string;
|
|
196
238
|
effective_base_due_amount: string;
|
|
197
239
|
credited_total: string;
|
|
198
240
|
credited_base_total: string;
|
|
199
|
-
currency_id:
|
|
241
|
+
currency_id: number | null;
|
|
200
242
|
formatted_created_at: string;
|
|
201
243
|
invoice_pdf_url: string;
|
|
202
244
|
formatted_invoice_date: string;
|
|
203
245
|
formatted_due_date: string;
|
|
204
246
|
allow_edit: string;
|
|
205
247
|
payment_module_enabled: string;
|
|
206
|
-
sales_tax_type: string;
|
|
207
|
-
sales_tax_address_type: string;
|
|
208
248
|
overdue: string;
|
|
209
249
|
effective_paid_status: string;
|
|
210
250
|
effective_overdue: string;
|
|
211
251
|
aeat_status: string;
|
|
212
|
-
qr_data: string;
|
|
213
|
-
hash: string;
|
|
214
|
-
aeat_csv: string;
|
|
215
|
-
is_credit_note:
|
|
216
|
-
rectified_invoice_id:
|
|
252
|
+
qr_data: string | null;
|
|
253
|
+
hash: string | null;
|
|
254
|
+
aeat_csv: string | null;
|
|
255
|
+
is_credit_note: boolean;
|
|
256
|
+
rectified_invoice_id: number | null;
|
|
217
257
|
rectified_invoice_number?: string | null;
|
|
218
258
|
rectified_invoice?: {
|
|
219
|
-
id:
|
|
220
|
-
invoice_number: string;
|
|
259
|
+
id: number;
|
|
260
|
+
invoice_number: string | null;
|
|
221
261
|
tax_per_item: string;
|
|
222
262
|
tax_included: string;
|
|
223
|
-
sub_total:
|
|
224
|
-
discount_val:
|
|
225
|
-
tax:
|
|
226
|
-
total:
|
|
263
|
+
sub_total: number;
|
|
264
|
+
discount_val: number;
|
|
265
|
+
tax: number;
|
|
266
|
+
total: number;
|
|
227
267
|
items: components["schemas"]["InvoiceItemResource"][];
|
|
228
268
|
taxes: components["schemas"]["TaxResource"][];
|
|
229
269
|
};
|
|
230
|
-
credit_notes_count: number;
|
|
270
|
+
credit_notes_count: string | number;
|
|
231
271
|
items?: components["schemas"]["InvoiceItemResource"][];
|
|
232
272
|
payments?: components["schemas"]["PaymentResource"][];
|
|
233
|
-
|
|
273
|
+
email_logs?: components["schemas"]["EmailLogResource"][];
|
|
274
|
+
customer?: components["schemas"]["CustomerResource"] | null;
|
|
234
275
|
invoice_series?: components["schemas"]["InvoiceSeriesResource"];
|
|
235
276
|
payment_method?: components["schemas"]["PaymentMethodResource"];
|
|
236
|
-
creator?: components["schemas"]["UserResource"];
|
|
277
|
+
creator?: components["schemas"]["UserResource"] | null;
|
|
237
278
|
taxes: components["schemas"]["TaxResource"][];
|
|
238
279
|
fields?: components["schemas"]["CustomFieldValueResource"][];
|
|
239
|
-
company?: components["schemas"]["CompanyResource"];
|
|
240
|
-
currency?: components["schemas"]["CurrencyResource"];
|
|
280
|
+
company?: components["schemas"]["CompanyResource"] | null;
|
|
281
|
+
currency?: components["schemas"]["CurrencyResource"] | null;
|
|
241
282
|
}>>;
|
|
242
283
|
/** Mismo caso que `create`: el `200` de `invoices.update` no está tipado en el spec. */
|
|
243
284
|
update: (id: number | string, body: InvoicesRequest, options?: WriteOptions) => Promise<ResourceEnvelope<{
|
|
244
|
-
id:
|
|
285
|
+
id: number;
|
|
245
286
|
invoice_date: string;
|
|
246
|
-
due_date: string;
|
|
247
|
-
invoice_number: string;
|
|
287
|
+
due_date: string | null;
|
|
288
|
+
invoice_number: string | null;
|
|
248
289
|
reference_number: string;
|
|
249
290
|
status: string;
|
|
250
291
|
paid_status: string;
|
|
251
292
|
tax_per_item: string;
|
|
252
293
|
tax_included: string;
|
|
253
294
|
discount_per_item: string;
|
|
254
|
-
notes: string;
|
|
255
|
-
discount_type: string;
|
|
256
|
-
discount:
|
|
257
|
-
discount_val:
|
|
258
|
-
sub_total:
|
|
259
|
-
total:
|
|
295
|
+
notes: string | null;
|
|
296
|
+
discount_type: string | null;
|
|
297
|
+
discount: number;
|
|
298
|
+
discount_val: number;
|
|
299
|
+
sub_total: number;
|
|
300
|
+
total: number;
|
|
260
301
|
effective_total: string;
|
|
261
|
-
tax:
|
|
302
|
+
tax: number;
|
|
262
303
|
due_amount: string;
|
|
263
304
|
effective_due_amount: string;
|
|
264
305
|
sent: string;
|
|
265
306
|
viewed: string;
|
|
266
|
-
|
|
267
|
-
|
|
307
|
+
sent_at: string;
|
|
308
|
+
viewed_at: string;
|
|
309
|
+
unique_hash: string | null;
|
|
310
|
+
template_name: string | null;
|
|
268
311
|
invoice_series_id: string;
|
|
269
|
-
customer_id:
|
|
312
|
+
customer_id: number | null;
|
|
270
313
|
external_ref: string | null;
|
|
271
314
|
payment_method_id: string;
|
|
272
315
|
recurring_invoice_id: string;
|
|
273
|
-
sequence_number:
|
|
274
|
-
exchange_rate:
|
|
275
|
-
base_discount_val: string;
|
|
276
|
-
base_sub_total: string;
|
|
277
|
-
base_total: string;
|
|
278
|
-
creator_id:
|
|
279
|
-
base_tax: string;
|
|
280
|
-
base_due_amount: string;
|
|
316
|
+
sequence_number: number | null;
|
|
317
|
+
exchange_rate: number | null;
|
|
318
|
+
base_discount_val: string | null;
|
|
319
|
+
base_sub_total: string | null;
|
|
320
|
+
base_total: string | null;
|
|
321
|
+
creator_id: number | null;
|
|
322
|
+
base_tax: string | null;
|
|
323
|
+
base_due_amount: string | null;
|
|
281
324
|
effective_base_total: string;
|
|
282
325
|
effective_base_due_amount: string;
|
|
283
326
|
credited_total: string;
|
|
284
327
|
credited_base_total: string;
|
|
285
|
-
currency_id:
|
|
328
|
+
currency_id: number | null;
|
|
286
329
|
formatted_created_at: string;
|
|
287
330
|
invoice_pdf_url: string;
|
|
288
331
|
formatted_invoice_date: string;
|
|
289
332
|
formatted_due_date: string;
|
|
290
333
|
allow_edit: string;
|
|
291
334
|
payment_module_enabled: string;
|
|
292
|
-
sales_tax_type: string;
|
|
293
|
-
sales_tax_address_type: string;
|
|
294
335
|
overdue: string;
|
|
295
336
|
effective_paid_status: string;
|
|
296
337
|
effective_overdue: string;
|
|
297
338
|
aeat_status: string;
|
|
298
|
-
qr_data: string;
|
|
299
|
-
hash: string;
|
|
300
|
-
aeat_csv: string;
|
|
301
|
-
is_credit_note:
|
|
302
|
-
rectified_invoice_id:
|
|
339
|
+
qr_data: string | null;
|
|
340
|
+
hash: string | null;
|
|
341
|
+
aeat_csv: string | null;
|
|
342
|
+
is_credit_note: boolean;
|
|
343
|
+
rectified_invoice_id: number | null;
|
|
303
344
|
rectified_invoice_number?: string | null;
|
|
304
345
|
rectified_invoice?: {
|
|
305
|
-
id:
|
|
306
|
-
invoice_number: string;
|
|
346
|
+
id: number;
|
|
347
|
+
invoice_number: string | null;
|
|
307
348
|
tax_per_item: string;
|
|
308
349
|
tax_included: string;
|
|
309
|
-
sub_total:
|
|
310
|
-
discount_val:
|
|
311
|
-
tax:
|
|
312
|
-
total:
|
|
350
|
+
sub_total: number;
|
|
351
|
+
discount_val: number;
|
|
352
|
+
tax: number;
|
|
353
|
+
total: number;
|
|
313
354
|
items: components["schemas"]["InvoiceItemResource"][];
|
|
314
355
|
taxes: components["schemas"]["TaxResource"][];
|
|
315
356
|
};
|
|
316
|
-
credit_notes_count: number;
|
|
357
|
+
credit_notes_count: string | number;
|
|
317
358
|
items?: components["schemas"]["InvoiceItemResource"][];
|
|
318
359
|
payments?: components["schemas"]["PaymentResource"][];
|
|
319
|
-
|
|
360
|
+
email_logs?: components["schemas"]["EmailLogResource"][];
|
|
361
|
+
customer?: components["schemas"]["CustomerResource"] | null;
|
|
320
362
|
invoice_series?: components["schemas"]["InvoiceSeriesResource"];
|
|
321
363
|
payment_method?: components["schemas"]["PaymentMethodResource"];
|
|
322
|
-
creator?: components["schemas"]["UserResource"];
|
|
364
|
+
creator?: components["schemas"]["UserResource"] | null;
|
|
323
365
|
taxes: components["schemas"]["TaxResource"][];
|
|
324
366
|
fields?: components["schemas"]["CustomFieldValueResource"][];
|
|
325
|
-
company?: components["schemas"]["CompanyResource"];
|
|
326
|
-
currency?: components["schemas"]["CurrencyResource"];
|
|
367
|
+
company?: components["schemas"]["CompanyResource"] | null;
|
|
368
|
+
currency?: components["schemas"]["CurrencyResource"] | null;
|
|
327
369
|
}>>;
|
|
328
370
|
};
|
|
329
371
|
get customers(): {
|
|
@@ -332,6 +374,11 @@ export declare class PimiaClient {
|
|
|
332
374
|
meta: {
|
|
333
375
|
customer_total_count: number;
|
|
334
376
|
};
|
|
377
|
+
} | {
|
|
378
|
+
data: components["schemas"]["CustomerSummaryResource"][];
|
|
379
|
+
meta: {
|
|
380
|
+
customer_total_count: number;
|
|
381
|
+
};
|
|
335
382
|
}>;
|
|
336
383
|
get: (id: number | string, options?: ReadOptions) => Promise<{
|
|
337
384
|
data: components["schemas"]["CustomerResource"];
|
|
@@ -341,40 +388,36 @@ export declare class PimiaClient {
|
|
|
341
388
|
}>;
|
|
342
389
|
/** El `200` de `customers.update` no está tipado en el spec. */
|
|
343
390
|
update: (id: number | string, body: CustomerRequest, options?: WriteOptions) => Promise<ResourceEnvelope<{
|
|
344
|
-
id:
|
|
391
|
+
id: number;
|
|
345
392
|
name: string;
|
|
346
|
-
email: string;
|
|
347
|
-
phone: string;
|
|
348
|
-
contact_name: string;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
enable_portal: string;
|
|
393
|
+
email: string | null;
|
|
394
|
+
phone: string | null;
|
|
395
|
+
contact_name: string | null;
|
|
396
|
+
website: string | null;
|
|
397
|
+
enable_portal: boolean;
|
|
352
398
|
password_added: boolean;
|
|
353
|
-
currency_id:
|
|
399
|
+
currency_id: number | null;
|
|
354
400
|
payment_method_id: string;
|
|
355
|
-
company_id:
|
|
356
|
-
|
|
357
|
-
google_id: string;
|
|
358
|
-
github_id: string;
|
|
359
|
-
created_at: string;
|
|
401
|
+
company_id: number | null;
|
|
402
|
+
created_at: string | null;
|
|
360
403
|
formatted_created_at: string;
|
|
361
|
-
updated_at: string;
|
|
404
|
+
updated_at: string | null;
|
|
362
405
|
avatar: string;
|
|
363
406
|
due_amount: string;
|
|
364
407
|
base_due_amount: string;
|
|
365
|
-
prefix: string;
|
|
408
|
+
prefix: string | null;
|
|
366
409
|
tax_id: string;
|
|
367
410
|
notes: string;
|
|
368
411
|
external_ref: string | null;
|
|
369
|
-
iban: string;
|
|
370
|
-
bic: string;
|
|
371
|
-
sepa_mandate_id: string;
|
|
372
|
-
sepa_mandate_date: string;
|
|
373
|
-
billing?: components["schemas"]["AddressResource"];
|
|
374
|
-
shipping?: components["schemas"]["AddressResource"];
|
|
412
|
+
iban: string | null;
|
|
413
|
+
bic: string | null;
|
|
414
|
+
sepa_mandate_id: string | null;
|
|
415
|
+
sepa_mandate_date: string | null;
|
|
416
|
+
billing?: components["schemas"]["AddressResource"] | null;
|
|
417
|
+
shipping?: components["schemas"]["AddressResource"] | null;
|
|
375
418
|
fields?: components["schemas"]["CustomFieldValueResource"][];
|
|
376
|
-
company?: components["schemas"]["CompanyResource"];
|
|
377
|
-
currency?: components["schemas"]["CurrencyResource"];
|
|
419
|
+
company?: components["schemas"]["CompanyResource"] | null;
|
|
420
|
+
currency?: components["schemas"]["CurrencyResource"] | null;
|
|
378
421
|
payment_method?: components["schemas"]["PaymentMethodResource"];
|
|
379
422
|
}>>;
|
|
380
423
|
};
|
|
@@ -384,9 +427,14 @@ export declare class PimiaClient {
|
|
|
384
427
|
meta: {
|
|
385
428
|
estimate_total_count: number;
|
|
386
429
|
};
|
|
430
|
+
} | {
|
|
431
|
+
data: components["schemas"]["EstimateSummaryResource"][];
|
|
432
|
+
meta: {
|
|
433
|
+
estimate_total_count: number;
|
|
434
|
+
};
|
|
387
435
|
}>;
|
|
388
436
|
get: (id: number | string, options?: ReadOptions) => Promise<{
|
|
389
|
-
data: components["schemas"]["EstimateResource"]
|
|
437
|
+
data: components["schemas"]["EstimateResource"] & Record<string, never>;
|
|
390
438
|
}>;
|
|
391
439
|
create: (body: EstimatesRequest, options?: WriteOptions) => Promise<{
|
|
392
440
|
data: components["schemas"]["EstimateResource"];
|
|
@@ -427,89 +475,90 @@ export declare class PimiaClient {
|
|
|
427
475
|
convertToInvoice: (id: number | string, options?: WriteOptions & {
|
|
428
476
|
externalRef?: string | null;
|
|
429
477
|
}) => Promise<ResourceEnvelope<{
|
|
430
|
-
id:
|
|
478
|
+
id: number;
|
|
431
479
|
invoice_date: string;
|
|
432
|
-
due_date: string;
|
|
433
|
-
invoice_number: string;
|
|
480
|
+
due_date: string | null;
|
|
481
|
+
invoice_number: string | null;
|
|
434
482
|
reference_number: string;
|
|
435
483
|
status: string;
|
|
436
484
|
paid_status: string;
|
|
437
485
|
tax_per_item: string;
|
|
438
486
|
tax_included: string;
|
|
439
487
|
discount_per_item: string;
|
|
440
|
-
notes: string;
|
|
441
|
-
discount_type: string;
|
|
442
|
-
discount:
|
|
443
|
-
discount_val:
|
|
444
|
-
sub_total:
|
|
445
|
-
total:
|
|
488
|
+
notes: string | null;
|
|
489
|
+
discount_type: string | null;
|
|
490
|
+
discount: number;
|
|
491
|
+
discount_val: number;
|
|
492
|
+
sub_total: number;
|
|
493
|
+
total: number;
|
|
446
494
|
effective_total: string;
|
|
447
|
-
tax:
|
|
495
|
+
tax: number;
|
|
448
496
|
due_amount: string;
|
|
449
497
|
effective_due_amount: string;
|
|
450
498
|
sent: string;
|
|
451
499
|
viewed: string;
|
|
452
|
-
|
|
453
|
-
|
|
500
|
+
sent_at: string;
|
|
501
|
+
viewed_at: string;
|
|
502
|
+
unique_hash: string | null;
|
|
503
|
+
template_name: string | null;
|
|
454
504
|
invoice_series_id: string;
|
|
455
|
-
customer_id:
|
|
505
|
+
customer_id: number | null;
|
|
456
506
|
external_ref: string | null;
|
|
457
507
|
payment_method_id: string;
|
|
458
508
|
recurring_invoice_id: string;
|
|
459
|
-
sequence_number:
|
|
460
|
-
exchange_rate:
|
|
461
|
-
base_discount_val: string;
|
|
462
|
-
base_sub_total: string;
|
|
463
|
-
base_total: string;
|
|
464
|
-
creator_id:
|
|
465
|
-
base_tax: string;
|
|
466
|
-
base_due_amount: string;
|
|
509
|
+
sequence_number: number | null;
|
|
510
|
+
exchange_rate: number | null;
|
|
511
|
+
base_discount_val: string | null;
|
|
512
|
+
base_sub_total: string | null;
|
|
513
|
+
base_total: string | null;
|
|
514
|
+
creator_id: number | null;
|
|
515
|
+
base_tax: string | null;
|
|
516
|
+
base_due_amount: string | null;
|
|
467
517
|
effective_base_total: string;
|
|
468
518
|
effective_base_due_amount: string;
|
|
469
519
|
credited_total: string;
|
|
470
520
|
credited_base_total: string;
|
|
471
|
-
currency_id:
|
|
521
|
+
currency_id: number | null;
|
|
472
522
|
formatted_created_at: string;
|
|
473
523
|
invoice_pdf_url: string;
|
|
474
524
|
formatted_invoice_date: string;
|
|
475
525
|
formatted_due_date: string;
|
|
476
526
|
allow_edit: string;
|
|
477
527
|
payment_module_enabled: string;
|
|
478
|
-
sales_tax_type: string;
|
|
479
|
-
sales_tax_address_type: string;
|
|
480
528
|
overdue: string;
|
|
481
529
|
effective_paid_status: string;
|
|
482
530
|
effective_overdue: string;
|
|
483
531
|
aeat_status: string;
|
|
484
|
-
qr_data: string;
|
|
485
|
-
hash: string;
|
|
486
|
-
aeat_csv: string;
|
|
487
|
-
is_credit_note:
|
|
488
|
-
rectified_invoice_id:
|
|
532
|
+
qr_data: string | null;
|
|
533
|
+
hash: string | null;
|
|
534
|
+
aeat_csv: string | null;
|
|
535
|
+
is_credit_note: boolean;
|
|
536
|
+
rectified_invoice_id: number | null;
|
|
489
537
|
rectified_invoice_number?: string | null;
|
|
490
538
|
rectified_invoice?: {
|
|
491
|
-
id:
|
|
492
|
-
invoice_number: string;
|
|
539
|
+
id: number;
|
|
540
|
+
invoice_number: string | null;
|
|
493
541
|
tax_per_item: string;
|
|
494
542
|
tax_included: string;
|
|
495
|
-
sub_total:
|
|
496
|
-
discount_val:
|
|
497
|
-
tax:
|
|
498
|
-
total:
|
|
543
|
+
sub_total: number;
|
|
544
|
+
discount_val: number;
|
|
545
|
+
tax: number;
|
|
546
|
+
total: number;
|
|
499
547
|
items: components["schemas"]["InvoiceItemResource"][];
|
|
500
548
|
taxes: components["schemas"]["TaxResource"][];
|
|
501
549
|
};
|
|
502
|
-
credit_notes_count: number;
|
|
550
|
+
credit_notes_count: string | number;
|
|
503
551
|
items?: components["schemas"]["InvoiceItemResource"][];
|
|
504
552
|
payments?: components["schemas"]["PaymentResource"][];
|
|
505
|
-
|
|
553
|
+
email_logs?: components["schemas"]["EmailLogResource"][];
|
|
554
|
+
customer?: components["schemas"]["CustomerResource"] | null;
|
|
506
555
|
invoice_series?: components["schemas"]["InvoiceSeriesResource"];
|
|
507
556
|
payment_method?: components["schemas"]["PaymentMethodResource"];
|
|
508
|
-
creator?: components["schemas"]["UserResource"];
|
|
557
|
+
creator?: components["schemas"]["UserResource"] | null;
|
|
509
558
|
taxes: components["schemas"]["TaxResource"][];
|
|
510
559
|
fields?: components["schemas"]["CustomFieldValueResource"][];
|
|
511
|
-
company?: components["schemas"]["CompanyResource"];
|
|
512
|
-
currency?: components["schemas"]["CurrencyResource"];
|
|
560
|
+
company?: components["schemas"]["CompanyResource"] | null;
|
|
561
|
+
currency?: components["schemas"]["CurrencyResource"] | null;
|
|
513
562
|
}>>;
|
|
514
563
|
};
|
|
515
564
|
get<T = unknown>(path: string, query?: RequestOptions['query'], options?: ReadOptions): Promise<T>;
|
|
@@ -517,6 +566,25 @@ export declare class PimiaClient {
|
|
|
517
566
|
put<T = unknown>(path: string, body?: unknown, options?: WriteOptions): Promise<T>;
|
|
518
567
|
patch<T = unknown>(path: string, body?: unknown, options?: WriteOptions): Promise<T>;
|
|
519
568
|
delete<T = unknown>(path: string, options?: ReadOptions): Promise<T>;
|
|
569
|
+
/**
|
|
570
|
+
* Descarga un fichero de la API y te lo da como `Blob`.
|
|
571
|
+
*
|
|
572
|
+
* Son dos operaciones: el membrete de una plantilla
|
|
573
|
+
* (`GET /invoice-templates/{id}/letterhead`) y el documento escaneado de una
|
|
574
|
+
* factura recibida (`GET /received-invoices/{id}/show/document`).
|
|
575
|
+
*
|
|
576
|
+
* Existe porque `get()` **corrompe un binario sin decirlo**: lee la
|
|
577
|
+
* respuesta con `response.text()`, y un PDF pasado por ahí llega entero de
|
|
578
|
+
* tamaño y no se abre. Ese es el peor final posible para una descarga, así
|
|
579
|
+
* que la forma correcta tiene nombre propio en vez de ser una bandera que
|
|
580
|
+
* hay que acordarse de poner.
|
|
581
|
+
*
|
|
582
|
+
* ```ts
|
|
583
|
+
* const pdf = await client.download(`/received-invoices/${id}/show/document`)
|
|
584
|
+
* const url = URL.createObjectURL(pdf)
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
download(path: string, query?: RequestOptions['query'], options?: ReadOptions): Promise<Blob>;
|
|
520
588
|
/**
|
|
521
589
|
* Petición cruda contra `/api/v1`. `path` puede llevar el prefijo o no:
|
|
522
590
|
* `/invoices` y `/api/v1/invoices` son lo mismo.
|
|
@@ -551,4 +619,35 @@ export declare class PimiaClient {
|
|
|
551
619
|
private captureRateLimit;
|
|
552
620
|
private retryDelay;
|
|
553
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Arma el `FormData` de una operación multipart con las conversiones que el
|
|
624
|
+
* servidor de Pimia espera, que **no** son las que hace `FormData` sola.
|
|
625
|
+
*
|
|
626
|
+
* Tres reglas, y las tres salen del contrato, no de la costumbre:
|
|
627
|
+
*
|
|
628
|
+
* - **Los booleanos viajan como `1` y `0`.** Lo dice el propio spec en
|
|
629
|
+
* `ExpenseRequest.is_attachment_receipt_removed`: «en `multipart/form-data`
|
|
630
|
+
* viaja como `1` o `0`». Un `String(false)` daría `"false"`, que PHP lee
|
|
631
|
+
* como verdadero.
|
|
632
|
+
* - **Los objetos y arrays viajan como JSON en una cadena.** También del
|
|
633
|
+
* spec, en `ExpenseRequest.customFields`: «viaja como cadena JSON:
|
|
634
|
+
* `[{"id":3,"value":"REF-42"}]`».
|
|
635
|
+
* - **`null` y `undefined` se omiten**, en vez de mandar `"null"`. Un campo
|
|
636
|
+
* ausente es un campo ausente; la cadena `"null"` es un valor.
|
|
637
|
+
*
|
|
638
|
+
* Un `Blob` o un `File` se añaden tal cual. Con un `File` el runtime manda ya
|
|
639
|
+
* su nombre; con un `Blob` suelto se puede dar uno pasando `[blob, 'x.pdf']`,
|
|
640
|
+
* que es la forma que el tercer argumento de `append` admite.
|
|
641
|
+
*
|
|
642
|
+
* ```ts
|
|
643
|
+
* await client.post('/expenses', toFormData({
|
|
644
|
+
* expense_date: '2026-08-24',
|
|
645
|
+
* expense_category_id: 3,
|
|
646
|
+
* amount: 12100,
|
|
647
|
+
* attachment_receipt: ficheroPdf,
|
|
648
|
+
* customFields: [{ id: 3, value: 'REF-42' }],
|
|
649
|
+
* }))
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
export declare function toFormData(fields: Record<string, unknown | [Blob, string]>): FormData;
|
|
554
653
|
export {};
|