@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.mjs CHANGED
@@ -423,6 +423,29 @@ var ConfigurationResource = class {
423
423
  return data.data;
424
424
  }
425
425
  };
426
+ var CatalogsResource = class {
427
+ constructor(client) {
428
+ this.client = client;
429
+ }
430
+ /** Tax types the API accepts. Canonical form of `configuration/tax-types`. */
431
+ async taxTypes() {
432
+ const { data } = await this.client.GET("/v1/tax-types");
433
+ return data.data;
434
+ }
435
+ /** Invoice customization options. Canonical form of the `configuration` read. */
436
+ async invoiceCustomizationOptions() {
437
+ const { data } = await this.client.GET("/v1/invoice-customization-options");
438
+ return data.data;
439
+ }
440
+ /**
441
+ * The signed-in person's preferences. Canonical form of
442
+ * `PUT /v1/configuration/language`: the language belongs to the person, not to a company.
443
+ */
444
+ async updateMe(body) {
445
+ const { data } = await this.client.PATCH("/v1/me", { body });
446
+ return data.data;
447
+ }
448
+ };
426
449
 
427
450
  // src/resources/series.ts
428
451
  var SeriesResource = class {
@@ -488,20 +511,869 @@ var NifResource = class {
488
511
  }
489
512
  };
490
513
 
