@beel_es/sdk 2.0.0 → 2.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/CHANGELOG.md +244 -0
- package/README.md +216 -25
- package/dist/index.d.mts +1480 -185
- package/dist/index.d.ts +1480 -185
- package/dist/index.js +1419 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1416 -187
- package/dist/index.mjs.map +1 -1
- package/docs/reference/README.md +233 -0
- package/docs/reference/account-companies.md +55 -0
- package/docs/reference/account-invitations.md +57 -0
- package/docs/reference/account-members.md +97 -0
- package/docs/reference/account-webhooks.md +123 -0
- package/docs/reference/account.md +94 -0
- package/docs/reference/accounts.md +72 -0
- package/docs/reference/catalogs.md +68 -0
- package/docs/reference/client.md +113 -0
- package/docs/reference/company-customers.md +85 -0
- package/docs/reference/company-invoices-schedule.md +52 -0
- package/docs/reference/company-invoices.md +316 -0
- package/docs/reference/company-payment-connections-events.md +103 -0
- package/docs/reference/company-payment-connections.md +87 -0
- package/docs/reference/company-products.md +72 -0
- package/docs/reference/company-recurring-invoices.md +136 -0
- package/docs/reference/company-series.md +94 -0
- package/docs/reference/company-tax-configuration.md +36 -0
- package/docs/reference/company-verifactu-configuration.md +41 -0
- package/docs/reference/company.md +94 -0
- package/docs/reference/configuration.md +90 -0
- package/docs/reference/customer-builder.md +107 -0
- package/docs/reference/customers.md +91 -0
- package/docs/reference/errors.md +72 -0
- package/docs/reference/invoice-builder.md +149 -0
- package/docs/reference/invoices.md +250 -0
- package/docs/reference/nif.md +31 -0
- package/docs/reference/products.md +111 -0
- package/docs/reference/series.md +81 -0
- package/docs/reference/types.md +222 -0
- package/docs/reference/webhook-verifier.md +95 -0
- package/llms.txt +52 -0
- package/package.json +10 -4
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<!-- Generated by `npm run docs:reference` from the SDK source and openapi/public-api.yaml. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
# `beel.customers` — `CustomersResource`
|
|
4
|
+
|
|
5
|
+
[Reference index](README.md)
|
|
6
|
+
|
|
7
|
+
> **Deprecated.** The contract deprecates the session-focus routes. Use `beel.company(companyId).customers` instead.
|
|
8
|
+
|
|
9
|
+
Customers of the focused company, on the flat `/v1/customers` routes.
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
| Method | HTTP | Summary |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| [`beel.customers.list(params?)`](#customers-list) | `GET /v1/customers` | List customers with optional filters and pagination. |
|
|
16
|
+
| [`beel.customers.create(body)`](#customers-create) | `POST /v1/customers` | Create a new customer. |
|
|
17
|
+
| [`beel.customers.get(id)`](#customers-get) | `GET /v1/customers/{customer_id}` | Get a customer by ID. |
|
|
18
|
+
| [`beel.customers.update(id, body)`](#customers-update) | `PUT /v1/customers/{customer_id}` | Update a customer. |
|
|
19
|
+
| [`beel.customers.deactivate(id)`](#customers-deactivate) | `DELETE /v1/customers/{customer_id}` | Deactivate (soft-delete) a customer. |
|
|
20
|
+
|
|
21
|
+
<a id="customers-list"></a>
|
|
22
|
+
### `list(params?)`
|
|
23
|
+
|
|
24
|
+
List customers with optional filters and pagination.
|
|
25
|
+
|
|
26
|
+
- **HTTP:** `GET /v1/customers` · operation `listCustomers` · scopes `customers:read` · **deprecated in the contract**
|
|
27
|
+
- **Parameters:**
|
|
28
|
+
- `params?: ListParams` — Filters and pagination.
|
|
29
|
+
- **Returns:** The page of `customers` and its `pagination`. Response `200` `data`: `{ customers: Customer[]; pagination: Pagination }`.
|
|
30
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
31
|
+
|
|
32
|
+
**Example**
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const { customers, pagination } = await beel.customers.list({ search: 'Acme', limit: 10 });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
<a id="customers-create"></a>
|
|
39
|
+
### `create(body)`
|
|
40
|
+
|
|
41
|
+
Create a new customer.
|
|
42
|
+
|
|
43
|
+
- **HTTP:** `POST /v1/customers` · operation `createCustomer` · scopes `customers:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
44
|
+
- **Parameters:**
|
|
45
|
+
- `body: components['schemas']['CreateCustomerRequest']` — Legal name, NIF and address.
|
|
46
|
+
- **Returns:** The created customer. Response `201` `data`: `Customer`.
|
|
47
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `409` `BeeLConflictError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
48
|
+
|
|
49
|
+
**Example**
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const customer = await beel.customers.create({
|
|
53
|
+
legal_name: 'Acme SL',
|
|
54
|
+
nif: 'B12345678',
|
|
55
|
+
address: { street: 'Calle Mayor', number: '1', postal_code: '28001', city: 'Madrid', province: 'Madrid', country: 'Spain', country_code: 'ES' },
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<a id="customers-get"></a>
|
|
60
|
+
### `get(id)`
|
|
61
|
+
|
|
62
|
+
Get a customer by ID.
|
|
63
|
+
|
|
64
|
+
- **HTTP:** `GET /v1/customers/{customer_id}` · operation `getCustomer` · scopes `customers:read` · **deprecated in the contract**
|
|
65
|
+
- **Parameters:**
|
|
66
|
+
- `id: string` — Customer UUID.
|
|
67
|
+
- **Returns:** The customer. Response `200` `data`: `Customer`.
|
|
68
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
69
|
+
|
|
70
|
+
<a id="customers-update"></a>
|
|
71
|
+
### `update(id, body)`
|
|
72
|
+
|
|
73
|
+
Update a customer. Only provided fields are changed.
|
|
74
|
+
|
|
75
|
+
- **HTTP:** `PUT /v1/customers/{customer_id}` · operation `updateCustomer` · scopes `customers:write` · **deprecated in the contract**
|
|
76
|
+
- **Parameters:**
|
|
77
|
+
- `id: string` — Customer UUID.
|
|
78
|
+
- `body: components['schemas']['UpdateCustomerRequest']` — Fields to change.
|
|
79
|
+
- **Returns:** The updated customer. Response `200` `data`: `Customer`.
|
|
80
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
81
|
+
|
|
82
|
+
<a id="customers-deactivate"></a>
|
|
83
|
+
### `deactivate(id)`
|
|
84
|
+
|
|
85
|
+
Deactivate (soft-delete) a customer.
|
|
86
|
+
|
|
87
|
+
- **HTTP:** `DELETE /v1/customers/{customer_id}` · operation `deleteCustomer` · scopes `customers:write` · **deprecated in the contract**
|
|
88
|
+
- **Parameters:**
|
|
89
|
+
- `id: string` — Customer UUID.
|
|
90
|
+
- **Returns:** Response `200` `data`: `{ message: string }`.
|
|
91
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `409` `BeeLConflictError` · `429` `BeeLRateLimitError`
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!-- Generated by `npm run docs:reference` from the SDK source and openapi/public-api.yaml. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Errors
|
|
4
|
+
|
|
5
|
+
[Reference index](README.md)
|
|
6
|
+
|
|
7
|
+
Every resource method rejects with one of these classes when the API answers non-2xx. A
|
|
8
|
+
network failure is thrown as the platform's own `fetch` error. `beel.raw` calls go through
|
|
9
|
+
the same client, so they also throw these errors instead of returning `{ error }`.
|
|
10
|
+
|
|
11
|
+
<a id="beelapierror"></a>
|
|
12
|
+
## `BeeLApiError` extends `Error`
|
|
13
|
+
|
|
14
|
+
Base error for every non-2xx answer of the BeeL API. The client throws it (or one of its
|
|
15
|
+
subclasses) from any resource method; a network failure is thrown as the platform's own
|
|
16
|
+
`fetch` error instead.
|
|
17
|
+
|
|
18
|
+
| Field | Type | Description |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| `statusCode` | `number` | HTTP status of the response. |
|
|
21
|
+
| `code` | `string` | Stable code of the error class. On the base class it is the API's `error.code`; the subclasses keep a fixed generic value (`CONFLICT`, `NOT_FOUND`…) for backward compatibility. Read `apiCode` for the API's specific code. |
|
|
22
|
+
| `apiCode` | `string` | The `error.code` the API answered with, verbatim — for example `INVOICE_DUPLICATE_EXTERNAL_REFERENCE`. Equal to `code` when the response did not carry one. See `BeeLErrorCodes` for the codes this SDK reacts to. |
|
|
23
|
+
| `details` | `Record<string, string>` | `error.details` of the response, when the API sent any. |
|
|
24
|
+
| `requestId` | `string` | `meta.request_id` of the response. Quote it when you contact support. |
|
|
25
|
+
|
|
26
|
+
<a id="beelratelimiterror"></a>
|
|
27
|
+
## `BeeLRateLimitError` extends `BeeLApiError`
|
|
28
|
+
|
|
29
|
+
`429`: rate limit exceeded. Retried automatically, see `maxRetries`.
|
|
30
|
+
|
|
31
|
+
| Field | Type | Description |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `retryAfterSeconds` | `number` | Seconds the API asked to wait before the next request. |
|
|
34
|
+
|
|
35
|
+
<a id="beelvalidationerror"></a>
|
|
36
|
+
## `BeeLValidationError` extends `BeeLApiError`
|
|
37
|
+
|
|
38
|
+
`422`: validation or business rule error. `details` names the offending fields.
|
|
39
|
+
|
|
40
|
+
<a id="beelautherror"></a>
|
|
41
|
+
## `BeeLAuthError` extends `BeeLApiError`
|
|
42
|
+
|
|
43
|
+
`401` / `403`: the API key is missing or invalid, or lacks access to the resource.
|
|
44
|
+
|
|
45
|
+
<a id="beelnotfounderror"></a>
|
|
46
|
+
## `BeeLNotFoundError` extends `BeeLApiError`
|
|
47
|
+
|
|
48
|
+
`404`: the resource does not exist.
|
|
49
|
+
|
|
50
|
+
<a id="beelconflicterror"></a>
|
|
51
|
+
## `BeeLConflictError` extends `BeeLApiError`
|
|
52
|
+
|
|
53
|
+
`409`: conflict — for example `INVOICE_DUPLICATE_EXTERNAL_REFERENCE` or an
|
|
54
|
+
`Idempotency-Key` reused with another body. Branch on `BeeLApiError.apiCode`.
|
|
55
|
+
|
|
56
|
+
<a id="webhookverificationerror"></a>
|
|
57
|
+
## `WebhookVerificationError` extends `Error`
|
|
58
|
+
|
|
59
|
+
Webhook verification error
|
|
60
|
+
|
|
61
|
+
<a id="beelerrorcodes"></a>
|
|
62
|
+
## `BeeLErrorCodes`
|
|
63
|
+
|
|
64
|
+
`error.code` values of the API that the SDK itself reacts to. Compare them with
|
|
65
|
+
`BeeLApiError.apiCode`. The full catalogue lives in the API reference
|
|
66
|
+
(https://docs.beel.es); these are the ones this package has behaviour for.
|
|
67
|
+
|
|
68
|
+
| Code | Meaning |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `INVOICE_DUPLICATE_EXTERNAL_REFERENCE` | `409`: a live standard or simplified invoice with the same `external_ref` already exists in this environment. Look it up with `invoices.list({ external_ref })`. |
|
|
71
|
+
| `IDEMPOTENCY_KEY_PROCESSING` | `409`: the first request with this `Idempotency-Key` is still being processed. Retry with the same key after `Retry-After`; the client does so automatically. |
|
|
72
|
+
| `IDEMPOTENCY_KEY_MISMATCH` | `409`: the `Idempotency-Key` was already used with a different body. Use a new key. |
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<!-- Generated by `npm run docs:reference` from the SDK source and openapi/public-api.yaml. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
# `InvoiceBuilder`
|
|
4
|
+
|
|
5
|
+
[Reference index](README.md)
|
|
6
|
+
|
|
7
|
+
Fluent builder for the body of `invoices.create`. It builds the request object only; send
|
|
8
|
+
it with `beel.company(companyId).invoices.create(builder.build())`.
|
|
9
|
+
|
|
10
|
+
The API requires a `main_tax` on every `NORMAL` line (`422 LINE_MAIN_TAX_REQUIRED`
|
|
11
|
+
otherwise): set it once with `mainTax`, or per line in `addLine`.
|
|
12
|
+
|
|
13
|
+
**Example**
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const request = InvoiceBuilder.create()
|
|
17
|
+
.forCustomer('customer-uuid')
|
|
18
|
+
.mainTax({ type: 'IVA', percentage: 21, regime_key: '01' })
|
|
19
|
+
.addLine('Consulting services', 10, 85.5)
|
|
20
|
+
.build();
|
|
21
|
+
const invoice = await beel.company(companyId).invoices.create(request);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Methods
|
|
25
|
+
|
|
26
|
+
| Method | HTTP | Summary |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| [`InvoiceBuilder.create()`](#invoice-builder-create) | — | Start a new builder. |
|
|
29
|
+
| [`InvoiceBuilder.type(type)`](#invoice-builder-type) | — | Set the invoice type. |
|
|
30
|
+
| [`InvoiceBuilder.forCustomer(customerId)`](#invoice-builder-for-customer) | — | Invoice a registered customer. |
|
|
31
|
+
| [`InvoiceBuilder.operationDate(date)`](#invoice-builder-operation-date) | — | Date the operation took place, when it differs from the issue date. |
|
|
32
|
+
| [`InvoiceBuilder.dueDate(date)`](#invoice-builder-due-date) | — | Payment due date. |
|
|
33
|
+
| [`InvoiceBuilder.mainTax(tax)`](#invoice-builder-main-tax) | — | Main tax applied to every line added with `addLine` after this call, unless the line passes its own. |
|
|
34
|
+
| [`InvoiceBuilder.addLine(description, quantity, unitPrice, discountPercentage?, mainTax?)`](#invoice-builder-add-line) | — | Add a `NORMAL` line. |
|
|
35
|
+
| [`InvoiceBuilder.addLineObject(line)`](#invoice-builder-add-line-object) | — | Add a line exactly as given — any line type or pricing mode. |
|
|
36
|
+
| [`InvoiceBuilder.notes(notes)`](#invoice-builder-notes) | — | Notes printed on the invoice. |
|
|
37
|
+
| [`InvoiceBuilder.series(id)`](#invoice-builder-series) | — | Number the invoice in this series instead of the default one. |
|
|
38
|
+
| [`InvoiceBuilder.metadata(data)`](#invoice-builder-metadata) | — | Your own key/value pairs, filterable when listing. |
|
|
39
|
+
| [`InvoiceBuilder.build()`](#invoice-builder-build) | — | Build the request body. |
|
|
40
|
+
|
|
41
|
+
<a id="invoice-builder-create"></a>
|
|
42
|
+
### `create()`
|
|
43
|
+
|
|
44
|
+
Start a new builder.
|
|
45
|
+
|
|
46
|
+
- **Returns:** An empty `STANDARD` invoice builder.
|
|
47
|
+
|
|
48
|
+
<a id="invoice-builder-type"></a>
|
|
49
|
+
### `type(type)`
|
|
50
|
+
|
|
51
|
+
Set the invoice type. Default: `STANDARD`.
|
|
52
|
+
|
|
53
|
+
- **Parameters:**
|
|
54
|
+
- `type: InvoiceType` — `STANDARD`, `SIMPLIFIED` or `PROFORMA` (correctives use `createCorrective`).
|
|
55
|
+
- **Returns:** This builder.
|
|
56
|
+
|
|
57
|
+
<a id="invoice-builder-for-customer"></a>
|
|
58
|
+
### `forCustomer(customerId)`
|
|
59
|
+
|
|
60
|
+
Invoice a registered customer.
|
|
61
|
+
|
|
62
|
+
- **Parameters:**
|
|
63
|
+
- `customerId: string` — Customer UUID.
|
|
64
|
+
- **Returns:** This builder.
|
|
65
|
+
|
|
66
|
+
<a id="invoice-builder-operation-date"></a>
|
|
67
|
+
### `operationDate(date)`
|
|
68
|
+
|
|
69
|
+
Date the operation took place, when it differs from the issue date.
|
|
70
|
+
|
|
71
|
+
- **Parameters:**
|
|
72
|
+
- `date: string | Date` — A `Date` or a `YYYY-MM-DD` string.
|
|
73
|
+
- **Returns:** This builder.
|
|
74
|
+
|
|
75
|
+
<a id="invoice-builder-due-date"></a>
|
|
76
|
+
### `dueDate(date)`
|
|
77
|
+
|
|
78
|
+
Payment due date.
|
|
79
|
+
|
|
80
|
+
- **Parameters:**
|
|
81
|
+
- `date: string | Date` — A `Date` or a `YYYY-MM-DD` string.
|
|
82
|
+
- **Returns:** This builder.
|
|
83
|
+
|
|
84
|
+
<a id="invoice-builder-main-tax"></a>
|
|
85
|
+
### `mainTax(tax)`
|
|
86
|
+
|
|
87
|
+
Main tax applied to every line added with `addLine` after this call, unless the
|
|
88
|
+
line passes its own.
|
|
89
|
+
|
|
90
|
+
- **Parameters:**
|
|
91
|
+
- `tax: LineMainTax` — For example `{ type: 'IVA', percentage: 21, regime_key: '01' }`.
|
|
92
|
+
- **Returns:** This builder.
|
|
93
|
+
|
|
94
|
+
<a id="invoice-builder-add-line"></a>
|
|
95
|
+
### `addLine(description, quantity, unitPrice, discountPercentage?, mainTax?)`
|
|
96
|
+
|
|
97
|
+
Add a `NORMAL` line.
|
|
98
|
+
|
|
99
|
+
- **Parameters:**
|
|
100
|
+
- `description: string` — What is invoiced.
|
|
101
|
+
- `quantity: number` — Units.
|
|
102
|
+
- `unitPrice: number` — Price per unit before taxes.
|
|
103
|
+
- `discountPercentage?: number` — Discount, 0–100. Default: `0`. Default: `NO_DISCOUNT`.
|
|
104
|
+
- `mainTax?: LineMainTax` — Tax of this line; defaults to the one set with `mainTax`. The API rejects a `NORMAL` line without one.
|
|
105
|
+
- **Returns:** This builder.
|
|
106
|
+
|
|
107
|
+
<a id="invoice-builder-add-line-object"></a>
|
|
108
|
+
### `addLineObject(line)`
|
|
109
|
+
|
|
110
|
+
Add a line exactly as given — any line type or pricing mode.
|
|
111
|
+
|
|
112
|
+
- **Parameters:**
|
|
113
|
+
- `line: InvoiceLine` — A line of `CreateInvoiceRequest`.
|
|
114
|
+
- **Returns:** This builder.
|
|
115
|
+
|
|
116
|
+
<a id="invoice-builder-notes"></a>
|
|
117
|
+
### `notes(notes)`
|
|
118
|
+
|
|
119
|
+
Notes printed on the invoice.
|
|
120
|
+
|
|
121
|
+
- **Parameters:**
|
|
122
|
+
- `notes: string` — Free text.
|
|
123
|
+
- **Returns:** This builder.
|
|
124
|
+
|
|
125
|
+
<a id="invoice-builder-series"></a>
|
|
126
|
+
### `series(id)`
|
|
127
|
+
|
|
128
|
+
Number the invoice in this series instead of the default one.
|
|
129
|
+
|
|
130
|
+
- **Parameters:**
|
|
131
|
+
- `id: string` — Series UUID.
|
|
132
|
+
- **Returns:** This builder.
|
|
133
|
+
|
|
134
|
+
<a id="invoice-builder-metadata"></a>
|
|
135
|
+
### `metadata(data)`
|
|
136
|
+
|
|
137
|
+
Your own key/value pairs, filterable when listing.
|
|
138
|
+
|
|
139
|
+
- **Parameters:**
|
|
140
|
+
- `data: Record<string, any>` — Metadata to store with the invoice.
|
|
141
|
+
- **Returns:** This builder.
|
|
142
|
+
|
|
143
|
+
<a id="invoice-builder-build"></a>
|
|
144
|
+
### `build()`
|
|
145
|
+
|
|
146
|
+
Build the request body.
|
|
147
|
+
|
|
148
|
+
- **Returns:** The `CreateInvoiceRequest`.
|
|
149
|
+
- **Throws:** `Error` When there is no customer or no line.
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<!-- Generated by `npm run docs:reference` from the SDK source and openapi/public-api.yaml. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
# `beel.invoices` — `InvoicesResource`
|
|
4
|
+
|
|
5
|
+
[Reference index](README.md)
|
|
6
|
+
|
|
7
|
+
> **Deprecated.** The contract deprecates the session-focus routes. Use `beel.company(companyId).invoices` instead.
|
|
8
|
+
|
|
9
|
+
Invoices of the focused company, on the flat `/v1/invoices` routes.
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
| Method | HTTP | Summary |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| [`beel.invoices.list(params?)`](#invoices-list) | `GET /v1/invoices` | List invoices with optional filters and pagination. |
|
|
16
|
+
| [`beel.invoices.create(body)`](#invoices-create) | `POST /v1/invoices` | Create a new invoice. |
|
|
17
|
+
| [`beel.invoices.get(id)`](#invoices-get) | `GET /v1/invoices/{invoice_id}` | Get an invoice by ID. |
|
|
18
|
+
| [`beel.invoices.update(id, body)`](#invoices-update) | `PUT /v1/invoices/{invoice_id}` | Update a draft invoice. |
|
|
19
|
+
| [`beel.invoices.delete(id)`](#invoices-delete) | `DELETE /v1/invoices/{invoice_id}` | Delete a draft invoice. |
|
|
20
|
+
| [`beel.invoices.duplicate(id, options?)`](#invoices-duplicate) | `POST /v1/invoices/{invoice_id}/duplicate` | Duplicate an invoice, optionally into a different series. |
|
|
21
|
+
| [`beel.invoices.issue(id, options?)`](#invoices-issue) | `POST /v1/invoices/{invoice_id}/issue` | Issue a draft invoice. |
|
|
22
|
+
| [`beel.invoices.markPaid(id, options?)`](#invoices-mark-paid) | `POST /v1/invoices/{invoice_id}/mark-paid` | Mark an invoice as paid. |
|
|
23
|
+
| [`beel.invoices.markSent(id, options?)`](#invoices-mark-sent) | `POST /v1/invoices/{invoice_id}/mark-sent` | Mark an invoice as sent (e.g. delivered by other means). |
|
|
24
|
+
| [`beel.invoices.revertToIssued(id)`](#invoices-revert-to-issued) | `POST /v1/invoices/{invoice_id}/revert-to-issued` | Revert a paid/sent invoice back to issued status. |
|
|
25
|
+
| [`beel.invoices.void(id, params)`](#invoices-void) | `POST /v1/invoices/{invoice_id}/void` | Void an issued invoice. |
|
|
26
|
+
| [`beel.invoices.createCorrective(id, body)`](#invoices-create-corrective) | `POST /v1/invoices/{invoice_id}/corrective` | Create a corrective invoice that references the original. |
|
|
27
|
+
| [`beel.invoices.schedule(id, params)`](#invoices-schedule) | `POST /v1/invoices/{invoice_id}/schedule` | Schedule a draft invoice to be issued on a future date. |
|
|
28
|
+
| [`beel.invoices.unschedule(id)`](#invoices-unschedule) | `POST /v1/invoices/{invoice_id}/unschedule` | Cancel a scheduled invoice, returning it to draft. |
|
|
29
|
+
| [`beel.invoices.reschedule(id, params)`](#invoices-reschedule) | `PATCH /v1/invoices/{invoice_id}/reschedule` | Change the scheduled date of a scheduled invoice. |
|
|
30
|
+
| [`beel.invoices.getPdf(id)`](#invoices-get-pdf) | `GET /v1/invoices/{invoice_id}/pdf` | Get a pre-signed URL to download the invoice PDF. |
|
|
31
|
+
| [`beel.invoices.sendEmail(id, options?)`](#invoices-send-email) | `POST /v1/invoices/{invoice_id}/send` | Send an invoice by email. |
|
|
32
|
+
|
|
33
|
+
<a id="invoices-list"></a>
|
|
34
|
+
### `list(params?)`
|
|
35
|
+
|
|
36
|
+
List invoices with optional filters and pagination.
|
|
37
|
+
|
|
38
|
+
- **HTTP:** `GET /v1/invoices` · operation `listInvoices` · scopes `invoices:read` · **deprecated in the contract**
|
|
39
|
+
- **Parameters:**
|
|
40
|
+
- `params?: ListParams` — Filters and pagination.
|
|
41
|
+
- **Returns:** The page of `invoices` and its `pagination`. Response `200` `data`: `{ invoices: Invoice[]; pagination: Pagination }`.
|
|
42
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
43
|
+
|
|
44
|
+
**Example**
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const { invoices, pagination } = await beel.invoices.list({ status: 'ISSUED', limit: 20 });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<a id="invoices-create"></a>
|
|
51
|
+
### `create(body)`
|
|
52
|
+
|
|
53
|
+
Create a new invoice. An idempotency key is automatically added.
|
|
54
|
+
|
|
55
|
+
- **HTTP:** `POST /v1/invoices` · operation `createInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
56
|
+
- **Parameters:**
|
|
57
|
+
- `body: components['schemas']['CreateInvoiceRequest']` — Type, recipient and lines.
|
|
58
|
+
- **Returns:** The created invoice. Response `201` `data`: `Invoice`.
|
|
59
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `409` `BeeLConflictError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
60
|
+
|
|
61
|
+
**Example**
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const invoice = await beel.invoices.create({
|
|
65
|
+
type: 'STANDARD',
|
|
66
|
+
recipient: { customer_id: 'uuid' },
|
|
67
|
+
lines: [{ description: 'Service', quantity: 1, unit_price: 100, discount_percentage: 0 }],
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
<a id="invoices-get"></a>
|
|
72
|
+
### `get(id)`
|
|
73
|
+
|
|
74
|
+
Get an invoice by ID.
|
|
75
|
+
|
|
76
|
+
- **HTTP:** `GET /v1/invoices/{invoice_id}` · operation `getInvoice` · scopes `invoices:read` · **deprecated in the contract**
|
|
77
|
+
- **Parameters:**
|
|
78
|
+
- `id: string` — Invoice UUID.
|
|
79
|
+
- **Returns:** The invoice. Response `200` `data`: `Invoice`.
|
|
80
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
81
|
+
|
|
82
|
+
<a id="invoices-update"></a>
|
|
83
|
+
### `update(id, body)`
|
|
84
|
+
|
|
85
|
+
Update a draft invoice. Only draft invoices can be updated.
|
|
86
|
+
|
|
87
|
+
- **HTTP:** `PUT /v1/invoices/{invoice_id}` · operation `updateInvoice` · scopes `invoices:write` · **deprecated in the contract**
|
|
88
|
+
- **Parameters:**
|
|
89
|
+
- `id: string` — Invoice UUID.
|
|
90
|
+
- `body: components['schemas']['UpdateInvoiceRequest']` — The draft's new content.
|
|
91
|
+
- **Returns:** The updated invoice. Response `200` `data`: `Invoice`.
|
|
92
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
93
|
+
|
|
94
|
+
<a id="invoices-delete"></a>
|
|
95
|
+
### `delete(id)`
|
|
96
|
+
|
|
97
|
+
Delete a draft invoice. Only draft invoices can be deleted.
|
|
98
|
+
|
|
99
|
+
- **HTTP:** `DELETE /v1/invoices/{invoice_id}` · operation `deleteInvoice` · scopes `invoices:write` · **deprecated in the contract**
|
|
100
|
+
- **Parameters:**
|
|
101
|
+
- `id: string` — Invoice UUID.
|
|
102
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
103
|
+
|
|
104
|
+
<a id="invoices-duplicate"></a>
|
|
105
|
+
### `duplicate(id, options?)`
|
|
106
|
+
|
|
107
|
+
Duplicate an invoice, optionally into a different series.
|
|
108
|
+
|
|
109
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/duplicate` · operation `duplicateInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
110
|
+
- **Parameters:**
|
|
111
|
+
- `id: string` — Invoice UUID.
|
|
112
|
+
- `options?: { series_id?: string; notes?: string }` — `series_id` and `notes` of the copy.
|
|
113
|
+
- **Returns:** The new draft. Response `201` `data`: `Invoice`.
|
|
114
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
115
|
+
|
|
116
|
+
<a id="invoices-issue"></a>
|
|
117
|
+
### `issue(id, options?)`
|
|
118
|
+
|
|
119
|
+
Issue a draft invoice. Assigns an invoice number and triggers VeriFactu submission.
|
|
120
|
+
|
|
121
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/issue` · operation `issueInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
122
|
+
- **Parameters:**
|
|
123
|
+
- `id: string` — Invoice UUID.
|
|
124
|
+
- `options?: { wait_for_pdf?: boolean }` — `wait_for_pdf: true` to wait for the PDF.
|
|
125
|
+
- **Returns:** The issued invoice. Response `200` `data`: `Invoice`.
|
|
126
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `409` `BeeLConflictError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
127
|
+
|
|
128
|
+
<a id="invoices-mark-paid"></a>
|
|
129
|
+
### `markPaid(id, options?)`
|
|
130
|
+
|
|
131
|
+
Mark an invoice as paid.
|
|
132
|
+
|
|
133
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/mark-paid` · operation `markInvoicePaid` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
134
|
+
- **Parameters:**
|
|
135
|
+
- `id: string` — Invoice UUID.
|
|
136
|
+
- `options?: { payment_date?: string; payment_method?: any }` — `payment_date` (default: today) and `payment_method`.
|
|
137
|
+
- **Returns:** The paid invoice. Response `200` `data`: `Invoice`.
|
|
138
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
139
|
+
|
|
140
|
+
<a id="invoices-mark-sent"></a>
|
|
141
|
+
### `markSent(id, options?)`
|
|
142
|
+
|
|
143
|
+
Mark an invoice as sent (e.g. delivered by other means).
|
|
144
|
+
|
|
145
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/mark-sent` · operation `markInvoiceSent` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
146
|
+
- **Parameters:**
|
|
147
|
+
- `id: string` — Invoice UUID.
|
|
148
|
+
- `options?: { sent_at?: string }` — `sent_at`.
|
|
149
|
+
- **Returns:** The sent invoice. Response `200` `data`: `Invoice`.
|
|
150
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
151
|
+
|
|
152
|
+
<a id="invoices-revert-to-issued"></a>
|
|
153
|
+
### `revertToIssued(id)`
|
|
154
|
+
|
|
155
|
+
Revert a paid/sent invoice back to issued status.
|
|
156
|
+
|
|
157
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/revert-to-issued` · operation `revertInvoiceToIssued` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
158
|
+
- **Parameters:**
|
|
159
|
+
- `id: string` — Invoice UUID.
|
|
160
|
+
- **Returns:** The invoice, back in `ISSUED`. Response `200` `data`: `Invoice`.
|
|
161
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
162
|
+
|
|
163
|
+
<a id="invoices-void"></a>
|
|
164
|
+
### `void(id, params)`
|
|
165
|
+
|
|
166
|
+
Void an issued invoice. Requires a reason (min 10 chars).
|
|
167
|
+
|
|
168
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/void` · operation `voidInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
169
|
+
- **Parameters:**
|
|
170
|
+
- `id: string` — Invoice UUID.
|
|
171
|
+
- `params: { reason: string; void_date?: string }` — `reason` (min 10 characters) and optional `void_date`.
|
|
172
|
+
- **Returns:** The voided invoice. Response `200` `data`: `Invoice`.
|
|
173
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `409` `BeeLConflictError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
174
|
+
|
|
175
|
+
**Example**
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
await beel.invoices.void('id', { reason: 'Duplicate invoice sent in error' });
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
<a id="invoices-create-corrective"></a>
|
|
182
|
+
### `createCorrective(id, body)`
|
|
183
|
+
|
|
184
|
+
Create a corrective invoice that references the original.
|
|
185
|
+
|
|
186
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/corrective` · operation `createCorrectiveInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
187
|
+
- **Parameters:**
|
|
188
|
+
- `id: string` — UUID of the issued invoice to correct.
|
|
189
|
+
- `body: components['schemas']['CreateCorrectiveInvoiceRequest']` — Rectification type, code, reason and lines.
|
|
190
|
+
- **Returns:** The corrective invoice. Response `201` `data`: `Invoice`.
|
|
191
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
192
|
+
|
|
193
|
+
<a id="invoices-schedule"></a>
|
|
194
|
+
### `schedule(id, params)`
|
|
195
|
+
|
|
196
|
+
Schedule a draft invoice to be issued on a future date.
|
|
197
|
+
|
|
198
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/schedule` · operation `scheduleInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
199
|
+
- **Parameters:**
|
|
200
|
+
- `id: string` — UUID of the draft.
|
|
201
|
+
- `params: { scheduled_for: string; action?: string }` — `scheduled_for` and optional `action`.
|
|
202
|
+
- **Returns:** The scheduled invoice. Response `200` `data`: `Invoice`.
|
|
203
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
204
|
+
|
|
205
|
+
<a id="invoices-unschedule"></a>
|
|
206
|
+
### `unschedule(id)`
|
|
207
|
+
|
|
208
|
+
Cancel a scheduled invoice, returning it to draft.
|
|
209
|
+
|
|
210
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/unschedule` · operation `unscheduleInvoice` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
211
|
+
- **Parameters:**
|
|
212
|
+
- `id: string` — Invoice UUID.
|
|
213
|
+
- **Returns:** The invoice, back in draft. Response `200` `data`: `Invoice`.
|
|
214
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
215
|
+
|
|
216
|
+
<a id="invoices-reschedule"></a>
|
|
217
|
+
### `reschedule(id, params)`
|
|
218
|
+
|
|
219
|
+
Change the scheduled date of a scheduled invoice.
|
|
220
|
+
|
|
221
|
+
- **HTTP:** `PATCH /v1/invoices/{invoice_id}/reschedule` · operation `rescheduleInvoice` · scopes `invoices:write` · **deprecated in the contract**
|
|
222
|
+
- **Parameters:**
|
|
223
|
+
- `id: string` — Invoice UUID.
|
|
224
|
+
- `params: { scheduled_for: string }` — New `scheduled_for`.
|
|
225
|
+
- **Returns:** The rescheduled invoice. Response `200` `data`: `Invoice`.
|
|
226
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
227
|
+
|
|
228
|
+
<a id="invoices-get-pdf"></a>
|
|
229
|
+
### `getPdf(id)`
|
|
230
|
+
|
|
231
|
+
Get a pre-signed URL to download the invoice PDF.
|
|
232
|
+
The URL expires in 5 minutes. Use `beel.downloadPdf(id)` for a simpler Buffer download.
|
|
233
|
+
|
|
234
|
+
- **HTTP:** `GET /v1/invoices/{invoice_id}/pdf` · operation `generateInvoicePdf` · scopes `invoices:read` · **deprecated in the contract**
|
|
235
|
+
- **Parameters:**
|
|
236
|
+
- `id: string` — Invoice UUID.
|
|
237
|
+
- **Returns:** `download_url`, `expires_in_seconds` and `file_name`. Response `200` `data`: `{ download_url: string; expires_in_seconds: number; file_name: string }`.
|
|
238
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `429` `BeeLRateLimitError`
|
|
239
|
+
|
|
240
|
+
<a id="invoices-send-email"></a>
|
|
241
|
+
### `sendEmail(id, options?)`
|
|
242
|
+
|
|
243
|
+
Send an invoice by email. Uses the customer's email by default.
|
|
244
|
+
|
|
245
|
+
- **HTTP:** `POST /v1/invoices/{invoice_id}/send` · operation `sendInvoiceEmail` · scopes `invoices:write` · accepts `Idempotency-Key` · **deprecated in the contract**
|
|
246
|
+
- **Parameters:**
|
|
247
|
+
- `id: string` — Invoice UUID.
|
|
248
|
+
- `options?: { to?: string[]; cc?: string[]; subject?: string; message?: string }` — Recipients, subject and message.
|
|
249
|
+
- **Returns:** The delivery record. Response `200` `data`: `{ email_id?: UUID; sent_to?: Email[]; sent_at?: string }`.
|
|
250
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `404` `BeeLNotFoundError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- Generated by `npm run docs:reference` from the SDK source and openapi/public-api.yaml. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
# `beel.nif` — `NifResource`
|
|
4
|
+
|
|
5
|
+
[Reference index](README.md)
|
|
6
|
+
|
|
7
|
+
NIF validation against the AEAT register. Reach it as `beel.nif`.
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
| Method | HTTP | Summary |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| [`beel.nif.validate(nif)`](#nif-validate) | `POST /v1/nif/validate` | Validate a Spanish NIF/CIF against the AEAT tax registry. |
|
|
14
|
+
|
|
15
|
+
<a id="nif-validate"></a>
|
|
16
|
+
### `validate(nif)`
|
|
17
|
+
|
|
18
|
+
Validate a Spanish NIF/CIF against the AEAT tax registry.
|
|
19
|
+
|
|
20
|
+
- **HTTP:** `POST /v1/nif/validate` · operation `validateNif` · scopes `nif:validate`
|
|
21
|
+
- **Parameters:**
|
|
22
|
+
- `nif: string` — The NIF/CIF to validate.
|
|
23
|
+
- **Returns:** Whether it is valid and, when the register knows it, its holder's name. Response `200` `data`: `ValidateNifResponse`.
|
|
24
|
+
- **Throws:** `400`/`500` `BeeLApiError` · `401`/`403` `BeeLAuthError` · `422` `BeeLValidationError` · `429` `BeeLRateLimitError`
|
|
25
|
+
|
|
26
|
+
**Example**
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
const result = await beel.nif.validate('B12345678');
|
|
30
|
+
console.log(result.valid, result.name);
|
|
31
|
+
```
|