@beel_es/sdk 1.2.0 → 1.3.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 +63 -0
- package/dist/index.d.mts +10104 -3678
- package/dist/index.d.ts +10104 -3678
- package/dist/index.js +255 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +249 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -43,12 +43,18 @@ __export(index_exports, {
|
|
|
43
43
|
BeeLNotFoundError: () => BeeLNotFoundError,
|
|
44
44
|
BeeLRateLimitError: () => BeeLRateLimitError,
|
|
45
45
|
BeeLValidationError: () => BeeLValidationError,
|
|
46
|
+
CatalogsResource: () => CatalogsResource,
|
|
46
47
|
CompanyCustomersResource: () => CompanyCustomersResource,
|
|
48
|
+
CompanyInvoiceScheduleResource: () => CompanyInvoiceScheduleResource,
|
|
47
49
|
CompanyInvoicesResource: () => CompanyInvoicesResource,
|
|
50
|
+
CompanyPaymentConnectionsResource: () => CompanyPaymentConnectionsResource,
|
|
51
|
+
CompanyPaymentEventsResource: () => CompanyPaymentEventsResource,
|
|
48
52
|
CompanyProductsResource: () => CompanyProductsResource,
|
|
49
53
|
CompanyRecurringInvoicesResource: () => CompanyRecurringInvoicesResource,
|
|
50
54
|
CompanyScope: () => CompanyScope,
|
|
51
55
|
CompanySeriesResource: () => CompanySeriesResource,
|
|
56
|
+
CompanyTaxConfigurationResource: () => CompanyTaxConfigurationResource,
|
|
57
|
+
CompanyVeriFactuConfigurationResource: () => CompanyVeriFactuConfigurationResource,
|
|
52
58
|
CustomerBuilder: () => CustomerBuilder,
|
|
53
59
|
InvoiceBuilder: () => InvoiceBuilder,
|
|
54
60
|
VeriFactuSubmissionStatus: () => VeriFactuSubmissionStatus,
|
|
@@ -483,6 +489,29 @@ var ConfigurationResource = class {
|
|
|
483
489
|
return data.data;
|
|
484
490
|
}
|
|
485
491
|
};
|
|
492
|
+
var CatalogsResource = class {
|
|
493
|
+
constructor(client) {
|
|
494
|
+
this.client = client;
|
|
495
|
+
}
|
|
496
|
+
/** Tax types the API accepts. Canonical form of `configuration/tax-types`. */
|
|
497
|
+
async taxTypes() {
|
|
498
|
+
const { data } = await this.client.GET("/v1/tax-types");
|
|
499
|
+
return data.data;
|
|
500
|
+
}
|
|
501
|
+
/** Invoice customization options. Canonical form of the `configuration` read. */
|
|
502
|
+
async invoiceCustomizationOptions() {
|
|
503
|
+
const { data } = await this.client.GET("/v1/invoice-customization-options");
|
|
504
|
+
return data.data;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The signed-in person's preferences. Canonical form of
|
|
508
|
+
* `PUT /v1/configuration/language`: the language belongs to the person, not to a company.
|
|
509
|
+
*/
|
|
510
|
+
async updateMe(body) {
|
|
511
|
+
const { data } = await this.client.PATCH("/v1/me", { body });
|
|
512
|
+
return data.data;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
486
515
|
|
|
487
516
|
// src/resources/series.ts
|
|
488
517
|
var SeriesResource = class {
|
|
@@ -779,7 +808,10 @@ var AccountCompaniesResource = class {
|
|
|
779
808
|
const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
|
|
780
809
|
params: { path: { account_id: this.accountId }, query: params }
|
|
781
810
|
});
|
|
782
|
-
return {
|
|
811
|
+
return {
|
|
812
|
+
companies: data.data?.companies ?? [],
|
|
813
|
+
pagination: data.data?.pagination
|
|
814
|
+
};
|
|
783
815
|
}
|
|
784
816
|
/** Register a new company (NIF) under the account. */
|
|
785
817
|
async create(body) {
|
|
@@ -798,6 +830,134 @@ var AccountCompaniesResource = class {
|
|
|
798
830
|
}
|
|
799
831
|
};
|
|
800
832
|
|
|
833
|
+
// src/resources/payment-connections.ts
|
|
834
|
+
var CompanyPaymentConnectionsResource = class {
|
|
835
|
+
constructor(client, companyId) {
|
|
836
|
+
this.client = client;
|
|
837
|
+
this.companyId = companyId;
|
|
838
|
+
}
|
|
839
|
+
path() {
|
|
840
|
+
return { company_id: this.companyId };
|
|
841
|
+
}
|
|
842
|
+
/** Every payment connection of this company. */
|
|
843
|
+
async list() {
|
|
844
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/payment-connections", {
|
|
845
|
+
params: { path: this.path() }
|
|
846
|
+
});
|
|
847
|
+
return data.data;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Start an authorization and get the URL where the NIF's holder approves it.
|
|
851
|
+
*
|
|
852
|
+
* This is the one place the provider slug is used — currently only `stripe`.
|
|
853
|
+
*/
|
|
854
|
+
async authorize(body) {
|
|
855
|
+
const { data } = await this.client.POST(
|
|
856
|
+
"/v1/companies/{company_id}/payment-connections/authorizations",
|
|
857
|
+
{ params: { path: this.path() }, body }
|
|
858
|
+
);
|
|
859
|
+
return data.data;
|
|
860
|
+
}
|
|
861
|
+
/** Update one connection, addressed by its UUID. */
|
|
862
|
+
async update(connectionId, body) {
|
|
863
|
+
const { data } = await this.client.PATCH(
|
|
864
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}",
|
|
865
|
+
{ params: { path: { ...this.path(), connection_id: connectionId } }, body }
|
|
866
|
+
);
|
|
867
|
+
return data.data;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Disconnect one connection. Tokens are revoked and auto-invoicing stops;
|
|
871
|
+
* already-issued invoices are untouched.
|
|
872
|
+
*/
|
|
873
|
+
async disconnect(connectionId) {
|
|
874
|
+
await this.client.DELETE("/v1/companies/{company_id}/payment-connections/{connection_id}", {
|
|
875
|
+
params: { path: { ...this.path(), connection_id: connectionId } }
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
/** The payment events of one connection — where you audit what did and didn't invoice. */
|
|
879
|
+
events(connectionId) {
|
|
880
|
+
return new CompanyPaymentEventsResource(this.client, this.companyId, connectionId);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
var CompanyPaymentEventsResource = class {
|
|
884
|
+
constructor(client, companyId, connectionId) {
|
|
885
|
+
this.client = client;
|
|
886
|
+
this.companyId = companyId;
|
|
887
|
+
this.connectionId = connectionId;
|
|
888
|
+
}
|
|
889
|
+
path() {
|
|
890
|
+
return { company_id: this.companyId, connection_id: this.connectionId };
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Events of the connection, most recent first. Nothing is hidden by default:
|
|
894
|
+
* skipped events, duplicates and disputes are all returned — narrow with the
|
|
895
|
+
* filters. `charges_only` returns one row per money movement instead.
|
|
896
|
+
*/
|
|
897
|
+
async list(params) {
|
|
898
|
+
const { data } = await this.client.GET(
|
|
899
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events",
|
|
900
|
+
{ params: { path: this.path(), query: params } }
|
|
901
|
+
);
|
|
902
|
+
return data.data;
|
|
903
|
+
}
|
|
904
|
+
/** One event. */
|
|
905
|
+
async get(eventId) {
|
|
906
|
+
const { data } = await this.client.GET(
|
|
907
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}",
|
|
908
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
909
|
+
);
|
|
910
|
+
return data.data;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Reprocess an event whose automatic invoicing didn't complete, applying the NIF's
|
|
914
|
+
* **current** configuration. Only retryable states qualify and the retry budget is
|
|
915
|
+
* finite: otherwise `400`.
|
|
916
|
+
*/
|
|
917
|
+
async retry(eventId) {
|
|
918
|
+
const { data } = await this.client.POST(
|
|
919
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/retry",
|
|
920
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
921
|
+
);
|
|
922
|
+
return data.data;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Build a **draft** invoice from an event that couldn't be invoiced automatically,
|
|
926
|
+
* so you can review it before issuing. Returns the draft's id.
|
|
927
|
+
*/
|
|
928
|
+
async draft(eventId) {
|
|
929
|
+
const { data } = await this.client.POST(
|
|
930
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/draft",
|
|
931
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
932
|
+
);
|
|
933
|
+
return data.data;
|
|
934
|
+
}
|
|
935
|
+
/** Mark an event as dealt with outside the automatic flow. */
|
|
936
|
+
async resolve(eventId) {
|
|
937
|
+
const { data } = await this.client.POST(
|
|
938
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/resolve",
|
|
939
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
940
|
+
);
|
|
941
|
+
return data.data;
|
|
942
|
+
}
|
|
943
|
+
/** Discard an event so it stops asking for attention. Reversible with {@link restore}. */
|
|
944
|
+
async discard(eventId) {
|
|
945
|
+
const { data } = await this.client.POST(
|
|
946
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/discard",
|
|
947
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
948
|
+
);
|
|
949
|
+
return data.data;
|
|
950
|
+
}
|
|
951
|
+
/** Bring a discarded event back into the list. */
|
|
952
|
+
async restore(eventId) {
|
|
953
|
+
const { data } = await this.client.POST(
|
|
954
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/restore",
|
|
955
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
956
|
+
);
|
|
957
|
+
return data.data;
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
|
|
801
961
|
// src/resources/company.ts
|
|
802
962
|
var CompanyScope = class {
|
|
803
963
|
constructor(client, companyId) {
|
|
@@ -808,6 +968,9 @@ var CompanyScope = class {
|
|
|
808
968
|
this.products = new CompanyProductsResource(client, companyId);
|
|
809
969
|
this.series = new CompanySeriesResource(client, companyId);
|
|
810
970
|
this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);
|
|
971
|
+
this.paymentConnections = new CompanyPaymentConnectionsResource(client, companyId);
|
|
972
|
+
this.taxConfiguration = new CompanyTaxConfigurationResource(client, companyId);
|
|
973
|
+
this.verifactuConfiguration = new CompanyVeriFactuConfigurationResource(client, companyId);
|
|
811
974
|
}
|
|
812
975
|
path() {
|
|
813
976
|
return { company_id: this.companyId };
|
|
@@ -850,6 +1013,17 @@ var CompanyInvoicesResource = class {
|
|
|
850
1013
|
constructor(client, companyId) {
|
|
851
1014
|
this.client = client;
|
|
852
1015
|
this.companyId = companyId;
|
|
1016
|
+
this.schedule = new CompanyInvoiceScheduleResource(client, companyId);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Derive a new invoice from an existing one — the canonical form of `duplicate`.
|
|
1020
|
+
*/
|
|
1021
|
+
async derive(body) {
|
|
1022
|
+
const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/derivations", {
|
|
1023
|
+
params: { path: { company_id: this.companyId } },
|
|
1024
|
+
body
|
|
1025
|
+
});
|
|
1026
|
+
return data.data;
|
|
853
1027
|
}
|
|
854
1028
|
path(rest) {
|
|
855
1029
|
return { company_id: this.companyId, ...rest };
|
|
@@ -942,6 +1116,36 @@ var CompanyInvoicesResource = class {
|
|
|
942
1116
|
return data.data;
|
|
943
1117
|
}
|
|
944
1118
|
};
|
|
1119
|
+
var CompanyInvoiceScheduleResource = class {
|
|
1120
|
+
constructor(client, companyId) {
|
|
1121
|
+
this.client = client;
|
|
1122
|
+
this.companyId = companyId;
|
|
1123
|
+
}
|
|
1124
|
+
async get(invoiceId) {
|
|
1125
|
+
const { data } = await this.client.GET(
|
|
1126
|
+
"/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
|
|
1127
|
+
{ params: { path: { company_id: this.companyId, invoice_id: invoiceId } } }
|
|
1128
|
+
);
|
|
1129
|
+
return data.data;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Set or move the schedule. One `PUT` replaces the three legacy calls
|
|
1133
|
+
* (`schedule`, `reschedule`, `unschedule`): setting it again moves it.
|
|
1134
|
+
*/
|
|
1135
|
+
async set(invoiceId, body) {
|
|
1136
|
+
const { data } = await this.client.PUT(
|
|
1137
|
+
"/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
|
|
1138
|
+
{ params: { path: { company_id: this.companyId, invoice_id: invoiceId } }, body }
|
|
1139
|
+
);
|
|
1140
|
+
return data.data;
|
|
1141
|
+
}
|
|
1142
|
+
/** Clear the schedule — the canonical form of `unschedule`. */
|
|
1143
|
+
async clear(invoiceId) {
|
|
1144
|
+
await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}/schedule", {
|
|
1145
|
+
params: { path: { company_id: this.companyId, invoice_id: invoiceId } }
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
945
1149
|
var CompanyCustomersResource = class {
|
|
946
1150
|
constructor(client, companyId) {
|
|
947
1151
|
this.client = client;
|
|
@@ -1149,16 +1353,57 @@ var CompanyRecurringInvoicesResource = class {
|
|
|
1149
1353
|
return data.data;
|
|
1150
1354
|
}
|
|
1151
1355
|
};
|
|
1356
|
+
var CompanyTaxConfigurationResource = class {
|
|
1357
|
+
constructor(client, companyId) {
|
|
1358
|
+
this.client = client;
|
|
1359
|
+
this.companyId = companyId;
|
|
1360
|
+
}
|
|
1361
|
+
async get() {
|
|
1362
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/tax-configuration", {
|
|
1363
|
+
params: { path: { company_id: this.companyId } }
|
|
1364
|
+
});
|
|
1365
|
+
return data.data;
|
|
1366
|
+
}
|
|
1367
|
+
/** Replaces the whole state — this is a `PUT`, not a merge. */
|
|
1368
|
+
async update(body) {
|
|
1369
|
+
const { data } = await this.client.PUT("/v1/companies/{company_id}/tax-configuration", {
|
|
1370
|
+
params: { path: { company_id: this.companyId } },
|
|
1371
|
+
body
|
|
1372
|
+
});
|
|
1373
|
+
return data.data;
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
var CompanyVeriFactuConfigurationResource = class {
|
|
1377
|
+
constructor(client, companyId) {
|
|
1378
|
+
this.client = client;
|
|
1379
|
+
this.companyId = companyId;
|
|
1380
|
+
}
|
|
1381
|
+
async get() {
|
|
1382
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/verifactu-configuration", {
|
|
1383
|
+
params: { path: { company_id: this.companyId } }
|
|
1384
|
+
});
|
|
1385
|
+
return data.data;
|
|
1386
|
+
}
|
|
1387
|
+
/** Flip VeriFactu for this NIF. `enabled` is the only field you can write. */
|
|
1388
|
+
async update(body) {
|
|
1389
|
+
const { data } = await this.client.PUT("/v1/companies/{company_id}/verifactu-configuration", {
|
|
1390
|
+
params: { path: { company_id: this.companyId } },
|
|
1391
|
+
body
|
|
1392
|
+
});
|
|
1393
|
+
return data.data;
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1152
1396
|
|
|
1153
1397
|
// src/client.ts
|
|
1154
1398
|
var BeeL = class {
|
|
1155
1399
|
constructor(config) {
|
|
1156
1400
|
const client = createBeeLClient(config);
|
|
1157
|
-
this.
|
|
1401
|
+
this.raw = client;
|
|
1158
1402
|
this.invoices = new InvoicesResource(client);
|
|
1159
1403
|
this.customers = new CustomersResource(client);
|
|
1160
1404
|
this.products = new ProductsResource(client);
|
|
1161
1405
|
this.configuration = new ConfigurationResource(client);
|
|
1406
|
+
this.catalogs = new CatalogsResource(client);
|
|
1162
1407
|
this.series = new SeriesResource(client);
|
|
1163
1408
|
this.nif = new NifResource(client);
|
|
1164
1409
|
this.accounts = new AccountsResource(client);
|
|
@@ -1174,7 +1419,7 @@ var BeeL = class {
|
|
|
1174
1419
|
* ```
|
|
1175
1420
|
*/
|
|
1176
1421
|
company(companyId) {
|
|
1177
|
-
return new CompanyScope(this.
|
|
1422
|
+
return new CompanyScope(this.raw, companyId);
|
|
1178
1423
|
}
|
|
1179
1424
|
/**
|
|
1180
1425
|
* Returns a facade scoped to one managed account — members, invitations,
|
|
@@ -1187,7 +1432,7 @@ var BeeL = class {
|
|
|
1187
1432
|
* ```
|
|
1188
1433
|
*/
|
|
1189
1434
|
account(accountId) {
|
|
1190
|
-
return new AccountScope(this.
|
|
1435
|
+
return new AccountScope(this.raw, accountId);
|
|
1191
1436
|
}
|
|
1192
1437
|
/**
|
|
1193
1438
|
* Download an invoice PDF as a Buffer.
|
|
@@ -1542,12 +1787,18 @@ var InvoiceBuilder = class _InvoiceBuilder {
|
|
|
1542
1787
|
BeeLNotFoundError,
|
|
1543
1788
|
BeeLRateLimitError,
|
|
1544
1789
|
BeeLValidationError,
|
|
1790
|
+
CatalogsResource,
|
|
1545
1791
|
CompanyCustomersResource,
|
|
1792
|
+
CompanyInvoiceScheduleResource,
|
|
1546
1793
|
CompanyInvoicesResource,
|
|
1794
|
+
CompanyPaymentConnectionsResource,
|
|
1795
|
+
CompanyPaymentEventsResource,
|
|
1547
1796
|
CompanyProductsResource,
|
|
1548
1797
|
CompanyRecurringInvoicesResource,
|
|
1549
1798
|
CompanyScope,
|
|
1550
1799
|
CompanySeriesResource,
|
|
1800
|
+
CompanyTaxConfigurationResource,
|
|
1801
|
+
CompanyVeriFactuConfigurationResource,
|
|
1551
1802
|
CustomerBuilder,
|
|
1552
1803
|
InvoiceBuilder,
|
|
1553
1804
|
VeriFactuSubmissionStatus,
|