514
+ // src/resources/accounts.ts
515
+ var AccountsResource = class {
516
+ constructor(client) {
517
+ this.client = client;
518
+ }
519
+ /** List accounts reachable with this API key (cursor-paginated). */
520
+ async list(params) {
521
+ const { data } = await this.client.GET("/v1/accounts", { params: { query: params } });
522
+ return data.data;
523
+ }
524
+ /** Provision a new managed account. */
525
+ async provision(body) {
526
+ const { data } = await this.client.POST("/v1/accounts", { body });
527
+ return data.data;
528
+ }
529
+ /** Get a managed account by ID. */
530
+ async get(accountId) {
531
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", {
532
+ params: { path: { account_id: accountId } }
533
+ });
534
+ return data.data;
535
+ }
536
+ /** Alias of `beel.account(accountId)` — returns an account-scoped facade. */
537
+ scope(accountId) {
538
+ return new AccountScope(this.client, accountId);
539
+ }
540
+ };
541
+ var AccountScope = class {
542
+ constructor(client, accountId) {
543
+ this.client = client;
544
+ this.accountId = accountId;
545
+ this.members = new AccountMembersResource(client, accountId);
546
+ this.invitations = new AccountInvitationsResource(client, accountId);
547
+ this.webhooks = new AccountWebhooksResource(client, accountId);
548
+ this.companies = new AccountCompaniesResource(client, accountId);
549
+ }
550
+ path() {
551
+ return { account_id: this.accountId };
552
+ }
553
+ /** Get the account summary. */
554
+ async get() {
555
+ const { data } = await this.client.GET("/v1/accounts/{account_id}", { params: { path: this.path() } });
556
+ return data.data;
557
+ }
558
+ /** Provisioning usage counters (accounts, NIFs) for billing purposes. */
559
+ async usage() {
560
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/usage", { params: { path: this.path() } });
561
+ return data.data;
562
+ }
563
+ /** Change the manager's access level over this account. */
564
+ async changeAccessLevel(body) {
565
+ await this.client.PATCH("/v1/accounts/{account_id}/access-level", {
566
+ params: { path: this.path() },
567
+ body
568
+ });
569
+ }
570
+ /** End the management relationship with this account. */
571
+ async endManagement() {
572
+ await this.client.DELETE("/v1/accounts/{account_id}/management", { params: { path: this.path() } });
573
+ }
574
+ /** Create a claim token so the end user can take ownership of the account. */
575
+ async createClaimToken(body) {
576
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/claim-tokens", {
577
+ params: { path: this.path() },
578
+ body: body ?? {}
579
+ });
580
+ return data.data;
581
+ }
582
+ /** Transfer account ownership to an existing member. */
583
+ async setOwner(body) {
584
+ await this.client.PUT("/v1/accounts/{account_id}/owner", {
585
+ params: { path: this.path() },
586
+ body
587
+ });
588
+ }
589
+ };
590
+ var AccountMembersResource = class {
591
+ constructor(client, accountId) {
592
+ this.client = client;
593
+ this.accountId = accountId;
594
+ }
595
+ async list() {
596
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members", {
597
+ params: { path: { account_id: this.accountId } }
598
+ });
599
+ return data.data.members;
600
+ }
601
+ async get(memberId) {
602
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}", {
603
+ params: { path: { account_id: this.accountId, member_id: memberId } }
604
+ });
605
+ return data.data;
606
+ }
607
+ /** Update a member's account role. */
608
+ async update(memberId, body) {
609
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/members/{member_id}", {
610
+ params: { path: { account_id: this.accountId, member_id: memberId } },
611
+ body
612
+ });
613
+ return data.data;
614
+ }
615
+ /** Remove a member from the account. */
616
+ async remove(memberId) {
617
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}", {
618
+ params: { path: { account_id: this.accountId, member_id: memberId } }
619
+ });
620
+ }
621
+ /** List a member's per-company grants. */
622
+ async listGrants(memberId) {
623
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/members/{member_id}/grants", {
624
+ params: { path: { account_id: this.accountId, member_id: memberId } }
625
+ });
626
+ return data.data;
627
+ }
628
+ /** Grant (or replace) a member's permissions over one company. */
629
+ async putGrant(memberId, companyId, body) {
630
+ const { data } = await this.client.PUT("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
631
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },
632
+ body
633
+ });
634
+ return data.data;
635
+ }
636
+ /** Revoke a member's grant over one company. */
637
+ async removeGrant(memberId, companyId) {
638
+ await this.client.DELETE("/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}", {
639
+ params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } }
640
+ });
641
+ }
642
+ };
643
+ var AccountInvitationsResource = class {
644
+ constructor(client, accountId) {
645
+ this.client = client;
646
+ this.accountId = accountId;
647
+ }
648
+ async list() {
649
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations", {
650
+ params: { path: { account_id: this.accountId } }
651
+ });
652
+ return data.data;
653
+ }
654
+ async create(body) {
655
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/invitations", {
656
+ params: { path: { account_id: this.accountId } },
657
+ body
658
+ });
659
+ return data.data;
660
+ }
661
+ async get(invitationId) {
662
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/invitations/{invitation_id}", {
663
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
664
+ });
665
+ return data.data;
666
+ }
667
+ async revoke(invitationId) {
668
+ await this.client.DELETE("/v1/accounts/{account_id}/invitations/{invitation_id}", {
669
+ params: { path: { account_id: this.accountId, invitation_id: invitationId } }
670
+ });
671
+ }
672
+ };
673
+ var AccountWebhooksResource = class {
674
+ constructor(client, accountId) {
675
+ this.client = client;
676
+ this.accountId = accountId;
677
+ }
678
+ async list(params) {
679
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks", {
680
+ params: { path: { account_id: this.accountId }, query: params }
681
+ });
682
+ return data.data;
683
+ }
684
+ async create(body) {
685
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks", {
686
+ params: { path: { account_id: this.accountId } },
687
+ body
688
+ });
689
+ return data.data;
690
+ }
691
+ async get(webhookId) {
692
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
693
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
694
+ });
695
+ return data.data;
696
+ }
697
+ async update(webhookId, body) {
698
+ const { data } = await this.client.PATCH("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
699
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } },
700
+ body
701
+ });
702
+ return data.data;
703
+ }
704
+ async delete(webhookId) {
705
+ await this.client.DELETE("/v1/accounts/{account_id}/webhooks/{webhook_id}", {
706
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
707
+ });
708
+ }
709
+ /** Send a test event to the webhook endpoint. */
710
+ async test(webhookId) {
711
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/test", {
712
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
713
+ });
714
+ return data.data;
715
+ }
716
+ /** Rotate the webhook signing secret. */
717
+ async rotateSecret(webhookId) {
718
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/secret", {
719
+ params: { path: { account_id: this.accountId, webhook_id: webhookId } }
720
+ });
721
+ return data.data;
722
+ }
723
+ async listDeliveries(webhookId, params) {
724
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries", {
725
+ params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params }
726
+ });
727
+ return data.data;
728
+ }
729
+ async retryDelivery(webhookId, deliveryId) {
730
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry", {
731
+ params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } }
732
+ });
733
+ return data.data;
734
+ }
735
+ };
736
+ var AccountCompaniesResource = class {
737
+ constructor(client, accountId) {
738
+ this.client = client;
739
+ this.accountId = accountId;
740
+ }
741
+ async list(params) {
742
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies", {
743
+ params: { path: { account_id: this.accountId }, query: params }
744
+ });
745
+ return {
746
+ companies: data.data?.companies ?? [],
747
+ pagination: data.data?.pagination
748
+ };
749
+ }
750
+ /** Register a new company (NIF) under the account. */
751
+ async create(body) {
752
+ const { data } = await this.client.POST("/v1/accounts/{account_id}/companies", {
753
+ params: { path: { account_id: this.accountId } },
754
+ body
755
+ });
756
+ return data.data;
757
+ }
758
+ /** Aggregated per-company stats for the account. */
759
+ async stats() {
760
+ const { data } = await this.client.GET("/v1/accounts/{account_id}/companies/stats", {
761
+ params: { path: { account_id: this.accountId } }
762
+ });
763
+ return data.data;
764
+ }
765
+ };
766
+
767
+ // src/resources/payment-connections.ts
768
+ var CompanyPaymentConnectionsResource = class {
769
+ constructor(client, companyId) {
770
+ this.client = client;
771
+ this.companyId = companyId;
772
+ }
773
+ path() {
774
+ return { company_id: this.companyId };
775
+ }
776
+ /** Every payment connection of this company. */
777
+ async list() {
778
+ const { data } = await this.client.GET("/v1/companies/{company_id}/payment-connections", {
779
+ params: { path: this.path() }
780
+ });
781
+ return data.data;
782
+ }
783
+ /**
784
+ * Start an authorization and get the URL where the NIF's holder approves it.
785
+ *
786
+ * This is the one place the provider slug is used — currently only `stripe`.
787
+ */
788
+ async authorize(body) {
789
+ const { data } = await this.client.POST(
790
+ "/v1/companies/{company_id}/payment-connections/authorizations",
791
+ { params: { path: this.path() }, body }
792
+ );
793
+ return data.data;
794
+ }
795
+ /** Update one connection, addressed by its UUID. */
796
+ async update(connectionId, body) {
797
+ const { data } = await this.client.PATCH(
798
+ "/v1/companies/{company_id}/payment-connections/{connection_id}",
799
+ { params: { path: { ...this.path(), connection_id: connectionId } }, body }
800
+ );
801
+ return data.data;
802
+ }
803
+ /**
804
+ * Disconnect one connection. Tokens are revoked and auto-invoicing stops;
805
+ * already-issued invoices are untouched.
806
+ */
807
+ async disconnect(connectionId) {
808
+ await this.client.DELETE("/v1/companies/{company_id}/payment-connections/{connection_id}", {
809
+ params: { path: { ...this.path(), connection_id: connectionId } }
810
+ });
811
+ }
812
+ /** The payment events of one connection — where you audit what did and didn't invoice. */
813
+ events(connectionId) {
814
+ return new CompanyPaymentEventsResource(this.client, this.companyId, connectionId);
815
+ }
816
+ };
817
+ var CompanyPaymentEventsResource = class {
818
+ constructor(client, companyId, connectionId) {
819
+ this.client = client;
820
+ this.companyId = companyId;
821
+ this.connectionId = connectionId;
822
+ }
823
+ path() {
824
+ return { company_id: this.companyId, connection_id: this.connectionId };
825
+ }
826
+ /**
827
+ * Events of the connection, most recent first. Nothing is hidden by default:
828
+ * skipped events, duplicates and disputes are all returned — narrow with the
829
+ * filters. `charges_only` returns one row per money movement instead.
830
+ */
831
+ async list(params) {
832
+ const { data } = await this.client.GET(
833
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events",
834
+ { params: { path: this.path(), query: params } }
835
+ );
836
+ return data.data;
837
+ }
838
+ /** One event. */
839
+ async get(eventId) {
840
+ const { data } = await this.client.GET(
841
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}",
842
+ { params: { path: { ...this.path(), event_id: eventId } } }
843
+ );
844
+ return data.data;
845
+ }
846
+ /**
847
+ * Reprocess an event whose automatic invoicing didn't complete, applying the NIF's
848
+ * **current** configuration. Only retryable states qualify and the retry budget is
849
+ * finite: otherwise `400`.
850
+ */
851
+ async retry(eventId) {
852
+ const { data } = await this.client.POST(
853
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/retry",
854
+ { params: { path: { ...this.path(), event_id: eventId } } }
855
+ );
856
+ return data.data;
857
+ }
858
+ /**
859
+ * Build a **draft** invoice from an event that couldn't be invoiced automatically,
860
+ * so you can review it before issuing. Returns the draft's id.
861
+ */
862
+ async draft(eventId) {
863
+ const { data } = await this.client.POST(
864
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/draft",
865
+ { params: { path: { ...this.path(), event_id: eventId } } }
866
+ );
867
+ return data.data;
868
+ }
869
+ /** Mark an event as dealt with outside the automatic flow. */
870
+ async resolve(eventId) {
871
+ const { data } = await this.client.POST(
872
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/resolve",
873
+ { params: { path: { ...this.path(), event_id: eventId } } }
874
+ );
875
+ return data.data;
876
+ }
877
+ /** Discard an event so it stops asking for attention. Reversible with {@link restore}. */
878
+ async discard(eventId) {
879
+ const { data } = await this.client.POST(
880
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/discard",
881
+ { params: { path: { ...this.path(), event_id: eventId } } }
882
+ );
883
+ return data.data;
884
+ }
885
+ /** Bring a discarded event back into the list. */
886
+ async restore(eventId) {
887
+ const { data } = await this.client.POST(
888
+ "/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/restore",
889
+ { params: { path: { ...this.path(), event_id: eventId } } }
890
+ );
891
+ return data.data;
892
+ }
893
+ };
894
+
895
+ // src/resources/company.ts
896
+ var CompanyScope = class {
897
+ constructor(client, companyId) {
898
+ this.client = client;
899
+ this.companyId = companyId;
900
+ this.invoices = new CompanyInvoicesResource(client, companyId);
901
+ this.customers = new CompanyCustomersResource(client, companyId);
902
+ this.products = new CompanyProductsResource(client, companyId);
903
+ this.series = new CompanySeriesResource(client, companyId);
904
+ this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);
905
+ this.paymentConnections = new CompanyPaymentConnectionsResource(client, companyId);
906
+ this.taxConfiguration = new CompanyTaxConfigurationResource(client, companyId);
907
+ this.verifactuConfiguration = new CompanyVeriFactuConfigurationResource(client, companyId);
908
+ }
909
+ path() {
910
+ return { company_id: this.companyId };
911
+ }
912
+ /** Get the company. */
913
+ async get(params) {
914
+ const { data } = await this.client.GET("/v1/companies/{company_id}", {
915
+ params: { path: this.path(), query: params }
916
+ });
917
+ return data.data;
918
+ }
919
+ /** Update company data. */
920
+ async update(body) {
921
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}", {
922
+ params: { path: this.path() },
923
+ body
924
+ });
925
+ return data.data;
926
+ }
927
+ /** Delete the company. */
928
+ async delete() {
929
+ await this.client.DELETE("/v1/companies/{company_id}", { params: { path: this.path() } });
930
+ }
931
+ /** Fiscal summary (VAT/IRPF aggregates) for the company. */
932
+ async fiscalSummary(params) {
933
+ const { data } = await this.client.GET("/v1/companies/{company_id}/fiscal-summary", {
934
+ params: { path: this.path(), query: params }
935
+ });
936
+ return data.data;
937
+ }
938
+ /** Whether the company can already issue invoices, and what is missing if not. */
939
+ async issuingReadiness() {
940
+ const { data } = await this.client.GET("/v1/companies/{company_id}/issuing-readiness", {
941
+ params: { path: this.path() }
942
+ });
943
+ return data.data;
944
+ }
945
+ };
946
+ var CompanyInvoicesResource = class {
947
+ constructor(client, companyId) {
948
+ this.client = client;
949
+ this.companyId = companyId;
950
+ this.schedule = new CompanyInvoiceScheduleResource(client, companyId);
951
+ }
952
+ /**
953
+ * Derive a new invoice from an existing one — the canonical form of `duplicate`.
954
+ */
955
+ async derive(body) {
956
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/derivations", {
957
+ params: { path: { company_id: this.companyId } },
958
+ body
959
+ });
960
+ return data.data;
961
+ }
962
+ path(rest) {
963
+ return { company_id: this.companyId, ...rest };
964
+ }
965
+ async list(params) {
966
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices", {
967
+ params: { path: this.path(), query: params }
968
+ });
969
+ return data.data;
970
+ }
971
+ async create(body, params) {
972
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices", {
973
+ params: { path: this.path(), query: params },
974
+ body
975
+ });
976
+ return data.data;
977
+ }
978
+ async get(invoiceId) {
979
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}", {
980
+ params: { path: this.path({ invoice_id: invoiceId }) }
981
+ });
982
+ return data.data;
983
+ }
984
+ /** Update a draft invoice. */
985
+ async update(invoiceId, body) {
986
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/invoices/{invoice_id}", {
987
+ params: { path: this.path({ invoice_id: invoiceId }) },
988
+ body
989
+ });
990
+ return data.data;
991
+ }
992
+ /** Delete a draft invoice. */
993
+ async delete(invoiceId) {
994
+ await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}", {
995
+ params: { path: this.path({ invoice_id: invoiceId }) }
996
+ });
997
+ }
998
+ /** Issue a draft invoice (assigns number, submits to VeriFactu when configured). */
999
+ async issue(invoiceId, params) {
1000
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/issue", {
1001
+ params: { path: this.path({ invoice_id: invoiceId }), query: params }
1002
+ });
1003
+ return data.data;
1004
+ }
1005
+ /** Void an issued invoice. */
1006
+ async void(invoiceId, body) {
1007
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/void", {
1008
+ params: { path: this.path({ invoice_id: invoiceId }) },
1009
+ body
1010
+ });
1011
+ return data.data;
1012
+ }
1013
+ /** Create a corrective (rectificativa) for an issued invoice. */
1014
+ async createCorrective(invoiceId, body) {
1015
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/corrective", {
1016
+ params: { path: this.path({ invoice_id: invoiceId }) },
1017
+ body
1018
+ });
1019
+ return data.data;
1020
+ }
1021
+ /** Convert a proforma into an invoice. */
1022
+ async convertToInvoice(invoiceId, body) {
1023
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice", {
1024
+ params: { path: this.path({ invoice_id: invoiceId }) },
1025
+ body
1026
+ });
1027
+ return data.data;
1028
+ }
1029
+ /** Update payment status (e.g. mark as paid). */
1030
+ async setStatus(invoiceId, body) {
1031
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/invoices/{invoice_id}/status", {
1032
+ params: { path: this.path({ invoice_id: invoiceId }) },
1033
+ body
1034
+ });
1035
+ return data.data;
1036
+ }
1037
+ /** Get PDF metadata and download URL. */
1038
+ async getPdf(invoiceId) {
1039
+ const { data } = await this.client.GET("/v1/companies/{company_id}/invoices/{invoice_id}/pdf", {
1040
+ params: { path: this.path({ invoice_id: invoiceId }) }
1041
+ });
1042
+ return data.data;
1043
+ }
1044
+ /** Send the invoice by email to the customer. */
1045
+ async send(invoiceId, body) {
1046
+ const { data } = await this.client.POST("/v1/companies/{company_id}/invoices/{invoice_id}/send", {
1047
+ params: { path: this.path({ invoice_id: invoiceId }) },
1048
+ body
1049
+ });
1050
+ return data.data;
1051
+ }
1052
+ };
1053
+ var CompanyInvoiceScheduleResource = class {
1054
+ constructor(client, companyId) {
1055
+ this.client = client;
1056
+ this.companyId = companyId;
1057
+ }
1058
+ async get(invoiceId) {
1059
+ const { data } = await this.client.GET(
1060
+ "/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
1061
+ { params: { path: { company_id: this.companyId, invoice_id: invoiceId } } }
1062
+ );
1063
+ return data.data;
1064
+ }
1065
+ /**
1066
+ * Set or move the schedule. One `PUT` replaces the three legacy calls
1067
+ * (`schedule`, `reschedule`, `unschedule`): setting it again moves it.
1068
+ */
1069
+ async set(invoiceId, body) {
1070
+ const { data } = await this.client.PUT(
1071
+ "/v1/companies/{company_id}/invoices/{invoice_id}/schedule",
1072
+ { params: { path: { company_id: this.companyId, invoice_id: invoiceId } }, body }
1073
+ );
1074
+ return data.data;
1075
+ }
1076
+ /** Clear the schedule — the canonical form of `unschedule`. */
1077
+ async clear(invoiceId) {
1078
+ await this.client.DELETE("/v1/companies/{company_id}/invoices/{invoice_id}/schedule", {
1079
+ params: { path: { company_id: this.companyId, invoice_id: invoiceId } }
1080
+ });
1081
+ }
1082
+ };
1083
+ var CompanyCustomersResource = class {
1084
+ constructor(client, companyId) {
1085
+ this.client = client;
1086
+ this.companyId = companyId;
1087
+ }
1088
+ async list(params) {
1089
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers", {
1090
+ params: { path: { company_id: this.companyId }, query: params }
1091
+ });
1092
+ return data.data;
1093
+ }
1094
+ async create(body) {
1095
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers", {
1096
+ params: { path: { company_id: this.companyId } },
1097
+ body
1098
+ });
1099
+ return data.data;
1100
+ }
1101
+ async createBulk(body) {
1102
+ const { data } = await this.client.POST("/v1/companies/{company_id}/customers/bulk", {
1103
+ params: { path: { company_id: this.companyId } },
1104
+ body
1105
+ });
1106
+ return data.data;
1107
+ }
1108
+ async get(customerId) {
1109
+ const { data } = await this.client.GET("/v1/companies/{company_id}/customers/{customer_id}", {
1110
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
1111
+ });
1112
+ return data.data;
1113
+ }
1114
+ async update(customerId, body) {
1115
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/customers/{customer_id}", {
1116
+ params: { path: { company_id: this.companyId, customer_id: customerId } },
1117
+ body
1118
+ });
1119
+ return data.data;
1120
+ }
1121
+ async delete(customerId) {
1122
+ await this.client.DELETE("/v1/companies/{company_id}/customers/{customer_id}", {
1123
+ params: { path: { company_id: this.companyId, customer_id: customerId } }
1124
+ });
1125
+ }
1126
+ };
1127
+ var CompanyProductsResource = class {
1128
+ constructor(client, companyId) {
1129
+ this.client = client;
1130
+ this.companyId = companyId;
1131
+ }
1132
+ async list(params) {
1133
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products", {
1134
+ params: { path: { company_id: this.companyId }, query: params }
1135
+ });
1136
+ return data.data;
1137
+ }
1138
+ async create(body) {
1139
+ const { data } = await this.client.POST("/v1/companies/{company_id}/products", {
1140
+ params: { path: { company_id: this.companyId } },
1141
+ body
1142
+ });
1143
+ return data.data;
1144
+ }
1145
+ async get(productId) {
1146
+ const { data } = await this.client.GET("/v1/companies/{company_id}/products/{product_id}", {
1147
+ params: { path: { company_id: this.companyId, product_id: productId } }
1148
+ });
1149
+ return data.data;
1150
+ }
1151
+ async update(productId, body) {
1152
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/products/{product_id}", {
1153
+ params: { path: { company_id: this.companyId, product_id: productId } },
1154
+ body
1155
+ });
1156
+ return data.data;
1157
+ }
1158
+ async delete(productId) {
1159
+ await this.client.DELETE("/v1/companies/{company_id}/products/{product_id}", {
1160
+ params: { path: { company_id: this.companyId, product_id: productId } }
1161
+ });
1162
+ }
1163
+ };
1164
+ var CompanySeriesResource = class {
1165
+ constructor(client, companyId) {
1166
+ this.client = client;
1167
+ this.companyId = companyId;
1168
+ }
1169
+ async list(params) {
1170
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series", {
1171
+ params: { path: { company_id: this.companyId }, query: params }
1172
+ });
1173
+ return data.data;
1174
+ }
1175
+ async create(body) {
1176
+ const { data } = await this.client.POST("/v1/companies/{company_id}/series", {
1177
+ params: { path: { company_id: this.companyId } },
1178
+ body
1179
+ });
1180
+ return data.data;
1181
+ }
1182
+ async update(seriesId, body) {
1183
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/series/{series_id}", {
1184
+ params: { path: { company_id: this.companyId, series_id: seriesId } },
1185
+ body
1186
+ });
1187
+ return data.data;
1188
+ }
1189
+ async delete(seriesId) {
1190
+ await this.client.DELETE("/v1/companies/{company_id}/series/{series_id}", {
1191
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1192
+ });
1193
+ }
1194
+ /** Current default series per invoice type. */
1195
+ async getDefaults() {
1196
+ const { data } = await this.client.GET("/v1/companies/{company_id}/series/defaults", {
1197
+ params: { path: { company_id: this.companyId } }
1198
+ });
1199
+ return data.data;
1200
+ }
1201
+ /** Ensure the three typed default series exist (idempotent seeding). */
1202
+ async ensureDefaults() {
1203
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/defaults", {
1204
+ params: { path: { company_id: this.companyId } }
1205
+ });
1206
+ return data.data;
1207
+ }
1208
+ /** Mark a series as the default for its invoice type. */
1209
+ async setDefault(seriesId) {
1210
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/series/{series_id}/default", {
1211
+ params: { path: { company_id: this.companyId, series_id: seriesId } }
1212
+ });
1213
+ return data.data;
1214
+ }
1215
+ };
1216
+ var CompanyRecurringInvoicesResource = class {
1217
+ constructor(client, companyId) {
1218
+ this.client = client;
1219
+ this.companyId = companyId;
1220
+ }
1221
+ path(rest) {
1222
+ return { company_id: this.companyId, ...rest };
1223
+ }
1224
+ async list(params) {
1225
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices", {
1226
+ params: { path: this.path(), query: params }
1227
+ });
1228
+ return data.data;
1229
+ }
1230
+ async create(body) {
1231
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices", {
1232
+ params: { path: this.path() },
1233
+ body
1234
+ });
1235
+ return data.data;
1236
+ }
1237
+ async get(recurringInvoiceId) {
1238
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1239
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1240
+ });
1241
+ return data.data;
1242
+ }
1243
+ async update(recurringInvoiceId, body) {
1244
+ const { data } = await this.client.PATCH("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1245
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1246
+ body
1247
+ });
1248
+ return data.data;
1249
+ }
1250
+ async delete(recurringInvoiceId) {
1251
+ await this.client.DELETE("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}", {
1252
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1253
+ });
1254
+ }
1255
+ /** Pause or resume the schedule. */
1256
+ async setStatus(recurringInvoiceId, body) {
1257
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status", {
1258
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },
1259
+ body
1260
+ });
1261
+ return data.data;
1262
+ }
1263
+ /** Skip the next scheduled occurrence. */
1264
+ async skip(recurringInvoiceId) {
1265
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip", {
1266
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1267
+ });
1268
+ return data.data;
1269
+ }
1270
+ /** Generate the next invoice now instead of waiting for the schedule. */
1271
+ async generateNow(recurringInvoiceId) {
1272
+ const { data } = await this.client.POST("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate", {
1273
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1274
+ });
1275
+ return data.data;
1276
+ }
1277
+ async nextOccurrence(recurringInvoiceId) {
1278
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence", {
1279
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) }
1280
+ });
1281
+ return data.data;
1282
+ }
1283
+ async history(recurringInvoiceId, params) {
1284
+ const { data } = await this.client.GET("/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history", {
1285
+ params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params }
1286
+ });
1287
+ return data.data;
1288
+ }
1289
+ };
1290
+ var CompanyTaxConfigurationResource = class {
1291
+ constructor(client, companyId) {
1292
+ this.client = client;
1293
+ this.companyId = companyId;
1294
+ }
1295
+ async get() {
1296
+ const { data } = await this.client.GET("/v1/companies/{company_id}/tax-configuration", {
1297
+ params: { path: { company_id: this.companyId } }
1298
+ });
1299
+ return data.data;
1300
+ }
1301
+ /** Replaces the whole state — this is a `PUT`, not a merge. */
1302
+ async update(body) {
1303
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/tax-configuration", {
1304
+ params: { path: { company_id: this.companyId } },
1305
+ body
1306
+ });
1307
+ return data.data;
1308
+ }
1309
+ };
1310
+ var CompanyVeriFactuConfigurationResource = class {
1311
+ constructor(client, companyId) {
1312
+ this.client = client;
1313
+ this.companyId = companyId;
1314
+ }
1315
+ async get() {
1316
+ const { data } = await this.client.GET("/v1/companies/{company_id}/verifactu-configuration", {
1317
+ params: { path: { company_id: this.companyId } }
1318
+ });
1319
+ return data.data;
1320
+ }
1321
+ /** Flip VeriFactu for this NIF. `enabled` is the only field you can write. */
1322
+ async update(body) {
1323
+ const { data } = await this.client.PUT("/v1/companies/{company_id}/verifactu-configuration", {
1324
+ params: { path: { company_id: this.companyId } },
1325
+ body
1326
+ });
1327
+ return data.data;
1328
+ }
1329
+ };
1330
+
491
1331
  // src/client.ts
