@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.mjs CHANGED
@@ -488,20 +488,653 @@ var NifResource = class {
488
488
  }
489
489
  };
490
490
 
491
+ // src/resources/accounts.ts
492
+ var AccountsResource = class {
493
+ constructor(client) {
494
+ this.client = client;
495
+ }
496
+ /** List accounts reachable with this API key (cursor-paginated). */
497
+ async list(params) {
498
+ const { data } = await this.client.GET("/v1/accounts", { params: { query: params } });
499
+ return data.data;
500
+ }
501
+ /** Provision a new managed account. */
502
+ async provision(body) {
503
+ const { data } = await this.client.POST("/v1/accounts", { body });
504
+ return data.data;
505
+ }
506
+ /** Get a managed account by ID. */
507
+ async get(accountId) {
508
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", {
509
+ params: { path: { account_id: accountId } }
510
+ });
511
+ return data.data;
512
+ }
513
+ /** Alias of `beel.account(accountId)` — returns an account-scoped facade. */
514
+ scope(accountId) {
515
+ return new AccountScope(this.client, accountId);
516
+ }
517
+ };
518
+ var AccountScope = class {
519
+ constructor(client, accountId) {
520
+ this.client = client;
521
+ this.accountId = accountId;
522
+ this.members = new AccountMembersResource(client, accountId);
523
+ this.invitations = new AccountInvitationsResource(client, accountId);
524
+ this.webhooks = new AccountWebhooksResource(client, accountId);
525
+ this.companies = new AccountCompaniesResource(client, accountId);
526
+ }
527
+ path() {
528
+ return { account_id: this.accountId };
529
+ }
530
+ /** Get the account summary. */
531
+ async get() {
532
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", { params: { path: this.path() } });
533
+ return data.data;
534
+ }
535
+ /** Provisioning usage counters (accounts, NIFs) for billing purposes. */
536
+ async usage() {
537
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/usage", { params: { path: this.path() } });
538
+ return data.data;
539
+ }
540
+ /** Change the manager's access level over this account. */
541
+ async changeAccessLevel(body) {
542
+ await this.client.PATCH("/v1/accounts/{account_id}/access-level", {
543
+ params: { path: this.path() },
544
+ body
545
+ });
546
+ }
547
+ /** End the management relationship with this account. */
548
+ async endManagement() {
549
+ await this.client.DELETE("/v1/accounts/{account_id}/management", { params: { path: this.path() } });
550
+ }
551
+ /** Create a claim token so the end user can take ownership of the account. */
552
+ async createClaimToken(body) {
553
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/claim-tokens", {
554
+ params: { path: this.path() },
555
+ body: body ?? {}
556
+ });
557
+ return data.data;
558
+ }
559
+ /** Transfer account ownership to an existing member. */
560
+ async setOwner(body) {
561
+ await this.client.PUT("/v1/accounts/{account_id}/owner", {
562
+ params: { path: this.path() },
563
+ body
564
+ });
565
+ }
566
+ };
567
+ var AccountMembersResource = class {
568
+ constructor(client, accountId) {
569
+ this.client = client;
570
+ this.accountId = accountId;
571
+ }
572
+ async list() {
573
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members", {
574
+ params: { path: { account_id: this.accountId } }
575
+ });
576
+ return data.data.members;
577
+ }
578
+ async get(memberId) {
579
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}", {
580
+ params: { path: { account_id: this.accountId, member_id: memberId } }
581
+ });
582
+ return data.data;
583
+ }
584
+ /** Update a member's account role. */
585
+ async update(memberId, body) {
586
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/members/{member_id}", {
587
+ params: { path: { account_id: this.accountId, member_id: memberId } },
588
+ body
589
+ });
590
+ return data.data;
591
+ }
592
+ /** Remove a member from the account. */
593
+ async remove(memberId) {
594
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}", {
595
+ params: { path: { account_id: this.accountId, member_id: memberId } }
596
+ });
597
+ }
598
+ /** List a member's per-company grants. */
599
+ async listGrants(memberId) {
600
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}/grants", {
601
+ params: { path: { account_id: this.accountId, member_id: memberId } }
602
+ });
603
+ return data.data;
604
+ }
605
+ /** Grant (or replace) a member's permissions over one company. */
606
+ async putGrant(memberId, companyId, body) {
607
+ const { data } = await this.client.PUT("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
608
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },
609
+ body
610
+ });
611
+ return data.data;
612
+ }
613
+ /** Revoke a member's grant over one company. */
614
+ async removeGrant(memberId, companyId) {
615
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
616
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } }
617
+ });
618
+ }
619
+ };
620
+ var AccountInvitationsResource = class {
621
+ constructor(client, accountId) {
622
+ this.client = client;
623
+ this.accountId = accountId;
624
+ }
625
+ async list() {
626
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations", {
627
+ params: { path: { account_id: this.accountId } }
628
+ });
629
+ return data.data;
630
+ }
631
+ async create(body) {
632
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/invitations", {
633
+ params: { path: { account_id: this.accountId } },
634
+ body
635
+ });
636
+ return data.data;
637
+ }
638
+ async get(invitationId) {
639
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations/{invitation_id}", {
640
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
641
+ });
642
+ return data.data;
643
+ }
644
+ async revoke(invitationId) {
645
+ await this.client.DELETE("/v1/accounts/{account_id}/invitations/{invitation_id}", {
646
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
647
+ });
648
+ }
649
+ };
650
+ var AccountWebhooksResource = class {
651
+ constructor(client, accountId) {
652
+ this.client = client;
653
+ this.accountId = accountId;
654
+ }
655
+ async list(params) {
656
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks", {
657
+ params: { path: { account_id: this.accountId }, query: params }
658
+ });
659
+ return data.data;
660
+ }
661
+ async create(body) {
662
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks", {
663
+ params: { path: { account_id: this.accountId } },
664
+ body
665
+ });
666
+ return data.data;
667
+ }
668
+ async get(webhookId) {
669
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
670
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
671
+ });
672
+ return data.data;
673
+ }
674
+ async update(webhookId, body) {
675
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
676
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } },
677
+ body
678
+ });
679
+ return data.data;
680
+ }
681
+ async delete(webhookId) {
682
+ await this.client.DELETE("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
683
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
684
+ });
685
+ }
686
+ /** Send a test event to the webhook endpoint. */
687
+ async test(webhookId) {
688
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/test", {
689
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
690
+ });
691
+ return data.data;
692
+ }
693
+ /** Rotate the webhook signing secret. */
694
+ async rotateSecret(webhookId) {
695
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/secret", {
696
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
697
+ });
698
+ return data.data;
699
+ }
700
+ async listDeliveries(webhookId, params) {
701
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries", {
702
+ params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params }
703
+ });
704
+ return data.data;
705
+ }
706
+ async retryDelivery(webhookId, deliveryId) {
707
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry", {
708
+ params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } }
709
+ });
710
+ return data.data;
711
+ }
712
+ };
713
+ var AccountCompaniesResource = class {
714
+ constructor(client, accountId) {
715
+ this.client = client;
716
+ this.accountId = accountId;
717
+ }
718
+ async list(params) {
719
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
720
+ params: { path: { account_id: this.accountId }, query: params }
721
+ });
722
+ return { companies: data.data ?? [], pagination: data.pagination };
723
+ }
724
+ /** Register a new company (NIF) under the account. */
725
+ async create(body) {
726
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/companies", {
727
+ params: { path: { account_id: this.accountId } },
728
+ body
729
+ });
730
+ return data.data;
731
+ }
732
+ /** Aggregated per-company stats for the account. */
733
+ async stats() {
734
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies/stats", {
735
+ params: { path: { account_id: this.accountId } }
736
+ });
737
+ return data.data;
738
+ }
739
+ };
740
+
741
+ // src/resources/company.ts
742
+ var CompanyScope = class {
743
+ constructor(client, companyId) {
744
+ this.client = client;
745
+ this.companyId = companyId;
746
+ this.invoices = new CompanyInvoicesResource(client, companyId);
747
+ this.customers = new CompanyCustomersResource(client, companyId);
748
+ this.products = new CompanyProductsResource(client, companyId);
749
+ this.series = new CompanySeriesResource(client, companyId);
750
+ this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);
751
+ }
752
+ path() {
753
+ return { company_id: this.companyId };
754
+ }
755
+ /** Get the company. */
756
+ async get(params) {
757
+ const { data } = await this.client.GET("/v1/companies/{company_id}", {
758
+ params: { path: this.path(), query: params }
759
+ });
760
+ return data.data;
761
+ }
762
+ /** Update company data. */
763
+ async update(body) {
764
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}", {
765
+ params: { path: this.path() },
766
+ body
767
+ });
768
+ return data.data;
769
+ }
770
+ /** Delete the company. */
771
+ async delete() {
772
+ await this.client.DELETE("/v1/companies/{company_id}", { params: { path: this.path() } });
773
+ }
774
+ /** Fiscal summary (VAT/IRPF aggregates) for the company. */
775
+ async fiscalSummary(params) {
776
+ const { data } = await this.client.GET("/v1/companies/{company_id}/fiscal-summary", {
777
+ params: { path: this.path(), query: params }
778
+ });
779
+ return data.data;
780
+ }
781
+ /** Whether the company can already issue invoices, and what is missing if not. */
782
+ async issuingReadiness() {
783
+ const { data } = await this.client.GET("/v1/companies/{company_id}/issuing-readiness", {
784
+ params: { path: this.path() }
785
+ });
786
+ return data.data;
787
+ }
788
+ };
789
+ var CompanyInvoicesResource = class {
790
+ constructor(client, companyId) {
791
+ this.client = client;
792
+ this.companyId = companyId;
793
+ }
794
+ path(rest) {
795
+ return { company_id: this.companyId, ...rest };
796
+ }
797
+ async list(params) {
798
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices", {
799
+ params: { path: this.path(), query: params }
800
+ });
801
+ return data.data;
802
+ }
803
+ async create(body, params) {
804
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices", {
805
+ params: { path: this.path(), query: params },
806
+ body
807
+ });
808
+ return data.data;
809
+ }
810
+ async get(invoiceId) {
811
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}", {
812
+ params: { path: this.path({ invoice_id: invoiceId }) }
813
+ });
814
+ return data.data;
815
+ }
816
+ /** Update a draft invoice. */
817
+ async update(invoiceId, body) {
818
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/invoices/{invoice_id}", {
819
+ params: { path: this.path({ invoice_id: invoiceId }) },
820
+ body
821
+ });
822
+ return data.data;
823
+ }
824
+ /** Delete a draft invoice. */
825
+ async delete(invoiceId) {
826
+ await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}", {
827
+ params: { path: this.path({ invoice_id: invoiceId }) }
828
+ });
829
+ }
830
+ /** Issue a draft invoice (assigns number, submits to VeriFactu when configured). */
831
+ async issue(invoiceId, params) {
832
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/issue", {
833
+ params: { path: this.path({ invoice_id: invoiceId }), query: params }
834
+ });
835
+ return data.data;
836
+ }
837
+ /** Void an issued invoice. */
838
+ async void(invoiceId, body) {
839
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/void", {
840
+ params: { path: this.path({ invoice_id: invoiceId }) },
841
+ body
842
+ });
843
+ return data.data;
844
+ }
845
+ /** Create a corrective (rectificativa) for an issued invoice. */
846
+ async createCorrective(invoiceId, body) {
847
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/corrective", {
848
+ params: { path: this.path({ invoice_id: invoiceId }) },
849
+ body
850
+ });
851
+ return data.data;
852
+ }
853
+ /** Convert a proforma into an invoice. */
854
+ async convertToInvoice(invoiceId, body) {
855
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice", {
856
+ params: { path: this.path({ invoice_id: invoiceId }) },
857
+ body
858
+ });
859
+ return data.data;
860
+ }
861
+ /** Update payment status (e.g. mark as paid). */
862
+ async setStatus(invoiceId, body) {
863
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/invoices/{invoice_id}/status", {
864
+ params: { path: this.path({ invoice_id: invoiceId }) },
865
+ body
866
+ });
867
+ return data.data;
868
+ }
869
+ /** Get PDF metadata and download URL. */
870
+ async getPdf(invoiceId) {
871
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}/pdf", {
872
+ params: { path: this.path({ invoice_id: invoiceId }) }
873
+ });
874
+ return data.data;
875
+ }
876
+ /** Send the invoice by email to the customer. */
877
+ async send(invoiceId, body) {
878
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/send", {
879
+ params: { path: this.path({ invoice_id: invoiceId }) },
880
+ body
881
+ });
882
+ return data.data;
883
+ }
884
+ };
885
+ var CompanyCustomersResource = class {
886
+ constructor(client, companyId) {
887
+ this.client = client;
888
+ this.companyId = companyId;
889
+ }
890
+ async list(params) {
891
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers", {
892
+ params: { path: { company_id: this.companyId }, query: params }
893
+ });
894
+ return data.data;
895
+ }
896
+ async create(body) {
897
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers", {
898
+ params: { path: { company_id: this.companyId } },
899
+ body
900
+ });
901
+ return data.data;
902
+ }
903
+ async createBulk(body) {
904
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers/bulk", {
905
+ params: { path: { company_id: this.companyId } },
906
+ body
907
+ });
908
+ return data.data;
909
+ }
910
+ async get(customerId) {
911
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers/{customer_id}", {
912
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
913
+ });
914
+ return data.data;
915
+ }
916
+ async update(customerId, body) {
917
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/customers/{customer_id}", {
918
+ params: { path: { company_id: this.companyId, customer_id: customerId } },
919
+ body
920
+ });
921
+ return data.data;
922
+ }
923
+ async delete(customerId) {
924
+ await this.client.DELETE("/v1/companies/{company_id}/customers/{customer_id}", {
925
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
926
+ });
927
+ }
928
+ };
929
+ var CompanyProductsResource = class {
930
+ constructor(client, companyId) {
931
+ this.client = client;
932
+ this.companyId = companyId;
933
+ }
934
+ async list(params) {
935
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products", {
936
+ params: { path: { company_id: this.companyId }, query: params }
937
+ });
938
+ return data.data;
939
+ }
940
+ async create(body) {
941
+ const { data } = await this.client.POST("/v1/companies/{company_id}/products", {
942
+ params: { path: { company_id: this.companyId } },
943
+ body
944
+ });
945
+ return data.data;
946
+ }
947
+ async get(productId) {
948
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products/{product_id}", {
949
+ params: { path: { company_id: this.companyId, product_id: productId } }
950
+ });
951
+ return data.data;
952
+ }
953
+ async update(productId, body) {
954
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/products/{product_id}", {
955
+ params: { path: { company_id: this.companyId, product_id: productId } },
956
+ body
957
+ });
958
+ return data.data;
959
+ }
960
+ async delete(productId) {
961
+ await this.client.DELETE("/v1/companies/{company_id}/products/{product_id}", {
962
+ params: { path: { company_id: this.companyId, product_id: productId } }
963
+ });
964
+ }
965
+ };
966
+ var CompanySeriesResource = class {
967
+ constructor(client, companyId) {
968
+ this.client = client;
969
+ this.companyId = companyId;
970
+ }
971
+ async list(params) {
972
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series", {
973
+ params: { path: { company_id: this.companyId }, query: params }
974
+ });
975
+ return data.data;
976
+ }
977
+ async create(body) {
978
+ const { data } = await this.client.POST("/v1/companies/{company_id}/series", {
979
+ params: { path: { company_id: this.companyId } },
980
+ body
981
+ });
982
+ return data.data;
983
+ }
984
+ async update(seriesId, body) {
985
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/series/{series_id}", {
986
+ params: { path: { company_id: this.companyId, series_id: seriesId } },
987
+ body
988
+ });
989
+ return data.data;
990
+ }
991
+ async delete(seriesId) {
992
+ await this.client.DELETE("/v1/companies/{company_id}/series/{series_id}", {
993
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
994
+ });
995
+ }
996
+ /** Current default series per invoice type. */
997
+ async getDefaults() {
998
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series/defaults", {
999
+ params: { path: { company_id: this.companyId } }
1000
+ });
1001
+ return data.data;
1002
+ }
1003
+ /** Ensure the three typed default series exist (idempotent seeding). */
1004
+ async ensureDefaults() {
1005
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/defaults", {
1006
+ params: { path: { company_id: this.companyId } }
1007
+ });
1008
+ return data.data;
1009
+ }
1010
+ /** Mark a series as the default for its invoice type. */
1011
+ async setDefault(seriesId) {
1012
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/{series_id}/default", {
1013
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1014
+ });
1015
+ return data.data;
1016
+ }
1017
+ };
1018
+ var CompanyRecurringInvoicesResource = class {
1019
+ constructor(client, companyId) {
1020
+ this.client = client;
1021
+ this.companyId = companyId;
1022
+ }
1023
+ path(rest) {
1024
+ return { company_id: this.companyId, ...rest };
1025
+ }
1026
+ async list(params) {
1027
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices", {
1028
+ params: { path: this.path(), query: params }
1029
+ });
1030
+ return data.data;
1031
+ }
1032
+ async create(body) {
1033
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices", {
1034
+ params: { path: this.path() },
1035
+ body
1036
+ });
1037
+ return data.data;
1038
+ }
1039
+ async get(recurringInvoiceId) {
1040
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1041
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1042
+ });
1043
+ return data.data;
1044
+ }
1045
+ async update(recurringInvoiceId, body) {
1046
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1047
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1048
+ body
1049
+ });
1050
+ return data.data;
1051
+ }
1052
+ async delete(recurringInvoiceId) {
1053
+ await this.client.DELETE("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1054
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1055
+ });
1056
+ }
1057
+ /** Pause or resume the schedule. */
1058
+ async setStatus(recurringInvoiceId, body) {
1059
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status", {
1060
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1061
+ body
1062
+ });
1063
+ return data.data;
1064
+ }
1065
+ /** Skip the next scheduled occurrence. */
1066
+ async skip(recurringInvoiceId) {
1067
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip", {
1068
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1069
+ });
1070
+ return data.data;
1071
+ }
1072
+ /** Generate the next invoice now instead of waiting for the schedule. */
1073
+ async generateNow(recurringInvoiceId) {
1074
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate", {
1075
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1076
+ });
1077
+ return data.data;
1078
+ }
1079
+ async nextOccurrence(recurringInvoiceId) {
1080
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence", {
1081
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1082
+ });
1083
+ return data.data;
1084
+ }
1085
+ async history(recurringInvoiceId, params) {
1086
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history", {
1087
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params }
1088
+ });
1089
+ return data.data;
1090
+ }
1091
+ };
1092
+
491
1093
  // src/client.ts
