@beel_es/sdk 1.1.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/dist/index.js CHANGED
@@ -30,6 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AccountCompaniesResource: () => AccountCompaniesResource,
34
+ AccountInvitationsResource: () => AccountInvitationsResource,
35
+ AccountMembersResource: () => AccountMembersResource,
36
+ AccountScope: () => AccountScope,
37
+ AccountWebhooksResource: () => AccountWebhooksResource,
38
+ AccountsResource: () => AccountsResource,
33
39
  BeeL: () => BeeL,
34
40
  BeeLApiError: () => BeeLApiError,
35
41
  BeeLAuthError: () => BeeLAuthError,
@@ -37,8 +43,22 @@ __export(index_exports, {
37
43
  BeeLNotFoundError: () => BeeLNotFoundError,
38
44
  BeeLRateLimitError: () => BeeLRateLimitError,
39
45
  BeeLValidationError: () => BeeLValidationError,
46
+ CatalogsResource: () => CatalogsResource,
47
+ CompanyCustomersResource: () => CompanyCustomersResource,
48
+ CompanyInvoiceScheduleResource: () => CompanyInvoiceScheduleResource,
49
+ CompanyInvoicesResource: () => CompanyInvoicesResource,
50
+ CompanyPaymentConnectionsResource: () => CompanyPaymentConnectionsResource,
51
+ CompanyPaymentEventsResource: () => CompanyPaymentEventsResource,
52
+ CompanyProductsResource: () => CompanyProductsResource,
53
+ CompanyRecurringInvoicesResource: () => CompanyRecurringInvoicesResource,
54
+ CompanyScope: () => CompanyScope,
55
+ CompanySeriesResource: () => CompanySeriesResource,
56
+ CompanyTaxConfigurationResource: () => CompanyTaxConfigurationResource,
57
+ CompanyVeriFactuConfigurationResource: () => CompanyVeriFactuConfigurationResource,
40
58
  CustomerBuilder: () => CustomerBuilder,
41
59
  InvoiceBuilder: () => InvoiceBuilder,
60
+ VeriFactuSubmissionStatus: () => VeriFactuSubmissionStatus,
61
+ WebhookEventType: () => WebhookEventType,
42
62
  WebhookVerificationError: () => WebhookVerificationError,
43
63
  WebhookVerifier: () => WebhookVerifier
44
64
  });
@@ -469,6 +489,29 @@ var ConfigurationResource = class {
469
489
  return data.data;
470
490
  }
471
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
+ };
472
515
 
473
516
  // src/resources/series.ts
474
517
  var SeriesResource = class {
@@ -534,20 +577,869 @@ var NifResource = class {
534
577
  }
535
578
  };
536
579
 