492
1332
  var BeeL = class {
493
1333
  constructor(config) {
494
1334
  const client = createBeeLClient(config);
1335
+ this.raw = client;
495
1336
  this.invoices = new InvoicesResource(client);
496
1337
  this.customers = new CustomersResource(client);
497
1338
  this.products = new ProductsResource(client);
498
1339
  this.configuration = new ConfigurationResource(client);
1340
+ this.catalogs = new CatalogsResource(client);
499
1341
  this.series = new SeriesResource(client);
500
1342
  this.nif = new NifResource(client);
1343
+ this.accounts = new AccountsResource(client);
1344
+ }
1345
+ /**
1346
+ * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.
1347
+ * All operations address the company in the path, no session focus needed.
1348
+ *
1349
+ * @example
1350
+ * ```typescript
1351
+ * const company = beel.company('company-uuid');
1352
+ * const { invoices } = await company.invoices.list({ status: 'ISSUED' });
1353
+ * ```
1354
+ */
1355
+ company(companyId) {
1356
+ return new CompanyScope(this.raw, companyId);
1357
+ }
1358
+ /**
1359
+ * Returns a facade scoped to one managed account — members, invitations,
1360
+ * account webhooks, companies, usage. Symmetric with {@link company}.
1361
+ *
1362
+ * @example
1363
+ * ```typescript
1364
+ * const account = beel.account('account-uuid');
1365
+ * const members = await account.members.list();
1366
+ * ```
1367
+ */
1368
+ account(accountId) {
1369
+ return new AccountScope(this.raw, accountId);
501
1370
  }
502
1371
  /**
503
1372
  * Download an invoice PDF as a Buffer.
504
1373
  *
1374
+ * @deprecated Relies on the deprecated session-focus PDF endpoint. Use
1375
+ * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.
1376
+ *
505
1377
  * @example
506
1378
  * ```typescript
507
1379
  * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');
@@ -633,6 +1505,100 @@ var WebhookVerificationError = class extends Error {
633
1505
  }
634
1506
  };
635
1507
 
1508
+ // src/generated-webhooks/models/AccountClaimedEvent.ts
1509
+ var AccountClaimedEvent;
1510
+ ((AccountClaimedEvent2) => {
1511
+ let type;
1512
+ ((type2) => {
1513
+ type2["ACCOUNT_CLAIMED"] = "account.claimed";
1514
+ })(type = AccountClaimedEvent2.type || (AccountClaimedEvent2.type = {}));
1515
+ })(AccountClaimedEvent || (AccountClaimedEvent = {}));
1516
+
1517
+ // src/generated-webhooks/models/CompanyCreatedEvent.ts
1518
+ var CompanyCreatedEvent;
1519
+ ((CompanyCreatedEvent2) => {
1520
+ let type;
1521
+ ((type2) => {
1522
+ type2["COMPANY_CREATED"] = "company.created";
1523
+ })(type = CompanyCreatedEvent2.type || (CompanyCreatedEvent2.type = {}));
1524
+ })(CompanyCreatedEvent || (CompanyCreatedEvent = {}));
1525
+
1526
+ // src/generated-webhooks/models/InvoiceEmailSentEvent.ts
1527
+ var InvoiceEmailSentEvent;
1528
+ ((InvoiceEmailSentEvent2) => {
1529
+ let type;
1530
+ ((type2) => {
1531
+ type2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1532
+ })(type = InvoiceEmailSentEvent2.type || (InvoiceEmailSentEvent2.type = {}));
1533
+ })(InvoiceEmailSentEvent || (InvoiceEmailSentEvent = {}));
1534
+
1535
+ // src/generated-webhooks/models/InvoiceIssuedEvent.ts
1536
+ var InvoiceIssuedEvent;
1537
+ ((InvoiceIssuedEvent2) => {
1538
+ let type;
1539
+ ((type2) => {
1540
+ type2["INVOICE_ISSUED"] = "invoice.issued";
1541
+ })(type = InvoiceIssuedEvent2.type || (InvoiceIssuedEvent2.type = {}));
1542
+ })(InvoiceIssuedEvent || (InvoiceIssuedEvent = {}));
1543
+
1544
+ // src/generated-webhooks/models/InvoiceVoidedEvent.ts
1545
+ var InvoiceVoidedEvent;
1546
+ ((InvoiceVoidedEvent2) => {
1547
+ let type;
1548
+ ((type2) => {
1549
+ type2["INVOICE_VOIDED"] = "invoice.voided";
1550
+ })(type = InvoiceVoidedEvent2.type || (InvoiceVoidedEvent2.type = {}));
1551
+ })(InvoiceVoidedEvent || (InvoiceVoidedEvent = {}));
1552
+
1553
+ // src/generated-webhooks/models/RecurringInvoicePausedEvent.ts
1554
+ var RecurringInvoicePausedEvent;
1555
+ ((RecurringInvoicePausedEvent2) => {
1556
+ let type;
1557
+ ((type2) => {
1558
+ type2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1559
+ })(type = RecurringInvoicePausedEvent2.type || (RecurringInvoicePausedEvent2.type = {}));
1560
+ })(RecurringInvoicePausedEvent || (RecurringInvoicePausedEvent = {}));
1561
+
1562
+ // src/generated-webhooks/models/RepresentationSignedEvent.ts
1563
+ var RepresentationSignedEvent;
1564
+ ((RepresentationSignedEvent2) => {
1565
+ let type;
1566
+ ((type2) => {
1567
+ type2["REPRESENTATION_SIGNED"] = "representation.signed";
1568
+ })(type = RepresentationSignedEvent2.type || (RepresentationSignedEvent2.type = {}));
1569
+ })(RepresentationSignedEvent || (RepresentationSignedEvent = {}));
1570
+
1571
+ // src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts
1572
+ var VeriFactuStatusUpdatedEvent;
1573
+ ((VeriFactuStatusUpdatedEvent2) => {
1574
+ let type;
1575
+ ((type2) => {
1576
+ type2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1577
+ })(type = VeriFactuStatusUpdatedEvent2.type || (VeriFactuStatusUpdatedEvent2.type = {}));
1578
+ })(VeriFactuStatusUpdatedEvent || (VeriFactuStatusUpdatedEvent = {}));
1579
+
1580
+ // src/generated-webhooks/models/VeriFactuSubmissionStatus.ts
1581
+ var VeriFactuSubmissionStatus = /* @__PURE__ */ ((VeriFactuSubmissionStatus2) => {
1582
+ VeriFactuSubmissionStatus2["PENDING"] = "PENDING";
1583
+ VeriFactuSubmissionStatus2["ACCEPTED"] = "ACCEPTED";
1584
+ VeriFactuSubmissionStatus2["VOIDED"] = "VOIDED";
1585
+ VeriFactuSubmissionStatus2["REJECTED"] = "REJECTED";
1586
+ return VeriFactuSubmissionStatus2;
1587
+ })(VeriFactuSubmissionStatus || {});
1588
+
1589
+ // src/generated-webhooks/models/WebhookEventType.ts
1590
+ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
1591
+ WebhookEventType2["VERIFACTU_STATUS_UPDATED"] = "verifactu.status.updated";
1592
+ WebhookEventType2["INVOICE_ISSUED"] = "invoice.issued";
1593
+ WebhookEventType2["INVOICE_EMAIL_SENT"] = "invoice.email.sent";
1594
+ WebhookEventType2["INVOICE_VOIDED"] = "invoice.voided";
1595
+ WebhookEventType2["RECURRING_INVOICE_PAUSED"] = "recurring_invoice.paused";
1596
+ WebhookEventType2["ACCOUNT_CLAIMED"] = "account.claimed";
1597
+ WebhookEventType2["COMPANY_CREATED"] = "company.created";
1598
+ WebhookEventType2["REPRESENTATION_SIGNED"] = "representation.signed";
1599
+ return WebhookEventType2;
1600
+ })(WebhookEventType || {});
1601
+
636
1602
  // src/builders/customer-builder.ts