492
1094
  var BeeL = class {
493
1095
  constructor(config) {
494
1096
  const client = createBeeLClient(config);
1097
+ this._client = client;
495
1098
  this.invoices = new InvoicesResource(client);
496
1099
  this.customers = new CustomersResource(client);
497
1100
  this.products = new ProductsResource(client);
498
1101
  this.configuration = new ConfigurationResource(client);
499
1102
  this.series = new SeriesResource(client);
500
1103
  this.nif = new NifResource(client);
1104
+ this.accounts = new AccountsResource(client);
1105
+ }
1106
+ /**
1107
+ * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.
1108
+ * All operations address the company in the path, no session focus needed.
1109
+ *
1110
+ * @example
1111
+ * ```typescript
1112
+ * const company = beel.company('company-uuid');
1113
+ * const { invoices } = await company.invoices.list({ status: 'ISSUED' });
1114
+ * ```
1115
+ */
1116
+ company(companyId) {
1117
+ return new CompanyScope(this._client, companyId);
1118
+ }
1119
+ /**
1120
+ * Returns a facade scoped to one managed account — members, invitations,
1121
+ * account webhooks, companies, usage. Symmetric with {@link company}.
1122
+ *
1123
+ * @example
1124
+ * ```typescript
1125
+ * const account = beel.account('account-uuid');
1126
+ * const members = await account.members.list();
1127
+ * ```
1128
+ */
1129
+ account(accountId) {
1130
+ return new AccountScope(this._client, accountId);
501
1131
  }
502
1132
  /**
503
1133
  * Download an invoice PDF as a Buffer.
504
1134
  *
1135
+ * @deprecated Relies on the deprecated session-focus PDF endpoint. Use
1136
+ * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.
1137
+ *
505
1138
  * @example
506
1139
  * ```typescript
507
1140
  * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');
@@ -633,6 +1266,100 @@ var WebhookVerificationError = class extends Error {
633
1266
  }
634
1267
  };
635
1268
 
1269
+ // src/generated-webhooks/models/AccountClaimedEvent.ts
1270
+ var AccountClaimedEvent;
1271
+ ((AccountClaimedEvent2) => {
1272
+ let type;
1273
+ ((type2) => {
1274
+ type2["ACCOUNT_CLAIMED"] = "account.claimed";
1275
+ })(type = AccountClaimedEvent2.type || (AccountClaimedEvent2.type = {}));
1276
+ })(AccountClaimedEvent || (AccountClaimedEvent = {}));
1277
+
1278
+ // src/generated-webhooks/models/CompanyCreatedEvent.ts
1279
+ var CompanyCreatedEvent;
1280
+ ((CompanyCreatedEvent2) => {
1281
+ let type;
1282
+ ((type2) => {
1283
+ type2["COMPANY_CREATED"] = "company.created";
1284
+ })(type = CompanyCreatedEvent2.type || (CompanyCreatedEvent2.type = {}));
1285
+ })(CompanyCreatedEvent || (CompanyCreatedEvent = {}));
1286
+
1287
+ // src/generated-webhooks/models/InvoiceEmailSentEvent.ts
1288
+ var InvoiceEmailSentEvent;
1289
+ ((InvoiceEmailSentEvent2) => {
1290
+ let type;
1291
+ ((type2) => {
1292
+ type2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1293
+ })(type = InvoiceEmailSentEvent2.type || (InvoiceEmailSentEvent2.type = {}));
1294
+ })(InvoiceEmailSentEvent || (InvoiceEmailSentEvent = {}));
1295
+
1296
+ // src/generated-webhooks/models/InvoiceIssuedEvent.ts
1297
+ var InvoiceIssuedEvent;
1298
+ ((InvoiceIssuedEvent2) => {
1299
+ let type;
1300
+ ((type2) => {
1301
+ type2["INVOICE_ISSUED"] = "invoice.issued";
1302
+ })(type = InvoiceIssuedEvent2.type || (InvoiceIssuedEvent2.type = {}));
1303
+ })(InvoiceIssuedEvent || (InvoiceIssuedEvent = {}));
1304
+
1305
+ // src/generated-webhooks/models/InvoiceVoidedEvent.ts
1306
+ var InvoiceVoidedEvent;
1307
+ ((InvoiceVoidedEvent2) => {
1308
+ let type;
1309
+ ((type2) => {
1310
+ type2["INVOICE_VOIDED"] = "invoice.voided";
1311
+ })(type = InvoiceVoidedEvent2.type || (InvoiceVoidedEvent2.type = {}));
1312
+ })(InvoiceVoidedEvent || (InvoiceVoidedEvent = {}));
1313
+
1314
+ // src/generated-webhooks/models/RecurringInvoicePausedEvent.ts
1315
+ var RecurringInvoicePausedEvent;
1316
+ ((RecurringInvoicePausedEvent2) => {
1317
+ let type;
1318
+ ((type2) => {
1319
+ type2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1320
+ })(type = RecurringInvoicePausedEvent2.type || (RecurringInvoicePausedEvent2.type = {}));
1321
+ })(RecurringInvoicePausedEvent || (RecurringInvoicePausedEvent = {}));
1322
+
1323
+ // src/generated-webhooks/models/RepresentationSignedEvent.ts
1324
+ var RepresentationSignedEvent;
1325
+ ((RepresentationSignedEvent2) => {
1326
+ let type;
1327
+ ((type2) => {
1328
+ type2["REPRESENTATION_SIGNED"] = "representation.signed";
1329
+ })(type = RepresentationSignedEvent2.type || (RepresentationSignedEvent2.type = {}));
1330
+ })(RepresentationSignedEvent || (RepresentationSignedEvent = {}));
1331
+
1332
+ // src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts
1333
+ var VeriFactuStatusUpdatedEvent;
1334
+ ((VeriFactuStatusUpdatedEvent2) => {
1335
+ let type;
1336
+ ((type2) => {
1337
+ type2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1338
+ })(type = VeriFactuStatusUpdatedEvent2.type || (VeriFactuStatusUpdatedEvent2.type = {}));
1339
+ })(VeriFactuStatusUpdatedEvent || (VeriFactuStatusUpdatedEvent = {}));
1340
+
1341
+ // src/generated-webhooks/models/VeriFactuSubmissionStatus.ts
1342
+ var VeriFactuSubmissionStatus = /* @__PURE__ */ ((VeriFactuSubmissionStatus2) => {
1343
+ VeriFactuSubmissionStatus2["PENDING"] = "PENDING";
1344
+ VeriFactuSubmissionStatus2["ACCEPTED"] = "ACCEPTED";
1345
+ VeriFactuSubmissionStatus2["VOIDED"] = "VOIDED";
1346
+ VeriFactuSubmissionStatus2["REJECTED"] = "REJECTED";
1347
+ return VeriFactuSubmissionStatus2;
1348
+ })(VeriFactuSubmissionStatus || {});
1349
+
1350
+ // src/generated-webhooks/models/WebhookEventType.ts
1351
+ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
1352
+ WebhookEventType2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1353
+ WebhookEventType2["INVOICE_ISSUED"] = "invoice.issued";
1354
+ WebhookEventType2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1355
+ WebhookEventType2["INVOICE_VOIDED"] = "invoice.voided";
1356
+ WebhookEventType2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1357
+ WebhookEventType2["ACCOUNT_CLAIMED"] = "account.claimed";
1358
+ WebhookEventType2["COMPANY_CREATED"] = "company.created";
1359
+ WebhookEventType2["REPRESENTATION_SIGNED"] = "representation.signed";
1360
+ return WebhookEventType2;
1361
+ })(WebhookEventType || {});
1362
+
636
1363
  // src/builders/customer-builder.ts