580
+ // src/resources/accounts.ts
581
+ var AccountsResource = class {
582
+ constructor(client) {
583
+ this.client = client;
584
+ }
585
+ /** List accounts reachable with this API key (cursor-paginated). */
586
+ async list(params) {
587
+ const { data } = await this.client.GET("/v1/accounts", { params: { query: params } });
588
+ return data.data;
589
+ }
590
+ /** Provision a new managed account. */
591
+ async provision(body) {
592
+ const { data } = await this.client.POST("/v1/accounts", { body });
593
+ return data.data;
594
+ }
595
+ /** Get a managed account by ID. */
596
+ async get(accountId) {
597
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", {
598
+ params: { path: { account_id: accountId } }
599
+ });
600
+ return data.data;
601
+ }
602
+ /** Alias of `beel.account(accountId)` — returns an account-scoped facade. */
603
+ scope(accountId) {
604
+ return new AccountScope(this.client, accountId);
605
+ }
606
+ };
607
+ var AccountScope = class {
608
+ constructor(client, accountId) {
609
+ this.client = client;
610
+ this.accountId = accountId;
611
+ this.members = new AccountMembersResource(client, accountId);
612
+ this.invitations = new AccountInvitationsResource(client, accountId);
613
+ this.webhooks = new AccountWebhooksResource(client, accountId);
614
+ this.companies = new AccountCompaniesResource(client, accountId);
615
+ }
616
+ path() {
617
+ return { account_id: this.accountId };
618
+ }
619
+ /** Get the account summary. */
620
+ async get() {
621
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", { params: { path: this.path() } });
622
+ return data.data;
623
+ }
624
+ /** Provisioning usage counters (accounts, NIFs) for billing purposes. */
625
+ async usage() {
626
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/usage", { params: { path: this.path() } });
627
+ return data.data;
628
+ }
629
+ /** Change the manager's access level over this account. */
630
+ async changeAccessLevel(body) {
631
+ await this.client.PATCH("/v1/accounts/{account_id}/access-level", {
632
+ params: { path: this.path() },
633
+ body
634
+ });
635
+ }
636
+ /** End the management relationship with this account. */
637
+ async endManagement() {
638
+ await this.client.DELETE("/v1/accounts/{account_id}/management", { params: { path: this.path() } });
639
+ }
640
+ /** Create a claim token so the end user can take ownership of the account. */
641
+ async createClaimToken(body) {
642
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/claim-tokens", {
643
+ params: { path: this.path() },
644
+ body: body ?? {}
645
+ });
646
+ return data.data;
647
+ }
648
+ /** Transfer account ownership to an existing member. */
649
+ async setOwner(body) {
650
+ await this.client.PUT("/v1/accounts/{account_id}/owner", {
651
+ params: { path: this.path() },
652
+ body
653
+ });
654
+ }
655
+ };
656
+ var AccountMembersResource = class {
657
+ constructor(client, accountId) {
658
+ this.client = client;
659
+ this.accountId = accountId;
660
+ }
661
+ async list() {
662
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members", {
663
+ params: { path: { account_id: this.accountId } }
664
+ });
665
+ return data.data.members;
666
+ }
667
+ async get(memberId) {
668
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}", {
669
+ params: { path: { account_id: this.accountId, member_id: memberId } }
670
+ });
671
+ return data.data;
672
+ }
673
+ /** Update a member's account role. */
674
+ async update(memberId, body) {
675
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/members/{member_id}", {
676
+ params: { path: { account_id: this.accountId, member_id: memberId } },
677
+ body
678
+ });
679
+ return data.data;
680
+ }
681
+ /** Remove a member from the account. */
682
+ async remove(memberId) {
683
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}", {
684
+ params: { path: { account_id: this.accountId, member_id: memberId } }
685
+ });
686
+ }
687
+ /** List a member's per-company grants. */
688
+ async listGrants(memberId) {
689
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}/grants", {
690
+ params: { path: { account_id: this.accountId, member_id: memberId } }
691
+ });
692
+ return data.data;
693
+ }
694
+ /** Grant (or replace) a member's permissions over one company. */
695
+ async putGrant(memberId, companyId, body) {
696
+ const { data } = await this.client.PUT("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
697
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },
698
+ body
699
+ });
700
+ return data.data;
701
+ }
702
+ /** Revoke a member's grant over one company. */
703
+ async removeGrant(memberId, companyId) {
704
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
705
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } }
706
+ });
707
+ }
708
+ };
709
+ var AccountInvitationsResource = class {
710
+ constructor(client, accountId) {
711
+ this.client = client;
712
+ this.accountId = accountId;
713
+ }
714
+ async list() {
715
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations", {
716
+ params: { path: { account_id: this.accountId } }
717
+ });
718
+ return data.data;
719
+ }
720
+ async create(body) {
721
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/invitations", {
722
+ params: { path: { account_id: this.accountId } },
723
+ body
724
+ });
725
+ return data.data;
726
+ }
727
+ async get(invitationId) {
728
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations/{invitation_id}", {
729
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
730
+ });
731
+ return data.data;
732
+ }
733
+ async revoke(invitationId) {
734
+ await this.client.DELETE("/v1/accounts/{account_id}/invitations/{invitation_id}", {
735
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
736
+ });
737
+ }
738
+ };
739
+ var AccountWebhooksResource = class {
740
+ constructor(client, accountId) {
741
+ this.client = client;
742
+ this.accountId = accountId;
743
+ }
744
+ async list(params) {
745
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks", {
746
+ params: { path: { account_id: this.accountId }, query: params }
747
+ });
748
+ return data.data;
749
+ }
750
+ async create(body) {
751
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks", {
752
+ params: { path: { account_id: this.accountId } },
753
+ body
754
+ });
755
+ return data.data;
756
+ }
757
+ async get(webhookId) {
758
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
759
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
760
+ });
761
+ return data.data;
762
+ }
763
+ async update(webhookId, body) {
764
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
765
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } },
766
+ body
767
+ });
768
+ return data.data;
769
+ }
770
+ async delete(webhookId) {
771
+ await this.client.DELETE("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
772
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
773
+ });
774
+ }
775
+ /** Send a test event to the webhook endpoint. */
776
+ async test(webhookId) {
777
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/test", {
778
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
779
+ });
780
+ return data.data;
781
+ }
782
+ /** Rotate the webhook signing secret. */
783
+ async rotateSecret(webhookId) {
784
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/secret", {
785
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
786
+ });
787
+ return data.data;
788
+ }
789
+ async listDeliveries(webhookId, params) {
790
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries", {
791
+ params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params }
792
+ });
793
+ return data.data;
794
+ }
795
+ async retryDelivery(webhookId, deliveryId) {
796
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry", {
797
+ params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } }
798
+ });
799
+ return data.data;
800
+ }
801
+ };
802
+ var AccountCompaniesResource = class {
803
+ constructor(client, accountId) {
804
+ this.client = client;
805
+ this.accountId = accountId;
806
+ }
807
+ async list(params) {
808
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
809
+ params: { path: { account_id: this.accountId }, query: params }
810
+ });
811
+ return {
812
+ companies: data.data?.companies ?? [],
813
+ pagination: data.data?.pagination
814
+ };
815
+ }
816
+ /** Register a new company (NIF) under the account. */
817
+ async create(body) {
818
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/companies", {
819
+ params: { path: { account_id: this.accountId } },
820
+ body
821
+ });
822
+ return data.data;
823
+ }
824
+ /** Aggregated per-company stats for the account. */
825
+ async stats() {
826
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies/stats", {
827
+ params: { path: { account_id: this.accountId } }
828
+ });
829
+ return data.data;
830
+ }
831
+ };
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
+
961
+ // src/resources/company.ts
962
+ var CompanyScope = class {
963
+ constructor(client, companyId) {
964
+ this.client = client;
965
+ this.companyId = companyId;
966
+ this.invoices = new CompanyInvoicesResource(client, companyId);
967
+ this.customers = new CompanyCustomersResource(client, companyId);
968
+ this.products = new CompanyProductsResource(client, companyId);
969
+ this.series = new CompanySeriesResource(client, companyId);
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);
974
+ }
975
+ path() {
976
+ return { company_id: this.companyId };
977
+ }
978
+ /** Get the company. */
979
+ async get(params) {
980
+ const { data } = await this.client.GET("/v1/companies/{company_id}", {
981
+ params: { path: this.path(), query: params }
982
+ });
983
+ return data.data;
984
+ }
985
+ /** Update company data. */
986
+ async update(body) {
987
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}", {
988
+ params: { path: this.path() },
989
+ body
990
+ });
991
+ return data.data;
992
+ }
993
+ /** Delete the company. */
994
+ async delete() {
995
+ await this.client.DELETE("/v1/companies/{company_id}", { params: { path: this.path() } });
996
+ }
997
+ /** Fiscal summary (VAT/IRPF aggregates) for the company. */
998
+ async fiscalSummary(params) {
999
+ const { data } = await this.client.GET("/v1/companies/{company_id}/fiscal-summary", {
1000
+ params: { path: this.path(), query: params }
1001
+ });
1002
+ return data.data;
1003
+ }
1004
+ /** Whether the company can already issue invoices, and what is missing if not. */
1005
+ async issuingReadiness() {
1006
+ const { data } = await this.client.GET("/v1/companies/{company_id}/issuing-readiness", {
1007
+ params: { path: this.path() }
1008
+ });
1009
+ return data.data;
1010
+ }
1011
+ };
1012
+ var CompanyInvoicesResource = class {
1013
+ constructor(client, companyId) {
1014
+ this.client = client;
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;
1027
+ }
1028
+ path(rest) {
1029
+ return { company_id: this.companyId, ...rest };
1030
+ }
1031
+ async list(params) {
1032
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices", {
1033
+ params: { path: this.path(), query: params }
1034
+ });
1035
+ return data.data;
1036
+ }
1037
+ async create(body, params) {
1038
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices", {
1039
+ params: { path: this.path(), query: params },
1040
+ body
1041
+ });
1042
+ return data.data;
1043
+ }
1044
+ async get(invoiceId) {
1045
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}", {
1046
+ params: { path: this.path({ invoice_id: invoiceId }) }
1047
+ });
1048
+ return data.data;
1049
+ }
1050
+ /** Update a draft invoice. */
1051
+ async update(invoiceId, body) {
1052
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/invoices/{invoice_id}", {
1053
+ params: { path: this.path({ invoice_id: invoiceId }) },
1054
+ body
1055
+ });
1056
+ return data.data;
1057
+ }
1058
+ /** Delete a draft invoice. */
1059
+ async delete(invoiceId) {
1060
+ await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}", {
1061
+ params: { path: this.path({ invoice_id: invoiceId }) }
1062
+ });
1063
+ }
1064
+ /** Issue a draft invoice (assigns number, submits to VeriFactu when configured). */
1065
+ async issue(invoiceId, params) {
1066
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/issue", {
1067
+ params: { path: this.path({ invoice_id: invoiceId }), query: params }
1068
+ });
1069
+ return data.data;
1070
+ }
1071
+ /** Void an issued invoice. */
1072
+ async void(invoiceId, body) {
1073
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/void", {
1074
+ params: { path: this.path({ invoice_id: invoiceId }) },
1075
+ body
1076
+ });
1077
+ return data.data;
1078
+ }
1079
+ /** Create a corrective (rectificativa) for an issued invoice. */
1080
+ async createCorrective(invoiceId, body) {
1081
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/corrective", {
1082
+ params: { path: this.path({ invoice_id: invoiceId }) },
1083
+ body
1084
+ });
1085
+ return data.data;
1086
+ }
1087
+ /** Convert a proforma into an invoice. */
1088
+ async convertToInvoice(invoiceId, body) {
1089
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice", {
1090
+ params: { path: this.path({ invoice_id: invoiceId }) },
1091
+ body
1092
+ });
1093
+ return data.data;
1094
+ }
1095
+ /** Update payment status (e.g. mark as paid). */
1096
+ async setStatus(invoiceId, body) {
1097
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/invoices/{invoice_id}/status", {
1098
+ params: { path: this.path({ invoice_id: invoiceId }) },
1099
+ body
1100
+ });
1101
+ return data.data;
1102
+ }
1103
+ /** Get PDF metadata and download URL. */
1104
+ async getPdf(invoiceId) {
1105
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}/pdf", {
1106
+ params: { path: this.path({ invoice_id: invoiceId }) }
1107
+ });
1108
+ return data.data;
1109
+ }
1110
+ /** Send the invoice by email to the customer. */
1111
+ async send(invoiceId, body) {
1112
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/send", {
1113
+ params: { path: this.path({ invoice_id: invoiceId }) },
1114
+ body
1115
+ });
1116
+ return data.data;
1117
+ }
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
+ };
1149
+ var CompanyCustomersResource = class {
1150
+ constructor(client, companyId) {
1151
+ this.client = client;
1152
+ this.companyId = companyId;
1153
+ }
1154
+ async list(params) {
1155
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers", {
1156
+ params: { path: { company_id: this.companyId }, query: params }
1157
+ });
1158
+ return data.data;
1159
+ }
1160
+ async create(body) {
1161
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers", {
1162
+ params: { path: { company_id: this.companyId } },
1163
+ body
1164
+ });
1165
+ return data.data;
1166
+ }
1167
+ async createBulk(body) {
1168
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers/bulk", {
1169
+ params: { path: { company_id: this.companyId } },
1170
+ body
1171
+ });
1172
+ return data.data;
1173
+ }
1174
+ async get(customerId) {
1175
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers/{customer_id}", {
1176
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
1177
+ });
1178
+ return data.data;
1179
+ }
1180
+ async update(customerId, body) {
1181
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/customers/{customer_id}", {
1182
+ params: { path: { company_id: this.companyId, customer_id: customerId } },
1183
+ body
1184
+ });
1185
+ return data.data;
1186
+ }
1187
+ async delete(customerId) {
1188
+ await this.client.DELETE("/v1/companies/{company_id}/customers/{customer_id}", {
1189
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
1190
+ });
1191
+ }
1192
+ };
1193
+ var CompanyProductsResource = class {
1194
+ constructor(client, companyId) {
1195
+ this.client = client;
1196
+ this.companyId = companyId;
1197
+ }
1198
+ async list(params) {
1199
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products", {
1200
+ params: { path: { company_id: this.companyId }, query: params }
1201
+ });
1202
+ return data.data;
1203
+ }
1204
+ async create(body) {
1205
+ const { data } = await this.client.POST("/v1/companies/{company_id}/products", {
1206
+ params: { path: { company_id: this.companyId } },
1207
+ body
1208
+ });
1209
+ return data.data;
1210
+ }
1211
+ async get(productId) {
1212
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products/{product_id}", {
1213
+ params: { path: { company_id: this.companyId, product_id: productId } }
1214
+ });
1215
+ return data.data;
1216
+ }
1217
+ async update(productId, body) {
1218
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/products/{product_id}", {
1219
+ params: { path: { company_id: this.companyId, product_id: productId } },
1220
+ body
1221
+ });
1222
+ return data.data;
1223
+ }
1224
+ async delete(productId) {
1225
+ await this.client.DELETE("/v1/companies/{company_id}/products/{product_id}", {
1226
+ params: { path: { company_id: this.companyId, product_id: productId } }
1227
+ });
1228
+ }
1229
+ };
1230
+ var CompanySeriesResource = class {
1231
+ constructor(client, companyId) {
1232
+ this.client = client;
1233
+ this.companyId = companyId;
1234
+ }
1235
+ async list(params) {
1236
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series", {
1237
+ params: { path: { company_id: this.companyId }, query: params }
1238
+ });
1239
+ return data.data;
1240
+ }
1241
+ async create(body) {
1242
+ const { data } = await this.client.POST("/v1/companies/{company_id}/series", {
1243
+ params: { path: { company_id: this.companyId } },
1244
+ body
1245
+ });
1246
+ return data.data;
1247
+ }
1248
+ async update(seriesId, body) {
1249
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/series/{series_id}", {
1250
+ params: { path: { company_id: this.companyId, series_id: seriesId } },
1251
+ body
1252
+ });
1253
+ return data.data;
1254
+ }
1255
+ async delete(seriesId) {
1256
+ await this.client.DELETE("/v1/companies/{company_id}/series/{series_id}", {
1257
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1258
+ });
1259
+ }
1260
+ /** Current default series per invoice type. */
1261
+ async getDefaults() {
1262
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series/defaults", {
1263
+ params: { path: { company_id: this.companyId } }
1264
+ });
1265
+ return data.data;
1266
+ }
1267
+ /** Ensure the three typed default series exist (idempotent seeding). */
1268
+ async ensureDefaults() {
1269
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/defaults", {
1270
+ params: { path: { company_id: this.companyId } }
1271
+ });
1272
+ return data.data;
1273
+ }
1274
+ /** Mark a series as the default for its invoice type. */
1275
+ async setDefault(seriesId) {
1276
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/{series_id}/default", {
1277
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1278
+ });
1279
+ return data.data;
1280
+ }
1281
+ };
1282
+ var CompanyRecurringInvoicesResource = class {
1283
+ constructor(client, companyId) {
1284
+ this.client = client;
1285
+ this.companyId = companyId;
1286
+ }
1287
+ path(rest) {
1288
+ return { company_id: this.companyId, ...rest };
1289
+ }
1290
+ async list(params) {
1291
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices", {
1292
+ params: { path: this.path(), query: params }
1293
+ });
1294
+ return data.data;
1295
+ }
1296
+ async create(body) {
1297
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices", {
1298
+ params: { path: this.path() },
1299
+ body
1300
+ });
1301
+ return data.data;
1302
+ }
1303
+ async get(recurringInvoiceId) {
1304
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1305
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1306
+ });
1307
+ return data.data;
1308
+ }
1309
+ async update(recurringInvoiceId, body) {
1310
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1311
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1312
+ body
1313
+ });
1314
+ return data.data;
1315
+ }
1316
+ async delete(recurringInvoiceId) {
1317
+ await this.client.DELETE("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1318
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1319
+ });
1320
+ }
1321
+ /** Pause or resume the schedule. */
1322
+ async setStatus(recurringInvoiceId, body) {
1323
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status", {
1324
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1325
+ body
1326
+ });
1327
+ return data.data;
1328
+ }
1329
+ /** Skip the next scheduled occurrence. */
1330
+ async skip(recurringInvoiceId) {
1331
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip", {
1332
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1333
+ });
1334
+ return data.data;
1335
+ }
1336
+ /** Generate the next invoice now instead of waiting for the schedule. */
1337
+ async generateNow(recurringInvoiceId) {
1338
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate", {
1339
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1340
+ });
1341
+ return data.data;
1342
+ }
1343
+ async nextOccurrence(recurringInvoiceId) {
1344
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence", {
1345
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1346
+ });
1347
+ return data.data;
1348
+ }
1349
+ async history(recurringInvoiceId, params) {
1350
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history", {
1351
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params }
1352
+ });
1353
+ return data.data;
1354
+ }
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
+ };
1396
+
537
1397
  // src/client.ts
