@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.mjs
CHANGED
|
@@ -423,6 +423,29 @@ var ConfigurationResource = class {
|
|
|
423
423
|
return data.data;
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
|
+
var CatalogsResource = class {
|
|
427
|
+
constructor(client) {
|
|
428
|
+
this.client = client;
|
|
429
|
+
}
|
|
430
|
+
/** Tax types the API accepts. Canonical form of `configuration/tax-types`. */
|
|
431
|
+
async taxTypes() {
|
|
432
|
+
const { data } = await this.client.GET("/v1/tax-types");
|
|
433
|
+
return data.data;
|
|
434
|
+
}
|
|
435
|
+
/** Invoice customization options. Canonical form of the `configuration` read. */
|
|
436
|
+
async invoiceCustomizationOptions() {
|
|
437
|
+
const { data } = await this.client.GET("/v1/invoice-customization-options");
|
|
438
|
+
return data.data;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* The signed-in person's preferences. Canonical form of
|
|
442
|
+
* `PUT /v1/configuration/language`: the language belongs to the person, not to a company.
|
|
443
|
+
*/
|
|
444
|
+
async updateMe(body) {
|
|
445
|
+
const { data } = await this.client.PATCH("/v1/me", { body });
|
|
446
|
+
return data.data;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
426
449
|
|
|
427
450
|
// src/resources/series.ts
|
|
428
451
|
var SeriesResource = class {
|
|
@@ -719,7 +742,10 @@ var AccountCompaniesResource = class {
|
|
|
719
742
|
const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
|
|
720
743
|
params: { path: { account_id: this.accountId }, query: params }
|
|
721
744
|
});
|
|
722
|
-
return {
|
|
745
|
+
return {
|
|
746
|
+
companies: data.data?.companies ?? [],
|
|
747
|
+
pagination: data.data?.pagination
|
|
748
|
+
};
|
|
723
749
|
}
|
|
724
750
|
/** Register a new company (NIF) under the account. */
|
|
725
751
|
async create(body) {
|
|
@@ -738,6 +764,134 @@ var AccountCompaniesResource = class {
|
|
|
738
764
|
}
|
|
739
765
|
};
|
|
740
766
|
|
|
767
|
+
// src/resources/payment-connections.ts
|
|
768
|
+
var CompanyPaymentConnectionsResource = class {
|
|
769
|
+
constructor(client, companyId) {
|
|
770
|
+
this.client = client;
|
|
771
|
+
this.companyId = companyId;
|
|
772
|
+
}
|
|
773
|
+
path() {
|
|
774
|
+
return { company_id: this.companyId };
|
|
775
|
+
}
|
|
776
|
+
/** Every payment connection of this company. */
|
|
777
|
+
async list() {
|
|
778
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/payment-connections", {
|
|
779
|
+
params: { path: this.path() }
|
|
780
|
+
});
|
|
781
|
+
return data.data;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Start an authorization and get the URL where the NIF's holder approves it.
|
|
785
|
+
*
|
|
786
|
+
* This is the one place the provider slug is used — currently only `stripe`.
|
|
787
|
+
*/
|
|
788
|
+
async authorize(body) {
|
|
789
|
+
const { data } = await this.client.POST(
|
|
790
|
+
"/v1/companies/{company_id}/payment-connections/authorizations",
|
|
791
|
+
{ params: { path: this.path() }, body }
|
|
792
|
+
);
|
|
793
|
+
return data.data;
|
|
794
|
+
}
|
|
795
|
+
/** Update one connection, addressed by its UUID. */
|
|
796
|
+
async update(connectionId, body) {
|
|
797
|
+
const { data } = await this.client.PATCH(
|
|
798
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}",
|
|
799
|
+
{ params: { path: { ...this.path(), connection_id: connectionId } }, body }
|
|
800
|
+
);
|
|
801
|
+
return data.data;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Disconnect one connection. Tokens are revoked and auto-invoicing stops;
|
|
805
|
+
* already-issued invoices are untouched.
|
|
806
|
+
*/
|
|
807
|
+
async disconnect(connectionId) {
|
|
808
|
+
await this.client.DELETE("/v1/companies/{company_id}/payment-connections/{connection_id}", {
|
|
809
|
+
params: { path: { ...this.path(), connection_id: connectionId } }
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
/** The payment events of one connection — where you audit what did and didn't invoice. */
|
|
813
|
+
events(connectionId) {
|
|
814
|
+
return new CompanyPaymentEventsResource(this.client, this.companyId, connectionId);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
var CompanyPaymentEventsResource = class {
|
|
818
|
+
constructor(client, companyId, connectionId) {
|
|
819
|
+
this.client = client;
|
|
820
|
+
this.companyId = companyId;
|
|
821
|
+
this.connectionId = connectionId;
|
|
822
|
+
}
|
|
823
|
+
path() {
|
|
824
|
+
return { company_id: this.companyId, connection_id: this.connectionId };
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Events of the connection, most recent first. Nothing is hidden by default:
|
|
828
|
+
* skipped events, duplicates and disputes are all returned — narrow with the
|
|
829
|
+
* filters. `charges_only` returns one row per money movement instead.
|
|
830
|
+
*/
|
|
831
|
+
async list(params) {
|
|
832
|
+
const { data } = await this.client.GET(
|
|
833
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events",
|
|
834
|
+
{ params: { path: this.path(), query: params } }
|
|
835
|
+
);
|
|
836
|
+
return data.data;
|
|
837
|
+
}
|
|
838
|
+
/** One event. */
|
|
839
|
+
async get(eventId) {
|
|
840
|
+
const { data } = await this.client.GET(
|
|
841
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}",
|
|
842
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
843
|
+
);
|
|
844
|
+
return data.data;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Reprocess an event whose automatic invoicing didn't complete, applying the NIF's
|
|
848
|
+
* **current** configuration. Only retryable states qualify and the retry budget is
|
|
849
|
+
* finite: otherwise `400`.
|
|
850
|
+
*/
|
|
851
|
+
async retry(eventId) {
|
|
852
|
+
const { data } = await this.client.POST(
|
|
853
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/retry",
|
|
854
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
855
|
+
);
|
|
856
|
+
return data.data;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Build a **draft** invoice from an event that couldn't be invoiced automatically,
|
|
860
|
+
* so you can review it before issuing. Returns the draft's id.
|
|
861
|
+
*/
|
|
862
|
+
async draft(eventId) {
|
|
863
|
+
const { data } = await this.client.POST(
|
|
864
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/draft",
|
|
865
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
866
|
+
);
|
|
867
|
+
return data.data;
|
|
868
|
+
}
|
|
869
|
+
/** Mark an event as dealt with outside the automatic flow. */
|
|
870
|
+
async resolve(eventId) {
|
|
871
|
+
const { data } = await this.client.POST(
|
|
872
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/resolve",
|
|
873
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
874
|
+
);
|
|
875
|
+
return data.data;
|
|
876
|
+
}
|
|
877
|
+
/** Discard an event so it stops asking for attention. Reversible with {@link restore}. */
|
|
878
|
+
async discard(eventId) {
|
|
879
|
+
const { data } = await this.client.POST(
|
|
880
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/discard",
|
|
881
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
882
|
+
);
|
|
883
|
+
return data.data;
|
|
884
|
+
}
|
|
885
|
+
/** Bring a discarded event back into the list. */
|
|
886
|
+
async restore(eventId) {
|
|
887
|
+
const { data } = await this.client.POST(
|
|
888
|
+
"/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/restore",
|
|
889
|
+
{ params: { path: { ...this.path(), event_id: eventId } } }
|
|
890
|
+
);
|
|
891
|
+
return data.data;
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
|
|
741
895
|
// src/resources/company.ts
|
|
742
896
|
var CompanyScope = class {
|
|
743
897
|
constructor(client, companyId) {
|
|
@@ -748,6 +902,9 @@ var CompanyScope = class {
|
|
|
748
902
|
this.products = new CompanyProductsResource(client, companyId);
|
|
749
903
|
this.series = new CompanySeriesResource(client, companyId);
|
|
750
904
|
this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);
|
|
905
|
+
this.paymentConnections = new CompanyPaymentConnectionsResource(client, companyId);
|
|
906
|
+
this.taxConfiguration = new CompanyTaxConfigurationResource(client, companyId);
|
|
907
|
+
this.verifactuConfiguration = new CompanyVeriFactuConfigurationResource(client, companyId);
|
|
751
908
|
}
|
|
752
909
|
path() {
|
|
753
910
|
return { company_id: this.companyId };
|
|
@@ -790,6 +947,17 @@ var CompanyInvoicesResource = class {
|
|
|
790
947
|
constructor(client, companyId) {
|
|
791
948
|
this.client = client;
|
|
792
949
|
this.companyId = companyId;
|
|
950
|
+
this.schedule = new CompanyInvoiceScheduleResource(client, companyId);
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Derive a new invoice from an existing one — the canonical form of `duplicate`.
|
|
954
|
+
*/
|
|
955
|
+
async derive(body) {
|
|
956
|
+
const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/derivations", {
|
|
957
|
+
params: { path: { company_id: this.companyId } },
|
|
958
|
+
body
|
|
959
|
+
});
|
|
960
|
+
return data.data;
|
|
793
961
|
}
|
|
794
962
|
path(rest) {
|
|
795
963
|
return { company_id: this.companyId, ...rest };
|
|
@@ -882,6 +1050,36 @@ var CompanyInvoicesResource = class {
|
|
|
882
1050
|
return data.data;
|
|
883
1051
|
}
|
|
884
1052
|
};
|
|
1053
|
+
var CompanyInvoiceScheduleResource = class {
|
|
1054
|
+
constructor(client, companyId) {
|
|
1055
|
+
this.client = client;
|
|
1056
|
+
this.companyId = companyId;
|
|
1057
|
+
}
|
|
1058
|
+
async get(invoiceId) {
|
|
1059
|
+
const { data } = await this.client.GET(
|
|
1060
|
+
"/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
|
|
1061
|
+
{ params: { path: { company_id: this.companyId, invoice_id: invoiceId } } }
|
|
1062
|
+
);
|
|
1063
|
+
return data.data;
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Set or move the schedule. One `PUT` replaces the three legacy calls
|
|
1067
|
+
* (`schedule`, `reschedule`, `unschedule`): setting it again moves it.
|
|
1068
|
+
*/
|
|
1069
|
+
async set(invoiceId, body) {
|
|
1070
|
+
const { data } = await this.client.PUT(
|
|
1071
|
+
"/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
|
|
1072
|
+
{ params: { path: { company_id: this.companyId, invoice_id: invoiceId } }, body }
|
|
1073
|
+
);
|
|
1074
|
+
return data.data;
|
|
1075
|
+
}
|
|
1076
|
+
/** Clear the schedule — the canonical form of `unschedule`. */
|
|
1077
|
+
async clear(invoiceId) {
|
|
1078
|
+
await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}/schedule", {
|
|
1079
|
+
params: { path: { company_id: this.companyId, invoice_id: invoiceId } }
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
885
1083
|
var CompanyCustomersResource = class {
|
|
886
1084
|
constructor(client, companyId) {
|
|
887
1085
|
this.client = client;
|
|
@@ -1089,16 +1287,57 @@ var CompanyRecurringInvoicesResource = class {
|
|
|
1089
1287
|
return data.data;
|
|
1090
1288
|
}
|
|
1091
1289
|
};
|
|
1290
|
+
var CompanyTaxConfigurationResource = class {
|
|
1291
|
+
constructor(client, companyId) {
|
|
1292
|
+
this.client = client;
|
|
1293
|
+
this.companyId = companyId;
|
|
1294
|
+
}
|
|
1295
|
+
async get() {
|
|
1296
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/tax-configuration", {
|
|
1297
|
+
params: { path: { company_id: this.companyId } }
|
|
1298
|
+
});
|
|
1299
|
+
return data.data;
|
|
1300
|
+
}
|
|
1301
|
+
/** Replaces the whole state — this is a `PUT`, not a merge. */
|
|
1302
|
+
async update(body) {
|
|
1303
|
+
const { data } = await this.client.PUT("/v1/companies/{company_id}/tax-configuration", {
|
|
1304
|
+
params: { path: { company_id: this.companyId } },
|
|
1305
|
+
body
|
|
1306
|
+
});
|
|
1307
|
+
return data.data;
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
var CompanyVeriFactuConfigurationResource = class {
|
|
1311
|
+
constructor(client, companyId) {
|
|
1312
|
+
this.client = client;
|
|
1313
|
+
this.companyId = companyId;
|
|
1314
|
+
}
|
|
1315
|
+
async get() {
|
|
1316
|
+
const { data } = await this.client.GET("/v1/companies/{company_id}/verifactu-configuration", {
|
|
1317
|
+
params: { path: { company_id: this.companyId } }
|
|
1318
|
+
});
|
|
1319
|
+
return data.data;
|
|
1320
|
+
}
|
|
1321
|
+
/** Flip VeriFactu for this NIF. `enabled` is the only field you can write. */
|
|
1322
|
+
async update(body) {
|
|
1323
|
+
const { data } = await this.client.PUT("/v1/companies/{company_id}/verifactu-configuration", {
|
|
1324
|
+
params: { path: { company_id: this.companyId } },
|
|
1325
|
+
body
|
|
1326
|
+
});
|
|
1327
|
+
return data.data;
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1092
1330
|
|
|
1093
1331
|
// src/client.ts
|
|
1094
1332
|
var BeeL = class {
|
|
1095
1333
|
constructor(config) {
|
|
1096
1334
|
const client = createBeeLClient(config);
|
|
1097
|
-
this.
|
|
1335
|
+
this.raw = client;
|
|
1098
1336
|
this.invoices = new InvoicesResource(client);
|
|
1099
1337
|
this.customers = new CustomersResource(client);
|
|
1100
1338
|
this.products = new ProductsResource(client);
|
|
1101
1339
|
this.configuration = new ConfigurationResource(client);
|
|
1340
|
+
this.catalogs = new CatalogsResource(client);
|
|
1102
1341
|
this.series = new SeriesResource(client);
|
|
1103
1342
|
this.nif = new NifResource(client);
|
|
1104
1343
|
this.accounts = new AccountsResource(client);
|
|
@@ -1114,7 +1353,7 @@ var BeeL = class {
|
|
|
1114
1353
|
* ```
|
|
1115
1354
|
*/
|
|
1116
1355
|
company(companyId) {
|
|
1117
|
-
return new CompanyScope(this.
|
|
1356
|
+
return new CompanyScope(this.raw, companyId);
|
|
1118
1357
|
}
|
|
1119
1358
|
/**
|
|
1120
1359
|
* Returns a facade scoped to one managed account — members, invitations,
|
|
@@ -1127,7 +1366,7 @@ var BeeL = class {
|
|
|
1127
1366
|
* ```
|
|
1128
1367
|
*/
|
|
1129
1368
|
account(accountId) {
|
|
1130
|
-
return new AccountScope(this.
|
|
1369
|
+
return new AccountScope(this.raw, accountId);
|
|
1131
1370
|
}
|
|
1132
1371
|
/**
|
|
1133
1372
|
* Download an invoice PDF as a Buffer.
|
|
@@ -1481,12 +1720,18 @@ export {
|
|
|
1481
1720
|
BeeLNotFoundError,
|
|
1482
1721
|
BeeLRateLimitError,
|
|
1483
1722
|
BeeLValidationError,
|
|
1723
|
+
CatalogsResource,
|
|
1484
1724
|
CompanyCustomersResource,
|
|
1725
|
+
CompanyInvoiceScheduleResource,
|
|
1485
1726
|
CompanyInvoicesResource,
|
|
1727
|
+
CompanyPaymentConnectionsResource,
|
|
1728
|
+
CompanyPaymentEventsResource,
|
|
1486
1729
|
CompanyProductsResource,
|
|
1487
1730
|
CompanyRecurringInvoicesResource,
|
|
1488
1731
|
CompanyScope,
|
|
1489
1732
|
CompanySeriesResource,
|
|
1733
|
+
CompanyTaxConfigurationResource,
|
|
1734
|
+
CompanyVeriFactuConfigurationResource,
|
|
1490
1735
|
CustomerBuilder,
|
|
1491
1736
|
InvoiceBuilder,
|
|
1492
1737
|
VeriFactuSubmissionStatus,
|