@beel_es/sdk 1.1.0 → 1.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/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,16 @@ __export(index_exports, {
37
43
  BeeLNotFoundError: () => BeeLNotFoundError,
38
44
  BeeLRateLimitError: () => BeeLRateLimitError,
39
45
  BeeLValidationError: () => BeeLValidationError,
46
+ CompanyCustomersResource: () => CompanyCustomersResource,
47
+ CompanyInvoicesResource: () => CompanyInvoicesResource,
48
+ CompanyProductsResource: () => CompanyProductsResource,
49
+ CompanyRecurringInvoicesResource: () => CompanyRecurringInvoicesResource,
50
+ CompanyScope: () => CompanyScope,
51
+ CompanySeriesResource: () => CompanySeriesResource,
40
52
  CustomerBuilder: () => CustomerBuilder,
41
53
  InvoiceBuilder: () => InvoiceBuilder,
54
+ VeriFactuSubmissionStatus: () => VeriFactuSubmissionStatus,
55
+ WebhookEventType: () => WebhookEventType,
42
56
  WebhookVerificationError: () => WebhookVerificationError,
43
57
  WebhookVerifier: () => WebhookVerifier
44
58
  });
@@ -534,20 +548,653 @@ var NifResource = class {
534
548
  }
535
549
  };
536
550
 