538
1398
  var BeeL = class {
539
1399
  constructor(config) {
540
1400
  const client = createBeeLClient(config);
1401
+ this.raw = client;
541
1402
  this.invoices = new InvoicesResource(client);
542
1403
  this.customers = new CustomersResource(client);
543
1404
  this.products = new ProductsResource(client);
544
1405
  this.configuration = new ConfigurationResource(client);
1406
+ this.catalogs = new CatalogsResource(client);
545
1407
  this.series = new SeriesResource(client);
546
1408
  this.nif = new NifResource(client);
1409
+ this.accounts = new AccountsResource(client);
1410
+ }
1411
+ /**
1412
+ * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.
1413
+ * All operations address the company in the path, no session focus needed.
1414
+ *
1415
+ * @example
1416
+ * ```typescript
1417
+ * const company = beel.company('company-uuid');
1418
+ * const { invoices } = await company.invoices.list({ status: 'ISSUED' });
1419
+ * ```
1420
+ */
1421
+ company(companyId) {
1422
+ return new CompanyScope(this.raw, companyId);
1423
+ }
1424
+ /**
1425
+ * Returns a facade scoped to one managed account — members, invitations,
1426
+ * account webhooks, companies, usage. Symmetric with {@link company}.
1427
+ *
1428
+ * @example
1429
+ * ```typescript
1430
+ * const account = beel.account('account-uuid');
1431
+ * const members = await account.members.list();
1432
+ * ```
1433
+ */
1434
+ account(accountId) {
1435
+ return new AccountScope(this.raw, accountId);
547
1436
  }
548
1437
  /**
549
1438
  * Download an invoice PDF as a Buffer.
550
1439
  *
1440
+ * @deprecated Relies on the deprecated session-focus PDF endpoint. Use
1441
+ * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.
1442
+ *
551
1443
  * @example
552
1444
  * ```typescript
553
1445
  * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');
@@ -679,6 +1571,100 @@ var WebhookVerificationError = class extends Error {
679
1571
  }
680
1572
  };
681
1573
 
1574
+ // src/generated-webhooks/models/AccountClaimedEvent.ts
1575
+ var AccountClaimedEvent;
1576
+ ((AccountClaimedEvent2) => {
1577
+ let type;
1578
+ ((type2) => {
1579
+ type2["ACCOUNT_CLAIMED"] = "account.claimed";
1580
+ })(type = AccountClaimedEvent2.type || (AccountClaimedEvent2.type = {}));
1581
+ })(AccountClaimedEvent || (AccountClaimedEvent = {}));
1582
+
1583
+ // src/generated-webhooks/models/CompanyCreatedEvent.ts
1584
+ var CompanyCreatedEvent;
1585
+ ((CompanyCreatedEvent2) => {
1586
+ let type;
1587
+ ((type2) => {
1588
+ type2["COMPANY_CREATED"] = "company.created";
1589
+ })(type = CompanyCreatedEvent2.type || (CompanyCreatedEvent2.type = {}));
1590
+ })(CompanyCreatedEvent || (CompanyCreatedEvent = {}));
1591
+
1592
+ // src/generated-webhooks/models/InvoiceEmailSentEvent.ts
1593
+ var InvoiceEmailSentEvent;
1594
+ ((InvoiceEmailSentEvent2) => {
1595
+ let type;
1596
+ ((type2) => {
1597
+ type2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1598
+ })(type = InvoiceEmailSentEvent2.type || (InvoiceEmailSentEvent2.type = {}));
1599
+ })(InvoiceEmailSentEvent || (InvoiceEmailSentEvent = {}));
1600
+
1601
+ // src/generated-webhooks/models/InvoiceIssuedEvent.ts
1602
+ var InvoiceIssuedEvent;
1603
+ ((InvoiceIssuedEvent2) => {
1604
+ let type;
1605
+ ((type2) => {
1606
+ type2["INVOICE_ISSUED"] = "invoice.issued";
1607
+ })(type = InvoiceIssuedEvent2.type || (InvoiceIssuedEvent2.type = {}));
1608
+ })(InvoiceIssuedEvent || (InvoiceIssuedEvent = {}));
1609
+
1610
+ // src/generated-webhooks/models/InvoiceVoidedEvent.ts
1611
+ var InvoiceVoidedEvent;
1612
+ ((InvoiceVoidedEvent2) => {
1613
+ let type;
1614
+ ((type2) => {
1615
+ type2["INVOICE_VOIDED"] = "invoice.voided";
1616
+ })(type = InvoiceVoidedEvent2.type || (InvoiceVoidedEvent2.type = {}));
1617
+ })(InvoiceVoidedEvent || (InvoiceVoidedEvent = {}));
1618
+
1619
+ // src/generated-webhooks/models/RecurringInvoicePausedEvent.ts
1620
+ var RecurringInvoicePausedEvent;
1621
+ ((RecurringInvoicePausedEvent2) => {
1622
+ let type;
1623
+ ((type2) => {
1624
+ type2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1625
+ })(type = RecurringInvoicePausedEvent2.type || (RecurringInvoicePausedEvent2.type = {}));
1626
+ })(RecurringInvoicePausedEvent || (RecurringInvoicePausedEvent = {}));
1627
+
1628
+ // src/generated-webhooks/models/RepresentationSignedEvent.ts
1629
+ var RepresentationSignedEvent;
1630
+ ((RepresentationSignedEvent2) => {
1631
+ let type;
1632
+ ((type2) => {
1633
+ type2["REPRESENTATION_SIGNED"] = "representation.signed";
1634
+ })(type = RepresentationSignedEvent2.type || (RepresentationSignedEvent2.type = {}));
1635
+ })(RepresentationSignedEvent || (RepresentationSignedEvent = {}));
1636
+
1637
+ // src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts
1638
+ var VeriFactuStatusUpdatedEvent;
1639
+ ((VeriFactuStatusUpdatedEvent2) => {
1640
+ let type;
1641
+ ((type2) => {
1642
+ type2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1643
+ })(type = VeriFactuStatusUpdatedEvent2.type || (VeriFactuStatusUpdatedEvent2.type = {}));
1644
+ })(VeriFactuStatusUpdatedEvent || (VeriFactuStatusUpdatedEvent = {}));
1645
+
1646
+ // src/generated-webhooks/models/VeriFactuSubmissionStatus.ts
1647
+ var VeriFactuSubmissionStatus = /* @__PURE__ */ ((VeriFactuSubmissionStatus2) => {
1648
+ VeriFactuSubmissionStatus2["PENDING"] = "PENDING";
1649
+ VeriFactuSubmissionStatus2["ACCEPTED"] = "ACCEPTED";
1650
+ VeriFactuSubmissionStatus2["VOIDED"] = "VOIDED";
1651
+ VeriFactuSubmissionStatus2["REJECTED"] = "REJECTED";
1652
+ return VeriFactuSubmissionStatus2;
1653
+ })(VeriFactuSubmissionStatus || {});
1654
+
1655
+ // src/generated-webhooks/models/WebhookEventType.ts
1656
+ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
1657
+ WebhookEventType2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1658
+ WebhookEventType2["INVOICE_ISSUED"] = "invoice.issued";
1659
+ WebhookEventType2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1660
+ WebhookEventType2["INVOICE_VOIDED"] = "invoice.voided";
1661
+ WebhookEventType2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1662
+ WebhookEventType2["ACCOUNT_CLAIMED"] = "account.claimed";
1663
+ WebhookEventType2["COMPANY_CREATED"] = "company.created";
1664
+ WebhookEventType2["REPRESENTATION_SIGNED"] = "representation.signed";
1665
+ return WebhookEventType2;
1666
+ })(WebhookEventType || {});
1667
+
682
1668
  // src/builders/customer-builder.ts