637
1364
  var CustomerBuilder = class _CustomerBuilder {
638
1365
  constructor() {
@@ -705,7 +1432,7 @@ var InvoiceBuilder = class _InvoiceBuilder {
705
1432
  return this;
706
1433
  }
707
1434
  addLine(description, quantity, unitPrice, discountPercentage = 0) {
708
- this._lines.push({ description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
1435
+ this._lines.push({ line_type: "NORMAL", description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
709
1436
  return this;
710
1437
  }
711
1438
  addLineObject(line) {
@@ -741,6 +1468,12 @@ var InvoiceBuilder = class _InvoiceBuilder {
741
1468
  }
742
1469
  };
743
1470
  export {
1471
+ AccountCompaniesResource,
1472
+ AccountInvitationsResource,
1473
+ AccountMembersResource,
1474
+ AccountScope,
1475
+ AccountWebhooksResource,
1476
+ AccountsResource,
744
1477
  BeeL,
745
1478
  BeeLApiError,
746
1479
  BeeLAuthError,
@@ -748,8 +1481,16 @@ export {
748
1481
  BeeLNotFoundError,
749
1482
  BeeLRateLimitError,
750
1483
  BeeLValidationError,
1484
+ CompanyCustomersResource,
1485
+ CompanyInvoicesResource,
1486
+ CompanyProductsResource,
1487
+ CompanyRecurringInvoicesResource,
1488
+ CompanyScope,
1489
+ CompanySeriesResource,
751
1490
  CustomerBuilder,
752
1491
  InvoiceBuilder,
1492
+ VeriFactuSubmissionStatus,
1493
+ WebhookEventType,
753
1494
  WebhookVerificationError,
754
1495
  WebhookVerifier
755
1496
  };