551
+ // src/resources/accounts.ts
552
+ var AccountsResource = class {
553
+ constructor(client) {
554
+ this.client = client;
555
+ }
556
+ /** List accounts reachable with this API key (cursor-paginated). */
557
+ async list(params) {
558
+ const { data } = await this.client.GET("/v1/accounts", { params: { query: params } });
559
+ return data.data;
560
+ }
561
+ /** Provision a new managed account. */
562
+ async provision(body) {
563
+ const { data } = await this.client.POST("/v1/accounts", { body });
564
+ return data.data;
565
+ }
566
+ /** Get a managed account by ID. */
567
+ async get(accountId) {
568
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", {
569
+ params: { path: { account_id: accountId } }
570
+ });
571
+ return data.data;
572
+ }
573
+ /** Alias of `beel.account(accountId)` — returns an account-scoped facade. */
574
+ scope(accountId) {
575
+ return new AccountScope(this.client, accountId);
576
+ }
577
+ };
578
+ var AccountScope = class {
579
+ constructor(client, accountId) {
580
+ this.client = client;
581
+ this.accountId = accountId;
582
+ this.members = new AccountMembersResource(client, accountId);
583
+ this.invitations = new AccountInvitationsResource(client, accountId);
584
+ this.webhooks = new AccountWebhooksResource(client, accountId);
585
+ this.companies = new AccountCompaniesResource(client, accountId);
586
+ }
587
+ path() {
588
+ return { account_id: this.accountId };
589
+ }
590
+ /** Get the account summary. */
591
+ async get() {
592
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", { params: { path: this.path() } });
593
+ return data.data;
594
+ }
595
+ /** Provisioning usage counters (accounts, NIFs) for billing purposes. */
596
+ async usage() {
597
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/usage", { params: { path: this.path() } });
598
+ return data.data;
599
+ }
600
+ /** Change the manager's access level over this account. */
601
+ async changeAccessLevel(body) {
602
+ await this.client.PATCH("/v1/accounts/{account_id}/access-level", {
603
+ params: { path: this.path() },
604
+ body
605
+ });
606
+ }
607
+ /** End the management relationship with this account. */
608
+ async endManagement() {
609
+ await this.client.DELETE("/v1/accounts/{account_id}/management", { params: { path: this.path() } });
610
+ }
611
+ /** Create a claim token so the end user can take ownership of the account. */
612
+ async createClaimToken(body) {
613
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/claim-tokens", {
614
+ params: { path: this.path() },
615
+ body: body ?? {}
616
+ });
617
+ return data.data;
618
+ }
619
+ /** Transfer account ownership to an existing member. */
620
+ async setOwner(body) {
621
+ await this.client.PUT("/v1/accounts/{account_id}/owner", {
622
+ params: { path: this.path() },
623
+ body
624
+ });
625
+ }
626
+ };
627
+ var AccountMembersResource = class {
628
+ constructor(client, accountId) {
629
+ this.client = client;
630
+ this.accountId = accountId;
631
+ }
632
+ async list() {
633
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members", {
634
+ params: { path: { account_id: this.accountId } }
635
+ });
636
+ return data.data.members;
637
+ }
638
+ async get(memberId) {
639
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}", {
640
+ params: { path: { account_id: this.accountId, member_id: memberId } }
641
+ });
642
+ return data.data;
643
+ }
644
+ /** Update a member's account role. */
645
+ async update(memberId, body) {
646
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/members/{member_id}", {
647
+ params: { path: { account_id: this.accountId, member_id: memberId } },
648
+ body
649
+ });
650
+ return data.data;
651
+ }
652
+ /** Remove a member from the account. */
653
+ async remove(memberId) {
654
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}", {
655
+ params: { path: { account_id: this.accountId, member_id: memberId } }
656
+ });
657
+ }
658
+ /** List a member's per-company grants. */
659
+ async listGrants(memberId) {
660
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}/grants", {
661
+ params: { path: { account_id: this.accountId, member_id: memberId } }
662
+ });
663
+ return data.data;
664
+ }
665
+ /** Grant (or replace) a member's permissions over one company. */
666
+ async putGrant(memberId, companyId, body) {
667
+ const { data } = await this.client.PUT("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
668
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },
669
+ body
670
+ });
671
+ return data.data;
672
+ }
673
+ /** Revoke a member's grant over one company. */
674
+ async removeGrant(memberId, companyId) {
675
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
676
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } }
677
+ });
678
+ }
679
+ };
680
+ var AccountInvitationsResource = class {
681
+ constructor(client, accountId) {
682
+ this.client = client;
683
+ this.accountId = accountId;
684
+ }
685
+ async list() {
686
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations", {
687
+ params: { path: { account_id: this.accountId } }
688
+ });
689
+ return data.data;
690
+ }
691
+ async create(body) {
692
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/invitations", {
693
+ params: { path: { account_id: this.accountId } },
694
+ body
695
+ });
696
+ return data.data;
697
+ }
698
+ async get(invitationId) {
699
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations/{invitation_id}", {
700
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
701
+ });
702
+ return data.data;
703
+ }
704
+ async revoke(invitationId) {
705
+ await this.client.DELETE("/v1/accounts/{account_id}/invitations/{invitation_id}", {
706
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
707
+ });
708
+ }
709
+ };
710
+ var AccountWebhooksResource = class {
711
+ constructor(client, accountId) {
712
+ this.client = client;
713
+ this.accountId = accountId;
714
+ }
715
+ async list(params) {
716
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks", {
717
+ params: { path: { account_id: this.accountId }, query: params }
718
+ });
719
+ return data.data;
720
+ }
721
+ async create(body) {
722
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks", {
723
+ params: { path: { account_id: this.accountId } },
724
+ body
725
+ });
726
+ return data.data;
727
+ }
728
+ async get(webhookId) {
729
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
730
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
731
+ });
732
+ return data.data;
733
+ }
734
+ async update(webhookId, body) {
735
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
736
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } },
737
+ body
738
+ });
739
+ return data.data;
740
+ }
741
+ async delete(webhookId) {
742
+ await this.client.DELETE("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
743
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
744
+ });
745
+ }
746
+ /** Send a test event to the webhook endpoint. */
747
+ async test(webhookId) {
748
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/test", {
749
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
750
+ });
751
+ return data.data;
752
+ }
753
+ /** Rotate the webhook signing secret. */
754
+ async rotateSecret(webhookId) {
755
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/secret", {
756
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
757
+ });
758
+ return data.data;
759
+ }
760
+ async listDeliveries(webhookId, params) {
761
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries", {
762
+ params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params }
763
+ });
764
+ return data.data;
765
+ }
766
+ async retryDelivery(webhookId, deliveryId) {
767
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry", {
768
+ params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } }
769
+ });
770
+ return data.data;
771
+ }
772
+ };
773
+ var AccountCompaniesResource = class {
774
+ constructor(client, accountId) {
775
+ this.client = client;
776
+ this.accountId = accountId;
777
+ }
778
+ async list(params) {
779
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
780
+ params: { path: { account_id: this.accountId }, query: params }
781
+ });
782
+ return { companies: data.data ?? [], pagination: data.pagination };
783
+ }
784
+ /** Register a new company (NIF) under the account. */
785
+ async create(body) {
786
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/companies", {
787
+ params: { path: { account_id: this.accountId } },
788
+ body
789
+ });
790
+ return data.data;
791
+ }
792
+ /** Aggregated per-company stats for the account. */
793
+ async stats() {
794
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies/stats", {
795
+ params: { path: { account_id: this.accountId } }
796
+ });
797
+ return data.data;
798
+ }
799
+ };
800
+
801
+ // src/resources/company.ts
802
+ var CompanyScope = class {
803
+ constructor(client, companyId) {
804
+ this.client = client;
805
+ this.companyId = companyId;
806
+ this.invoices = new CompanyInvoicesResource(client, companyId);
807
+ this.customers = new CompanyCustomersResource(client, companyId);
808
+ this.products = new CompanyProductsResource(client, companyId);
809
+ this.series = new CompanySeriesResource(client, companyId);
810
+ this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);
811
+ }
812
+ path() {
813
+ return { company_id: this.companyId };
814
+ }
815
+ /** Get the company. */
816
+ async get(params) {
817
+ const { data } = await this.client.GET("/v1/companies/{company_id}", {
818
+ params: { path: this.path(), query: params }
819
+ });
820
+ return data.data;
821
+ }
822
+ /** Update company data. */
823
+ async update(body) {
824
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}", {
825
+ params: { path: this.path() },
826
+ body
827
+ });
828
+ return data.data;
829
+ }
830
+ /** Delete the company. */
831
+ async delete() {
832
+ await this.client.DELETE("/v1/companies/{company_id}", { params: { path: this.path() } });
833
+ }
834
+ /** Fiscal summary (VAT/IRPF aggregates) for the company. */
835
+ async fiscalSummary(params) {
836
+ const { data } = await this.client.GET("/v1/companies/{company_id}/fiscal-summary", {
837
+ params: { path: this.path(), query: params }
838
+ });
839
+ return data.data;
840
+ }
841
+ /** Whether the company can already issue invoices, and what is missing if not. */
842
+ async issuingReadiness() {
843
+ const { data } = await this.client.GET("/v1/companies/{company_id}/issuing-readiness", {
844
+ params: { path: this.path() }
845
+ });
846
+ return data.data;
847
+ }
848
+ };
849
+ var CompanyInvoicesResource = class {
850
+ constructor(client, companyId) {
851
+ this.client = client;
852
+ this.companyId = companyId;
853
+ }
854
+ path(rest) {
855
+ return { company_id: this.companyId, ...rest };
856
+ }
857
+ async list(params) {
858
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices", {
859
+ params: { path: this.path(), query: params }
860
+ });
861
+ return data.data;
862
+ }
863
+ async create(body, params) {
864
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices", {
865
+ params: { path: this.path(), query: params },
866
+ body
867
+ });
868
+ return data.data;
869
+ }
870
+ async get(invoiceId) {
871
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}", {
872
+ params: { path: this.path({ invoice_id: invoiceId }) }
873
+ });
874
+ return data.data;
875
+ }
876
+ /** Update a draft invoice. */
877
+ async update(invoiceId, body) {
878
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/invoices/{invoice_id}", {
879
+ params: { path: this.path({ invoice_id: invoiceId }) },
880
+ body
881
+ });
882
+ return data.data;
883
+ }
884
+ /** Delete a draft invoice. */
885
+ async delete(invoiceId) {
886
+ await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}", {
887
+ params: { path: this.path({ invoice_id: invoiceId }) }
888
+ });
889
+ }
890
+ /** Issue a draft invoice (assigns number, submits to VeriFactu when configured). */
891
+ async issue(invoiceId, params) {
892
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/issue", {
893
+ params: { path: this.path({ invoice_id: invoiceId }), query: params }
894
+ });
895
+ return data.data;
896
+ }
897
+ /** Void an issued invoice. */
898
+ async void(invoiceId, body) {
899
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/void", {
900
+ params: { path: this.path({ invoice_id: invoiceId }) },
901
+ body
902
+ });
903
+ return data.data;
904
+ }
905
+ /** Create a corrective (rectificativa) for an issued invoice. */
906
+ async createCorrective(invoiceId, body) {
907
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/corrective", {
908
+ params: { path: this.path({ invoice_id: invoiceId }) },
909
+ body
910
+ });
911
+ return data.data;
912
+ }
913
+ /** Convert a proforma into an invoice. */
914
+ async convertToInvoice(invoiceId, body) {
915
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice", {
916
+ params: { path: this.path({ invoice_id: invoiceId }) },
917
+ body
918
+ });
919
+ return data.data;
920
+ }
921
+ /** Update payment status (e.g. mark as paid). */
922
+ async setStatus(invoiceId, body) {
923
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/invoices/{invoice_id}/status", {
924
+ params: { path: this.path({ invoice_id: invoiceId }) },
925
+ body
926
+ });
927
+ return data.data;
928
+ }
929
+ /** Get PDF metadata and download URL. */
930
+ async getPdf(invoiceId) {
931
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}/pdf", {
932
+ params: { path: this.path({ invoice_id: invoiceId }) }
933
+ });
934
+ return data.data;
935
+ }
936
+ /** Send the invoice by email to the customer. */
937
+ async send(invoiceId, body) {
938
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/send", {
939
+ params: { path: this.path({ invoice_id: invoiceId }) },
940
+ body
941
+ });
942
+ return data.data;
943
+ }
944
+ };
945
+ var CompanyCustomersResource = class {
946
+ constructor(client, companyId) {
947
+ this.client = client;
948
+ this.companyId = companyId;
949
+ }
950
+ async list(params) {
951
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers", {
952
+ params: { path: { company_id: this.companyId }, query: params }
953
+ });
954
+ return data.data;
955
+ }
956
+ async create(body) {
957
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers", {
958
+ params: { path: { company_id: this.companyId } },
959
+ body
960
+ });
961
+ return data.data;
962
+ }
963
+ async createBulk(body) {
964
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers/bulk", {
965
+ params: { path: { company_id: this.companyId } },
966
+ body
967
+ });
968
+ return data.data;
969
+ }
970
+ async get(customerId) {
971
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers/{customer_id}", {
972
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
973
+ });
974
+ return data.data;
975
+ }
976
+ async update(customerId, body) {
977
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/customers/{customer_id}", {
978
+ params: { path: { company_id: this.companyId, customer_id: customerId } },
979
+ body
980
+ });
981
+ return data.data;
982
+ }
983
+ async delete(customerId) {
984
+ await this.client.DELETE("/v1/companies/{company_id}/customers/{customer_id}", {
985
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
986
+ });
987
+ }
988
+ };
989
+ var CompanyProductsResource = class {
990
+ constructor(client, companyId) {
991
+ this.client = client;
992
+ this.companyId = companyId;
993
+ }
994
+ async list(params) {
995
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products", {
996
+ params: { path: { company_id: this.companyId }, query: params }
997
+ });
998
+ return data.data;
999
+ }
1000
+ async create(body) {
1001
+ const { data } = await this.client.POST("/v1/companies/{company_id}/products", {
1002
+ params: { path: { company_id: this.companyId } },
1003
+ body
1004
+ });
1005
+ return data.data;
1006
+ }
1007
+ async get(productId) {
1008
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products/{product_id}", {
1009
+ params: { path: { company_id: this.companyId, product_id: productId } }
1010
+ });
1011
+ return data.data;
1012
+ }
1013
+ async update(productId, body) {
1014
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/products/{product_id}", {
1015
+ params: { path: { company_id: this.companyId, product_id: productId } },
1016
+ body
1017
+ });
1018
+ return data.data;
1019
+ }
1020
+ async delete(productId) {
1021
+ await this.client.DELETE("/v1/companies/{company_id}/products/{product_id}", {
1022
+ params: { path: { company_id: this.companyId, product_id: productId } }
1023
+ });
1024
+ }
1025
+ };
1026
+ var CompanySeriesResource = class {
1027
+ constructor(client, companyId) {
1028
+ this.client = client;
1029
+ this.companyId = companyId;
1030
+ }
1031
+ async list(params) {
1032
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series", {
1033
+ params: { path: { company_id: this.companyId }, query: params }
1034
+ });
1035
+ return data.data;
1036
+ }
1037
+ async create(body) {
1038
+ const { data } = await this.client.POST("/v1/companies/{company_id}/series", {
1039
+ params: { path: { company_id: this.companyId } },
1040
+ body
1041
+ });
1042
+ return data.data;
1043
+ }
1044
+ async update(seriesId, body) {
1045
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/series/{series_id}", {
1046
+ params: { path: { company_id: this.companyId, series_id: seriesId } },
1047
+ body
1048
+ });
1049
+ return data.data;
1050
+ }
1051
+ async delete(seriesId) {
1052
+ await this.client.DELETE("/v1/companies/{company_id}/series/{series_id}", {
1053
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1054
+ });
1055
+ }
1056
+ /** Current default series per invoice type. */
1057
+ async getDefaults() {
1058
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series/defaults", {
1059
+ params: { path: { company_id: this.companyId } }
1060
+ });
1061
+ return data.data;
1062
+ }
1063
+ /** Ensure the three typed default series exist (idempotent seeding). */
1064
+ async ensureDefaults() {
1065
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/defaults", {
1066
+ params: { path: { company_id: this.companyId } }
1067
+ });
1068
+ return data.data;
1069
+ }
1070
+ /** Mark a series as the default for its invoice type. */
1071
+ async setDefault(seriesId) {
1072
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/{series_id}/default", {
1073
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1074
+ });
1075
+ return data.data;
1076
+ }
1077
+ };
1078
+ var CompanyRecurringInvoicesResource = class {
1079
+ constructor(client, companyId) {
1080
+ this.client = client;
1081
+ this.companyId = companyId;
1082
+ }
1083
+ path(rest) {
1084
+ return { company_id: this.companyId, ...rest };
1085
+ }
1086
+ async list(params) {
1087
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices", {
1088
+ params: { path: this.path(), query: params }
1089
+ });
1090
+ return data.data;
1091
+ }
1092
+ async create(body) {
1093
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices", {
1094
+ params: { path: this.path() },
1095
+ body
1096
+ });
1097
+ return data.data;
1098
+ }
1099
+ async get(recurringInvoiceId) {
1100
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1101
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1102
+ });
1103
+ return data.data;
1104
+ }
1105
+ async update(recurringInvoiceId, body) {
1106
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1107
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1108
+ body
1109
+ });
1110
+ return data.data;
1111
+ }
1112
+ async delete(recurringInvoiceId) {
1113
+ await this.client.DELETE("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1114
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1115
+ });
1116
+ }
1117
+ /** Pause or resume the schedule. */
1118
+ async setStatus(recurringInvoiceId, body) {
1119
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status", {
1120
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1121
+ body
1122
+ });
1123
+ return data.data;
1124
+ }
1125
+ /** Skip the next scheduled occurrence. */
1126
+ async skip(recurringInvoiceId) {
1127
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip", {
1128
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1129
+ });
1130
+ return data.data;
1131
+ }
1132
+ /** Generate the next invoice now instead of waiting for the schedule. */
1133
+ async generateNow(recurringInvoiceId) {
1134
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate", {
1135
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1136
+ });
1137
+ return data.data;
1138
+ }
1139
+ async nextOccurrence(recurringInvoiceId) {
1140
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence", {
1141
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1142
+ });
1143
+ return data.data;
1144
+ }
1145
+ async history(recurringInvoiceId, params) {
1146
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history", {
1147
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params }
1148
+ });
1149
+ return data.data;
1150
+ }
1151
+ };
1152
+
537
1153
  // src/client.ts