683
1669
  var CustomerBuilder = class _CustomerBuilder {
684
1670
  constructor() {
@@ -751,7 +1737,7 @@ var InvoiceBuilder = class _InvoiceBuilder {
751
1737
  return this;
752
1738
  }
753
1739
  addLine(description, quantity, unitPrice, discountPercentage = 0) {
754
- this._lines.push({ description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
1740
+ this._lines.push({ line_type: "NORMAL", description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
755
1741
  return this;
756
1742
  }
757
1743
  addLineObject(line) {
@@ -788,6 +1774,12 @@ var InvoiceBuilder = class _InvoiceBuilder {
788
1774
  };
789
1775
  // Annotate the CommonJS export names for ESM import in node:
790
1776
  0 && (module.exports = {
1777
+ AccountCompaniesResource,
1778
+ AccountInvitationsResource,
1779
+ AccountMembersResource,
1780
+ AccountScope,
1781
+ AccountWebhooksResource,
1782
+ AccountsResource,
791
1783
  BeeL,
792
1784
  BeeLApiError,
793
1785
  BeeLAuthError,
@@ -795,8 +1787,22 @@ var InvoiceBuilder = class _InvoiceBuilder {
795
1787
  BeeLNotFoundError,
796
1788
  BeeLRateLimitError,
797
1789
  BeeLValidationError,
1790
+ CatalogsResource,
1791
+ CompanyCustomersResource,
1792
+ CompanyInvoiceScheduleResource,
1793
+ CompanyInvoicesResource,
1794
+ CompanyPaymentConnectionsResource,
1795
+ CompanyPaymentEventsResource,
1796
+ CompanyProductsResource,
1797
+ CompanyRecurringInvoicesResource,
1798
+ CompanyScope,
1799
+ CompanySeriesResource,
1800
+ CompanyTaxConfigurationResource,
1801
+ CompanyVeriFactuConfigurationResource,
798
1802
  CustomerBuilder,
799
1803
  InvoiceBuilder,
1804
+ VeriFactuSubmissionStatus,
1805
+ WebhookEventType,
800
1806
  WebhookVerificationError,
801
1807
  WebhookVerifier
802
1808
  });