637
1603
  var CustomerBuilder = class _CustomerBuilder {
638
1604
  constructor() {
@@ -705,7 +1671,7 @@ var InvoiceBuilder = class _InvoiceBuilder {
705
1671
  return this;
706
1672
  }
707
1673
  addLine(description, quantity, unitPrice, discountPercentage = 0) {
708
- this._lines.push({ description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
1674
+ this._lines.push({ line_type: "NORMAL", description, quantity, unit_price: unitPrice, discount_percentage: discountPercentage });
709
1675
  return this;
710
1676
  }
711
1677
  addLineObject(line) {
@@ -741,6 +1707,12 @@ var InvoiceBuilder = class _InvoiceBuilder {
741
1707
  }
742
1708
  };
743
1709
  export {
1710
+ AccountCompaniesResource,
1711
+ AccountInvitationsResource,
1712
+ AccountMembersResource,
1713
+ AccountScope,
1714
+ AccountWebhooksResource,
1715
+ AccountsResource,
744
1716
  BeeL,
745
1717
  BeeLApiError,
746
1718
  BeeLAuthError,
@@ -748,8 +1720,22 @@ export {
748
1720
  BeeLNotFoundError,
749
1721
  BeeLRateLimitError,
750
1722
  BeeLValidationError,
1723
+ CatalogsResource,
1724
+ CompanyCustomersResource,
1725
+ CompanyInvoiceScheduleResource,
1726
+ CompanyInvoicesResource,
1727
+ CompanyPaymentConnectionsResource,
1728
+ CompanyPaymentEventsResource,
1729
+ CompanyProductsResource,
1730
+ CompanyRecurringInvoicesResource,
1731
+ CompanyScope,
1732
+ CompanySeriesResource,
1733
+ CompanyTaxConfigurationResource,
1734
+ CompanyVeriFactuConfigurationResource,
751
1735
  CustomerBuilder,
752
1736
  InvoiceBuilder,
1737
+ VeriFactuSubmissionStatus,
1738
+ WebhookEventType,
753
1739
  WebhookVerificationError,
754
1740
  WebhookVerifier
755
1741
  };