538
1154
  var BeeL = class {
539
1155
  constructor(config) {
540
1156
  const client = createBeeLClient(config);
1157
+ this._client = client;
541
1158
  this.invoices = new InvoicesResource(client);
542
1159
  this.customers = new CustomersResource(client);
543
1160
  this.products = new ProductsResource(client);
544
1161
  this.configuration = new ConfigurationResource(client);
545
1162
  this.series = new SeriesResource(client);
546
1163
  this.nif = new NifResource(client);
1164
+ this.accounts = new AccountsResource(client);
1165
+ }
1166
+ /**
1167
+ * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.
1168
+ * All operations address the company in the path, no session focus needed.
1169
+ *
1170
+ * @example
1171
+ * ```typescript
1172
+ * const company = beel.company('company-uuid');
1173
+ * const { invoices } = await company.invoices.list({ status: 'ISSUED' });
1174
+ * ```
1175
+ */
1176
+ company(companyId) {
1177
+ return new CompanyScope(this._client, companyId);
1178
+ }
1179
+ /**
1180
+ * Returns a facade scoped to one managed account — members, invitations,
1181
+ * account webhooks, companies, usage. Symmetric with {@link company}.
1182
+ *
1183
+ * @example
1184
+ * ```typescript
1185
+ * const account = beel.account('account-uuid');
1186
+ * const members = await account.members.list();
1187
+ * ```
1188
+ */
1189
+ account(accountId) {
1190
+ return new AccountScope(this._client, accountId);
547
1191
  }
548
1192
  /**
549
1193
  * Download an invoice PDF as a Buffer.
550
1194
  *
1195
+ * @deprecated Relies on the deprecated session-focus PDF endpoint. Use
1196
+ * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.
1197
+ *
551
1198
  * @example
552
1199
  * ```typescript
553
1200
  * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');
@@ -679,6 +1326,100 @@ var WebhookVerificationError = class extends Error {
679
1326
  }
680
1327
  };
681
1328
 
1329
+ // src/generated-webhooks/models/AccountClaimedEvent.ts
1330
+ var AccountClaimedEvent;
1331
+ ((AccountClaimedEvent2) => {
1332
+ let type;
1333
+ ((type2) => {
1334
+ type2["ACCOUNT_CLAIMED"] = "account.claimed";
1335
+ })(type = AccountClaimedEvent2.type || (AccountClaimedEvent2.type = {}));
1336
+ })(AccountClaimedEvent || (AccountClaimedEvent = {}));
1337
+
1338
+ // src/generated-webhooks/models/CompanyCreatedEvent.ts
1339
+ var CompanyCreatedEvent;
1340
+ ((CompanyCreatedEvent2) => {
1341
+ let type;
1342
+ ((type2) => {
1343
+ type2["COMPANY_CREATED"] = "company.created";
1344
+ })(type = CompanyCreatedEvent2.type || (CompanyCreatedEvent2.type = {}));
1345
+ })(CompanyCreatedEvent || (CompanyCreatedEvent = {}));
1346
+
1347
+ // src/generated-webhooks/models/InvoiceEmailSentEvent.ts
1348
+ var InvoiceEmailSentEvent;
1349
+ ((InvoiceEmailSentEvent2) => {
1350
+ let type;
1351
+ ((type2) => {
1352
+ type2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1353
+ })(type = InvoiceEmailSentEvent2.type || (InvoiceEmailSentEvent2.type = {}));
1354
+ })(InvoiceEmailSentEvent || (InvoiceEmailSentEvent = {}));
1355
+
1356
+ // src/generated-webhooks/models/InvoiceIssuedEvent.ts
1357
+ var InvoiceIssuedEvent;
1358
+ ((InvoiceIssuedEvent2) => {
1359
+ let type;
1360
+ ((type2) => {
1361
+ type2["INVOICE_ISSUED"] = "invoice.issued";
1362
+ })(type = InvoiceIssuedEvent2.type || (InvoiceIssuedEvent2.type = {}));
1363
+ })(InvoiceIssuedEvent || (InvoiceIssuedEvent = {}));
1364
+
1365
+ // src/generated-webhooks/models/InvoiceVoidedEvent.ts
1366
+ var InvoiceVoidedEvent;
1367
+ ((InvoiceVoidedEvent2) => {
1368
+ let type;
1369
+ ((type2) => {
1370
+ type2["INVOICE_VOIDED"] = "invoice.voided";
1371
+ })(type = InvoiceVoidedEvent2.type || (InvoiceVoidedEvent2.type = {}));
1372
+ })(InvoiceVoidedEvent || (InvoiceVoidedEvent = {}));
1373
+
1374
+ // src/generated-webhooks/models/RecurringInvoicePausedEvent.ts
1375
+ var RecurringInvoicePausedEvent;
1376
+ ((RecurringInvoicePausedEvent2) => {
1377
+ let type;
1378
+ ((type2) => {
1379
+ type2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1380
+ })(type = RecurringInvoicePausedEvent2.type || (RecurringInvoicePausedEvent2.type = {}));
1381
+ })(RecurringInvoicePausedEvent || (RecurringInvoicePausedEvent = {}));
1382
+
1383
+ // src/generated-webhooks/models/RepresentationSignedEvent.ts
1384
+ var RepresentationSignedEvent;
1385
+ ((RepresentationSignedEvent2) => {
1386
+ let type;
1387
+ ((type2) => {
1388
+ type2["REPRESENTATION_SIGNED"] = "representation.signed";
1389
+ })(type = RepresentationSignedEvent2.type || (RepresentationSignedEvent2.type = {}));
1390
+ })(RepresentationSignedEvent || (RepresentationSignedEvent = {}));
1391
+
1392
+ // src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts
1393
+ var VeriFactuStatusUpdatedEvent;
1394
+ ((VeriFactuStatusUpdatedEvent2) => {
1395
+ let type;
1396
+ ((type2) => {
1397
+ type2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1398
+ })(type = VeriFactuStatusUpdatedEvent2.type || (VeriFactuStatusUpdatedEvent2.type = {}));
1399
+ })(VeriFactuStatusUpdatedEvent || (VeriFactuStatusUpdatedEvent = {}));
1400
+
1401
+ // src/generated-webhooks/models/VeriFactuSubmissionStatus.ts
1402
+ var VeriFactuSubmissionStatus = /* @__PURE__ */ ((VeriFactuSubmissionStatus2) => {
1403
+ VeriFactuSubmissionStatus2["PENDING"] = "PENDING";
1404
+ VeriFactuSubmissionStatus2["ACCEPTED"] = "ACCEPTED";
1405
+ VeriFactuSubmissionStatus2["VOIDED"] = "VOIDED";
1406
+ VeriFactuSubmissionStatus2["REJECTED"] = "REJECTED";
1407
+ return VeriFactuSubmissionStatus2;
1408
+ })(VeriFactuSubmissionStatus || {});
1409
+
1410
+ // src/generated-webhooks/models/WebhookEventType.ts
1411
+ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
1412
+ WebhookEventType2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1413
+ WebhookEventType2["INVOICE_ISSUED"] = "invoice.issued";
1414
+ WebhookEventType2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1415
+ WebhookEventType2["INVOICE_VOIDED"] = "invoice.voided";
1416
+ WebhookEventType2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1417
+ WebhookEventType2["ACCOUNT_CLAIMED"] = "account.claimed";
1418
+ WebhookEventType2["COMPANY_CREATED"] = "company.created";
1419
+ WebhookEventType2["REPRESENTATION_SIGNED"] = "representation.signed";
1420
+ return WebhookEventType2;
1421
+ })(WebhookEventType || {});
1422
+
682
1423
  // src/builders/customer-builder.ts
683
1424
  var CustomerBuilder = class _CustomerBuilder {
684
1425
  constructor() {
@@ -751,7 +1492,7 @@ var InvoiceBuilder = class _InvoiceBuilder {
751
1492
  return this;
752
1493
  }
753
1494
  addLine(description, quantity, unitPrice, discountPercentage = 0) {
754
- this._lines.push({ description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
1495
+ this._lines.push({ line_type: "NORMAL", description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
755
1496
  return this;
756
1497
  }
757
1498
  addLineObject(line) {
@@ -788,6 +1529,12 @@ var InvoiceBuilder = class _InvoiceBuilder {
788
1529
  };
789
1530
  // Annotate the CommonJS export names for ESM import in node:
790
1531
  0 && (module.exports = {
1532
+ AccountCompaniesResource,
1533
+ AccountInvitationsResource,
1534
+ AccountMembersResource,
1535
+ AccountScope,
1536
+ AccountWebhooksResource,
1537
+ AccountsResource,
791
1538
  BeeL,
792
1539
  BeeLApiError,
793
1540
  BeeLAuthError,
@@ -795,8 +1542,16 @@ var InvoiceBuilder = class _InvoiceBuilder {
795
1542
  BeeLNotFoundError,
796
1543
  BeeLRateLimitError,
797
1544
  BeeLValidationError,
1545
+ CompanyCustomersResource,
1546
+ CompanyInvoicesResource,
1547
+ CompanyProductsResource,
1548
+ CompanyRecurringInvoicesResource,
1549
+ CompanyScope,
1550
+ CompanySeriesResource,
798
1551
  CustomerBuilder,
799
1552
  InvoiceBuilder,
1553
+ VeriFactuSubmissionStatus,
1554
+ WebhookEventType,
800
1555
  WebhookVerificationError,
801
1556
  WebhookVerifier
802
1557
  });