lago-javascript-client 1.11.0 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,13 @@ This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, an
5
5
  [![PyPI version](https://badge.fury.io/js/lago-javascript-client.svg)](https://badge.fury.io/js/lago-javascript-client)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
7
7
 
8
+ ## Current Releases
9
+
10
+ | Project | Release Badge |
11
+ |--------------------|-----------------------------------------------------------------------------------------------------|
12
+ | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
13
+ | **Lago JavaScript Client** | [![Lago JavaScript Client Release](https://img.shields.io/github/v/release/getlago/lago-javascript-client)](https://github.com/getlago/lago-javascript-client/releases) |
14
+
8
15
  ## Installation
9
16
 
10
17
  For npm users:
@@ -560,8 +560,8 @@ export interface ChargeObject {
560
560
  * @example "2022-09-14T16:35:31Z"
561
561
  */
562
562
  created_at: string;
563
- /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`. */
564
- charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
563
+ /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`. */
564
+ charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
565
565
  /**
566
566
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to `false`, the charge is due and invoiced at the end of each billing period.
567
567
  * @example true
@@ -1633,6 +1633,22 @@ export interface CustomerCreateInput {
1633
1633
  * @example "Gavin Belson"
1634
1634
  */
1635
1635
  name?: string | null;
1636
+ /**
1637
+ * First name of the customer
1638
+ * @example "Gavin"
1639
+ */
1640
+ firstname?: string | null;
1641
+ /**
1642
+ * Last name of the customer
1643
+ * @example "Belson"
1644
+ */
1645
+ lastname?: string | null;
1646
+ /**
1647
+ * The type of the customer. It can have one of the following values:
1648
+ * - `company`: the customer is a company.
1649
+ * - `individual`: the customer is an individual.
1650
+ */
1651
+ customer_type?: "company" | "individual" | null;
1636
1652
  /**
1637
1653
  * The phone number of the customer
1638
1654
  * @example "1-171-883-3711 x245"
@@ -1841,6 +1857,22 @@ export type CustomerObject = {
1841
1857
  * @example "Gavin Belson"
1842
1858
  */
1843
1859
  name?: string | null;
1860
+ /**
1861
+ * First name of the customer
1862
+ * @example "Gavin"
1863
+ */
1864
+ firstname?: string | null;
1865
+ /**
1866
+ * Last name of the customer
1867
+ * @example "Belson"
1868
+ */
1869
+ lastname?: string | null;
1870
+ /**
1871
+ * The type of the customer. It can have one of the following values:
1872
+ * - `company`: the customer is a company.
1873
+ * - `individual`: the customer is an individual.
1874
+ */
1875
+ customer_type?: "company" | "individual" | null;
1844
1876
  /**
1845
1877
  * The phone number of the customer
1846
1878
  * @example "1-171-883-3711 x245"
@@ -1992,10 +2024,10 @@ export interface EventInput {
1992
2024
  */
1993
2025
  transaction_id: string;
1994
2026
  /**
1995
- * The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the `external_customer_id` is not provided.
2027
+ * The unique identifier of the subscription in your application. This field is mandatory in order to link events to the correct customer subscription.
1996
2028
  * @example "sub_1234567890"
1997
2029
  */
1998
- external_subscription_id?: string;
2030
+ external_subscription_id: string;
1999
2031
  /**
2000
2032
  * The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
2001
2033
  * @example "storage"
@@ -2008,6 +2040,11 @@ export interface EventInput {
2008
2040
  * @example "1651240791.123"
2009
2041
  */
2010
2042
  timestamp?: number | string;
2043
+ /**
2044
+ * The precise total amount in cents with precision used by the `dynamic` pricing model to compute the usage amount.
2045
+ * @example "1234.56"
2046
+ */
2047
+ precise_total_amount_cents?: string | null;
2011
2048
  /**
2012
2049
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2013
2050
  * @example {"gb":10}
@@ -2044,6 +2081,11 @@ export interface EventObject {
2044
2081
  * @example "2022-04-29T08:59:51.123Z"
2045
2082
  */
2046
2083
  timestamp: string;
2084
+ /**
2085
+ * The precise total amount that was sent in the event payload. This filed is used by the `dynamic` pricing model.
2086
+ * @example "1234.56"
2087
+ */
2088
+ precise_total_amount_cents?: string | null;
2047
2089
  /**
2048
2090
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2049
2091
  * @example {"gb":10}
@@ -2505,6 +2547,84 @@ export interface GrossRevenueObject {
2505
2547
  export interface GrossRevenues {
2506
2548
  gross_revenues: GrossRevenueObject[];
2507
2549
  }
2550
+ export interface LifetimeUsage {
2551
+ lifetime_usage: LifetimeUsageObject;
2552
+ }
2553
+ export interface LifetimeUsageInput {
2554
+ lifetime_usage: {
2555
+ /**
2556
+ * The historical usage amount in cents for the subscription (provided by your own application).
2557
+ * @example 100
2558
+ */
2559
+ external_historical_usage_amount_cents: number;
2560
+ };
2561
+ }
2562
+ export interface LifetimeUsageObject {
2563
+ /**
2564
+ * Unique identifier assigned to the lifetime usage record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the lifetime usage record within the Lago system
2565
+ * @format uuid
2566
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
2567
+ */
2568
+ lago_id: string;
2569
+ /**
2570
+ * Unique identifier assigned to the subscription record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the subscription record within the Lago system
2571
+ * @format uuid
2572
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
2573
+ */
2574
+ lago_subscription_id: string;
2575
+ /**
2576
+ * The subscription external unique identifier (provided by your own application).
2577
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
2578
+ */
2579
+ external_subscription_id: string;
2580
+ /**
2581
+ * The historical usage amount in cents for the subscription (provided by your own application).
2582
+ * @example 100
2583
+ */
2584
+ external_historical_usage_amount_cents: number;
2585
+ /**
2586
+ * The total invoiced usage amount in cents for the subscription.
2587
+ * @example 100
2588
+ */
2589
+ invoiced_usage_amount_cents: number;
2590
+ /**
2591
+ * The current usage amount in cents for the subscription on the current billing period.
2592
+ * @example 100
2593
+ */
2594
+ current_usage_amount_cents: number;
2595
+ /**
2596
+ * The recording start date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
2597
+ * @format date-time
2598
+ * @example "2024-01-01T00:00:00Z"
2599
+ */
2600
+ from_datetime: string;
2601
+ /**
2602
+ * The recording end date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
2603
+ * @format date-time
2604
+ * @example "2024-12-31T23:59:59Z"
2605
+ */
2606
+ to_datetime: string;
2607
+ /** Array of usage thresholds attached to the subscription's plan. */
2608
+ usage_thresholds?: LifetimeUsageThresholdObject[];
2609
+ }
2610
+ export interface LifetimeUsageThresholdObject {
2611
+ /**
2612
+ * The usage threshold amount in cents.
2613
+ * @example 100
2614
+ */
2615
+ amount_cents: number;
2616
+ /**
2617
+ * The completion ratio of the usage threshold.
2618
+ * @example 0.5
2619
+ */
2620
+ completion_ratio: number;
2621
+ /**
2622
+ * The date and time when the usage threshold was reached. The date and time must be in ISO 8601 format.
2623
+ * @format date-time
2624
+ * @example "2024-01-01T00:00:00Z"
2625
+ */
2626
+ reached_at: string | null;
2627
+ }
2508
2628
  /** Minimum commitment for this plan. */
2509
2629
  export type MinimumCommitmentInput = {
2510
2630
  /**
@@ -3179,6 +3299,48 @@ export interface PaginationMeta {
3179
3299
  */
3180
3300
  total_count: number;
3181
3301
  }
3302
+ export interface PaymentRequestObject {
3303
+ /**
3304
+ * Unique identifier of the payment request, created by Lago.
3305
+ * @format uuid
3306
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
3307
+ */
3308
+ lago_id: string;
3309
+ /**
3310
+ * The customer's email address used for sending dunning notifications
3311
+ * @format email
3312
+ * @example "dinesh@piedpiper.test"
3313
+ */
3314
+ email: string;
3315
+ /**
3316
+ * The sum of the total amounts of all the invoices included in the payment request, expressed in cents.
3317
+ * @example 100
3318
+ */
3319
+ amount_cents: number;
3320
+ /** The currency of the payment request. */
3321
+ amount_currency: Currency;
3322
+ /**
3323
+ * The status of the payment associated with the payment request. It can have one of the following values:
3324
+ * - `pending`: the payment is pending, waiting for payment processing in the payment provider or when the invoice is emitted but users have not updated the payment status through the endpoint.
3325
+ * - `succeeded`: the payment of the payment request has been successfully processed.
3326
+ * - `failed`: the payment of the payment request has failed or encountered an error during processing.
3327
+ * @example "succeeded"
3328
+ */
3329
+ payment_status: "pending" | "succeeded" | "failed";
3330
+ /**
3331
+ * The date and time when the payment request was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the payment request was initially created.
3332
+ * @format date-time
3333
+ * @example "2022-04-29T08:59:51Z"
3334
+ */
3335
+ created_at: string;
3336
+ /** The customer on which the payment request applies. It refers to the customer account or entity associated with the payment request. */
3337
+ customer: any;
3338
+ invoices: any[];
3339
+ }
3340
+ export interface PaymentRequestsPaginated {
3341
+ payment_requests: PaymentRequestObject[];
3342
+ meta: PaginationMeta;
3343
+ }
3182
3344
  export interface Plan {
3183
3345
  plan: PlanObject;
3184
3346
  }
@@ -3250,10 +3412,10 @@ export interface PlanCreateInput {
3250
3412
  */
3251
3413
  billable_metric_id?: string;
3252
3414
  /**
3253
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage` or `volume`.
3415
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage`, `volume` or `dynamic`.
3254
3416
  * @example "standard"
3255
3417
  */
3256
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3418
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3257
3419
  /**
3258
3420
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3259
3421
  * @example false
@@ -3452,10 +3614,10 @@ export interface PlanUpdateInput {
3452
3614
  */
3453
3615
  billable_metric_id?: string;
3454
3616
  /**
3455
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`.
3617
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`.
3456
3618
  * @example "standard"
3457
3619
  */
3458
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3620
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3459
3621
  /**
3460
3622
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3461
3623
  * @example false
@@ -3772,6 +3934,18 @@ export interface SubscriptionObject {
3772
3934
  * @example "2022-08-08T00:00:00Z"
3773
3935
  */
3774
3936
  trial_ended_at?: string | null;
3937
+ /**
3938
+ * The date and time when the current billing period started, represented in ISO 8601 date format.
3939
+ * @format date-time
3940
+ * @example "2022-08-08T00:00:00Z"
3941
+ */
3942
+ current_billing_period_started_at?: string | null;
3943
+ /**
3944
+ * The date and time when the current billing period ends, represented in ISO 8601 date format.
3945
+ * @format date-time
3946
+ * @example "2022-09-08T00:00:00Z"
3947
+ */
3948
+ current_billing_period_ending_at?: string | null;
3775
3949
  }
3776
3950
  export type SubscriptionObjectExtended = SubscriptionObject & {
3777
3951
  plan?: PlanObject;
@@ -4098,13 +4272,13 @@ export interface WalletObject {
4098
4272
  */
4099
4273
  rate_amount: string;
4100
4274
  /**
4101
- * The current wallet balance expressed in credits.
4275
+ * The current wallet balance expressed in credits. This reflects the available balance after all transactions are settled.
4102
4276
  * @pattern ^[0-9]+.?[0-9]*$
4103
4277
  * @example "28.0"
4104
4278
  */
4105
4279
  credits_balance: string;
4106
4280
  /**
4107
- * The current wallet balance expressed in cents.
4281
+ * The current wallet balance expressed in cents. This reflects the available balance after all transactions are settled.
4108
4282
  * @example 1000
4109
4283
  */
4110
4284
  balance_cents: number;
@@ -4225,23 +4399,23 @@ export interface WalletObject {
4225
4399
  }[];
4226
4400
  }[];
4227
4401
  /**
4228
- * The wallet ongoing balance expressed in cents.
4402
+ * The ongoing wallet balance expressed in cents. This represents the `balance_cents` minus the `ongoing_usage_balance_cents`, showing the real time balance after accounting for current usage including taxes.
4229
4403
  * @example 800
4230
4404
  */
4231
4405
  ongoing_balance_cents: number;
4232
4406
  /**
4233
- * The wallet ongoing usage balance expressed in cents.
4407
+ * The ongoing usage balance of the wallet, expressed in cents. This reflects all current usage including taxes.
4234
4408
  * @example 200
4235
4409
  */
4236
4410
  ongoing_usage_balance_cents: number;
4237
4411
  /**
4238
- * The wallet ongoing balance expressed in credits.
4412
+ * The ongoing wallet balance expressed in credits. This represents the `credits_balance` minus the `credits_ongoing_usage_balance`, showing the real time balance after accounting for current usage including taxes.
4239
4413
  * @pattern ^[0-9]+.?[0-9]*$
4240
4414
  * @example "8.0"
4241
4415
  */
4242
4416
  credits_ongoing_balance: string;
4243
4417
  /**
4244
- * The wallet ongoing usage balance expressed in credits.
4418
+ * The ongoing usage balance of the wallet, expressed in credits. This reflects all current usage including taxes.
4245
4419
  * @pattern ^[0-9]+.?[0-9]*$
4246
4420
  * @example "2.0"
4247
4421
  */
@@ -4587,9 +4761,9 @@ export declare class HttpClient<SecurityDataType = unknown> {
4587
4761
  }
4588
4762
  /**
4589
4763
  * @title Lago API documentation
4590
- * @version 1.11.0
4764
+ * @version 1.12.2
4591
4765
  * @license AGPLv3
4592
- * @baseUrl https://{region}.getlago.com/api/v1
4766
+ * @baseUrl https://api{region}getlago.com/api/v1
4593
4767
  * @externalDocs https://github.com/getlago
4594
4768
  * @contact <tech@getlago.com>
4595
4769
  *
@@ -5104,7 +5278,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5104
5278
  */
5105
5279
  portal_url: string;
5106
5280
  };
5107
- }, ApiErrorForbidden | ApiErrorUnauthorized | ApiErrorNotFound>>;
5281
+ }, ApiErrorUnauthorized | ApiErrorNotFound>>;
5108
5282
  /**
5109
5283
  * @description This endpoint enables the retrieval of the usage-based billing data for a customer within the current period.
5110
5284
  *
@@ -5202,6 +5376,52 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5202
5376
  * @secure
5203
5377
  */
5204
5378
  createEvent: (data: EventInput, params?: RequestParams) => Promise<HttpResponse<Event, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5379
+ /**
5380
+ * @description This endpoint is used for retrieving all events.
5381
+ *
5382
+ * @tags events
5383
+ * @name FindAllEvents
5384
+ * @summary List all events
5385
+ * @request GET:/events
5386
+ * @secure
5387
+ */
5388
+ findAllEvents: (query?: {
5389
+ /**
5390
+ * Page number.
5391
+ * @example 1
5392
+ */
5393
+ page?: number;
5394
+ /**
5395
+ * Number of records per page.
5396
+ * @example 20
5397
+ */
5398
+ per_page?: number;
5399
+ /**
5400
+ * External subscription ID
5401
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5402
+ */
5403
+ external_subscription_id?: string;
5404
+ /**
5405
+ * Filter events by its code.
5406
+ * @example "event-123"
5407
+ */
5408
+ code?: string;
5409
+ /**
5410
+ * Filter events by timestamp starting from a specific date.
5411
+ * @format date-time
5412
+ * @example "2022-08-08T00:00:00Z"
5413
+ */
5414
+ timestamp_from?: string;
5415
+ /**
5416
+ * Filter events by timestamp up to a specific date.
5417
+ * @format date-time
5418
+ * @example "2022-08-08T00:00:00Z"
5419
+ */
5420
+ timestamp_to?: string;
5421
+ }, params?: RequestParams) => Promise<HttpResponse<{
5422
+ events: EventObject[];
5423
+ meta: PaginationMeta;
5424
+ }, ApiErrorUnauthorized>>;
5205
5425
  /**
5206
5426
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
5207
5427
  *
@@ -5373,7 +5593,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5373
5593
  */
5374
5594
  createInvoice: (data: InvoiceOneOffCreateInput, params?: RequestParams) => Promise<HttpResponse<Invoice, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5375
5595
  /**
5376
- * @description This endpoint is used for retrievign all invoices.
5596
+ * @description This endpoint is used for retrieving all invoices.
5377
5597
  *
5378
5598
  * @tags invoices
5379
5599
  * @name FindAllInvoices
@@ -5604,44 +5824,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5604
5824
  lago_invoice_ids: string[];
5605
5825
  };
5606
5826
  }, params?: RequestParams) => Promise<HttpResponse<{
5607
- payment_request: {
5608
- /**
5609
- * Unique identifier of the payment request, created by Lago.
5610
- * @format uuid
5611
- * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
5612
- */
5613
- lago_id: string;
5614
- /**
5615
- * The customer's email address used for sending dunning notifications
5616
- * @format email
5617
- * @example "dinesh@piedpiper.test"
5618
- */
5619
- email: string;
5620
- /**
5621
- * The sum of the total amounts of all the invoices included in the payment request, expressed in cents.
5622
- * @example 100
5623
- */
5624
- amount_cents: number;
5625
- /** The currency of the payment request. */
5626
- amount_currency: Currency;
5627
- /**
5628
- * The status of the payment associated with the payment request. It can have one of the following values:
5629
- * - `pending`: the payment is pending, waiting for payment processing in the payment provider or when the invoice is emitted but users have not updated the payment status through the endpoint.
5630
- * - `succeeded`: the payment of the payment request has been successfully processed.
5631
- * - `failed`: the payment of the payment request has failed or encountered an error during processing.
5632
- * @example "succeeded"
5633
- */
5634
- payment_status: "pending" | "succeeded" | "failed";
5635
- /**
5636
- * The date and time when the payment request was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the payment request was initially created.
5637
- * @format date-time
5638
- * @example "2022-04-29T08:59:51Z"
5639
- */
5640
- created_at: string;
5641
- /** The customer on which the payment request applies. It refers to the customer account or entity associated with the payment request. */
5642
- customer: any;
5643
- invoices: any[];
5644
- };
5827
+ payment_request: PaymentRequestObject;
5645
5828
  }, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5646
5829
  /**
5647
5830
  * @description This endpoint is used to list all existing payment requests.
@@ -5668,10 +5851,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5668
5851
  * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5669
5852
  */
5670
5853
  external_customer_id?: string;
5671
- }, params?: RequestParams) => Promise<HttpResponse<{
5672
- payment_requests: any[];
5673
- meta: PaginationMeta;
5674
- }, ApiErrorUnauthorized>>;
5854
+ }, params?: RequestParams) => Promise<HttpResponse<PaymentRequestsPaginated, ApiErrorUnauthorized>>;
5675
5855
  };
5676
5856
  plans: {
5677
5857
  /**
@@ -5819,6 +5999,26 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5819
5999
  */
5820
6000
  status?: string;
5821
6001
  }, params?: RequestParams) => Promise<HttpResponse<Subscription, ApiErrorUnauthorized | ApiErrorNotAllowed | ApiErrorNotFound>>;
6002
+ /**
6003
+ * @description This endpoint enables the retrieval of the lifetime usage of a subscription.
6004
+ *
6005
+ * @tags subscriptions
6006
+ * @name GetSubscriptionLifetimeUsage
6007
+ * @summary Retrive subscription lifetime usage
6008
+ * @request GET:/subscriptions/{external_id}/lifetime_usage
6009
+ * @secure
6010
+ */
6011
+ getSubscriptionLifetimeUsage: (externalId: string, params?: RequestParams) => Promise<HttpResponse<LifetimeUsage, ApiErrorUnauthorized | ApiErrorNotFound>>;
6012
+ /**
6013
+ * @description This endpoint allows you to update the lifetime usage of a subscription.
6014
+ *
6015
+ * @tags subscriptions
6016
+ * @name UpdateSubscriptionLifetimeUsage
6017
+ * @summary Update a subscription lifetime usage
6018
+ * @request PUT:/subscriptions/{external_id}/lifetime_usage
6019
+ * @secure
6020
+ */
6021
+ updateSubscriptionLifetimeUsage: (externalId: string, data: LifetimeUsageInput, params?: RequestParams) => Promise<HttpResponse<LifetimeUsage, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity | ApiErrorNotFound>>;
5822
6022
  };
5823
6023
  taxes: {
5824
6024
  /**
@@ -16,7 +16,7 @@ export var ContentType;
16
16
  ContentType["Text"] = "text/plain";
17
17
  })(ContentType || (ContentType = {}));
18
18
  export class HttpClient {
19
- baseUrl = "https://{region}.getlago.com/api/v1";
19
+ baseUrl = "https://api{region}getlago.com/api/v1";
20
20
  securityData = null;
21
21
  securityWorker;
22
22
  abortControllers = new Map();
@@ -148,9 +148,9 @@ export class HttpClient {
148
148
  }
149
149
  /**
150
150
  * @title Lago API documentation
151
- * @version 1.11.0
151
+ * @version 1.12.2
152
152
  * @license AGPLv3
153
- * @baseUrl https://{region}.getlago.com/api/v1
153
+ * @baseUrl https://api{region}getlago.com/api/v1
154
154
  * @externalDocs https://github.com/getlago
155
155
  * @contact <tech@getlago.com>
156
156
  *
@@ -833,6 +833,23 @@ export class Api extends HttpClient {
833
833
  format: "json",
834
834
  ...params,
835
835
  }),
836
+ /**
837
+ * @description This endpoint is used for retrieving all events.
838
+ *
839
+ * @tags events
840
+ * @name FindAllEvents
841
+ * @summary List all events
842
+ * @request GET:/events
843
+ * @secure
844
+ */
845
+ findAllEvents: (query, params = {}) => this.request({
846
+ path: `/events`,
847
+ method: "GET",
848
+ query: query,
849
+ secure: true,
850
+ format: "json",
851
+ ...params,
852
+ }),
836
853
  /**
837
854
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
838
855
  *
@@ -974,7 +991,7 @@ export class Api extends HttpClient {
974
991
  ...params,
975
992
  }),
976
993
  /**
977
- * @description This endpoint is used for retrievign all invoices.
994
+ * @description This endpoint is used for retrieving all invoices.
978
995
  *
979
996
  * @tags invoices
980
997
  * @name FindAllInvoices
@@ -1383,6 +1400,40 @@ export class Api extends HttpClient {
1383
1400
  format: "json",
1384
1401
  ...params,
1385
1402
  }),
1403
+ /**
1404
+ * @description This endpoint enables the retrieval of the lifetime usage of a subscription.
1405
+ *
1406
+ * @tags subscriptions
1407
+ * @name GetSubscriptionLifetimeUsage
1408
+ * @summary Retrive subscription lifetime usage
1409
+ * @request GET:/subscriptions/{external_id}/lifetime_usage
1410
+ * @secure
1411
+ */
1412
+ getSubscriptionLifetimeUsage: (externalId, params = {}) => this.request({
1413
+ path: `/subscriptions/${externalId}/lifetime_usage`,
1414
+ method: "GET",
1415
+ secure: true,
1416
+ format: "json",
1417
+ ...params,
1418
+ }),
1419
+ /**
1420
+ * @description This endpoint allows you to update the lifetime usage of a subscription.
1421
+ *
1422
+ * @tags subscriptions
1423
+ * @name UpdateSubscriptionLifetimeUsage
1424
+ * @summary Update a subscription lifetime usage
1425
+ * @request PUT:/subscriptions/{external_id}/lifetime_usage
1426
+ * @secure
1427
+ */
1428
+ updateSubscriptionLifetimeUsage: (externalId, data, params = {}) => this.request({
1429
+ path: `/subscriptions/${externalId}/lifetime_usage`,
1430
+ method: "PUT",
1431
+ body: data,
1432
+ secure: true,
1433
+ type: ContentType.Json,
1434
+ format: "json",
1435
+ ...params,
1436
+ }),
1386
1437
  };
1387
1438
  taxes = {
1388
1439
  /**
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/mod.js",
4
4
  "name": "lago-javascript-client",
5
5
  "sideEffects": false,
6
- "version": "v1.11.0",
6
+ "version": "v1.12.3",
7
7
  "description": "Lago JavaScript API Client",
8
8
  "repository": {
9
9
  "type": "git",
@@ -560,8 +560,8 @@ export interface ChargeObject {
560
560
  * @example "2022-09-14T16:35:31Z"
561
561
  */
562
562
  created_at: string;
563
- /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`. */
564
- charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
563
+ /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`. */
564
+ charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
565
565
  /**
566
566
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to `false`, the charge is due and invoiced at the end of each billing period.
567
567
  * @example true
@@ -1633,6 +1633,22 @@ export interface CustomerCreateInput {
1633
1633
  * @example "Gavin Belson"
1634
1634
  */
1635
1635
  name?: string | null;
1636
+ /**
1637
+ * First name of the customer
1638
+ * @example "Gavin"
1639
+ */
1640
+ firstname?: string | null;
1641
+ /**
1642
+ * Last name of the customer
1643
+ * @example "Belson"
1644
+ */
1645
+ lastname?: string | null;
1646
+ /**
1647
+ * The type of the customer. It can have one of the following values:
1648
+ * - `company`: the customer is a company.
1649
+ * - `individual`: the customer is an individual.
1650
+ */
1651
+ customer_type?: "company" | "individual" | null;
1636
1652
  /**
1637
1653
  * The phone number of the customer
1638
1654
  * @example "1-171-883-3711 x245"
@@ -1841,6 +1857,22 @@ export type CustomerObject = {
1841
1857
  * @example "Gavin Belson"
1842
1858
  */
1843
1859
  name?: string | null;
1860
+ /**
1861
+ * First name of the customer
1862
+ * @example "Gavin"
1863
+ */
1864
+ firstname?: string | null;
1865
+ /**
1866
+ * Last name of the customer
1867
+ * @example "Belson"
1868
+ */
1869
+ lastname?: string | null;
1870
+ /**
1871
+ * The type of the customer. It can have one of the following values:
1872
+ * - `company`: the customer is a company.
1873
+ * - `individual`: the customer is an individual.
1874
+ */
1875
+ customer_type?: "company" | "individual" | null;
1844
1876
  /**
1845
1877
  * The phone number of the customer
1846
1878
  * @example "1-171-883-3711 x245"
@@ -1992,10 +2024,10 @@ export interface EventInput {
1992
2024
  */
1993
2025
  transaction_id: string;
1994
2026
  /**
1995
- * The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the `external_customer_id` is not provided.
2027
+ * The unique identifier of the subscription in your application. This field is mandatory in order to link events to the correct customer subscription.
1996
2028
  * @example "sub_1234567890"
1997
2029
  */
1998
- external_subscription_id?: string;
2030
+ external_subscription_id: string;
1999
2031
  /**
2000
2032
  * The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
2001
2033
  * @example "storage"
@@ -2008,6 +2040,11 @@ export interface EventInput {
2008
2040
  * @example "1651240791.123"
2009
2041
  */
2010
2042
  timestamp?: number | string;
2043
+ /**
2044
+ * The precise total amount in cents with precision used by the `dynamic` pricing model to compute the usage amount.
2045
+ * @example "1234.56"
2046
+ */
2047
+ precise_total_amount_cents?: string | null;
2011
2048
  /**
2012
2049
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2013
2050
  * @example {"gb":10}
@@ -2044,6 +2081,11 @@ export interface EventObject {
2044
2081
  * @example "2022-04-29T08:59:51.123Z"
2045
2082
  */
2046
2083
  timestamp: string;
2084
+ /**
2085
+ * The precise total amount that was sent in the event payload. This filed is used by the `dynamic` pricing model.
2086
+ * @example "1234.56"
2087
+ */
2088
+ precise_total_amount_cents?: string | null;
2047
2089
  /**
2048
2090
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2049
2091
  * @example {"gb":10}
@@ -2505,6 +2547,84 @@ export interface GrossRevenueObject {
2505
2547
  export interface GrossRevenues {
2506
2548
  gross_revenues: GrossRevenueObject[];
2507
2549
  }
2550
+ export interface LifetimeUsage {
2551
+ lifetime_usage: LifetimeUsageObject;
2552
+ }
2553
+ export interface LifetimeUsageInput {
2554
+ lifetime_usage: {
2555
+ /**
2556
+ * The historical usage amount in cents for the subscription (provided by your own application).
2557
+ * @example 100
2558
+ */
2559
+ external_historical_usage_amount_cents: number;
2560
+ };
2561
+ }
2562
+ export interface LifetimeUsageObject {
2563
+ /**
2564
+ * Unique identifier assigned to the lifetime usage record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the lifetime usage record within the Lago system
2565
+ * @format uuid
2566
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
2567
+ */
2568
+ lago_id: string;
2569
+ /**
2570
+ * Unique identifier assigned to the subscription record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the subscription record within the Lago system
2571
+ * @format uuid
2572
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
2573
+ */
2574
+ lago_subscription_id: string;
2575
+ /**
2576
+ * The subscription external unique identifier (provided by your own application).
2577
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
2578
+ */
2579
+ external_subscription_id: string;
2580
+ /**
2581
+ * The historical usage amount in cents for the subscription (provided by your own application).
2582
+ * @example 100
2583
+ */
2584
+ external_historical_usage_amount_cents: number;
2585
+ /**
2586
+ * The total invoiced usage amount in cents for the subscription.
2587
+ * @example 100
2588
+ */
2589
+ invoiced_usage_amount_cents: number;
2590
+ /**
2591
+ * The current usage amount in cents for the subscription on the current billing period.
2592
+ * @example 100
2593
+ */
2594
+ current_usage_amount_cents: number;
2595
+ /**
2596
+ * The recording start date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
2597
+ * @format date-time
2598
+ * @example "2024-01-01T00:00:00Z"
2599
+ */
2600
+ from_datetime: string;
2601
+ /**
2602
+ * The recording end date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
2603
+ * @format date-time
2604
+ * @example "2024-12-31T23:59:59Z"
2605
+ */
2606
+ to_datetime: string;
2607
+ /** Array of usage thresholds attached to the subscription's plan. */
2608
+ usage_thresholds?: LifetimeUsageThresholdObject[];
2609
+ }
2610
+ export interface LifetimeUsageThresholdObject {
2611
+ /**
2612
+ * The usage threshold amount in cents.
2613
+ * @example 100
2614
+ */
2615
+ amount_cents: number;
2616
+ /**
2617
+ * The completion ratio of the usage threshold.
2618
+ * @example 0.5
2619
+ */
2620
+ completion_ratio: number;
2621
+ /**
2622
+ * The date and time when the usage threshold was reached. The date and time must be in ISO 8601 format.
2623
+ * @format date-time
2624
+ * @example "2024-01-01T00:00:00Z"
2625
+ */
2626
+ reached_at: string | null;
2627
+ }
2508
2628
  /** Minimum commitment for this plan. */
2509
2629
  export type MinimumCommitmentInput = {
2510
2630
  /**
@@ -3179,6 +3299,48 @@ export interface PaginationMeta {
3179
3299
  */
3180
3300
  total_count: number;
3181
3301
  }
3302
+ export interface PaymentRequestObject {
3303
+ /**
3304
+ * Unique identifier of the payment request, created by Lago.
3305
+ * @format uuid
3306
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
3307
+ */
3308
+ lago_id: string;
3309
+ /**
3310
+ * The customer's email address used for sending dunning notifications
3311
+ * @format email
3312
+ * @example "dinesh@piedpiper.test"
3313
+ */
3314
+ email: string;
3315
+ /**
3316
+ * The sum of the total amounts of all the invoices included in the payment request, expressed in cents.
3317
+ * @example 100
3318
+ */
3319
+ amount_cents: number;
3320
+ /** The currency of the payment request. */
3321
+ amount_currency: Currency;
3322
+ /**
3323
+ * The status of the payment associated with the payment request. It can have one of the following values:
3324
+ * - `pending`: the payment is pending, waiting for payment processing in the payment provider or when the invoice is emitted but users have not updated the payment status through the endpoint.
3325
+ * - `succeeded`: the payment of the payment request has been successfully processed.
3326
+ * - `failed`: the payment of the payment request has failed or encountered an error during processing.
3327
+ * @example "succeeded"
3328
+ */
3329
+ payment_status: "pending" | "succeeded" | "failed";
3330
+ /**
3331
+ * The date and time when the payment request was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the payment request was initially created.
3332
+ * @format date-time
3333
+ * @example "2022-04-29T08:59:51Z"
3334
+ */
3335
+ created_at: string;
3336
+ /** The customer on which the payment request applies. It refers to the customer account or entity associated with the payment request. */
3337
+ customer: any;
3338
+ invoices: any[];
3339
+ }
3340
+ export interface PaymentRequestsPaginated {
3341
+ payment_requests: PaymentRequestObject[];
3342
+ meta: PaginationMeta;
3343
+ }
3182
3344
  export interface Plan {
3183
3345
  plan: PlanObject;
3184
3346
  }
@@ -3250,10 +3412,10 @@ export interface PlanCreateInput {
3250
3412
  */
3251
3413
  billable_metric_id?: string;
3252
3414
  /**
3253
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage` or `volume`.
3415
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage`, `volume` or `dynamic`.
3254
3416
  * @example "standard"
3255
3417
  */
3256
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3418
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3257
3419
  /**
3258
3420
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3259
3421
  * @example false
@@ -3452,10 +3614,10 @@ export interface PlanUpdateInput {
3452
3614
  */
3453
3615
  billable_metric_id?: string;
3454
3616
  /**
3455
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`.
3617
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`.
3456
3618
  * @example "standard"
3457
3619
  */
3458
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3620
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3459
3621
  /**
3460
3622
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3461
3623
  * @example false
@@ -3772,6 +3934,18 @@ export interface SubscriptionObject {
3772
3934
  * @example "2022-08-08T00:00:00Z"
3773
3935
  */
3774
3936
  trial_ended_at?: string | null;
3937
+ /**
3938
+ * The date and time when the current billing period started, represented in ISO 8601 date format.
3939
+ * @format date-time
3940
+ * @example "2022-08-08T00:00:00Z"
3941
+ */
3942
+ current_billing_period_started_at?: string | null;
3943
+ /**
3944
+ * The date and time when the current billing period ends, represented in ISO 8601 date format.
3945
+ * @format date-time
3946
+ * @example "2022-09-08T00:00:00Z"
3947
+ */
3948
+ current_billing_period_ending_at?: string | null;
3775
3949
  }
3776
3950
  export type SubscriptionObjectExtended = SubscriptionObject & {
3777
3951
  plan?: PlanObject;
@@ -4098,13 +4272,13 @@ export interface WalletObject {
4098
4272
  */
4099
4273
  rate_amount: string;
4100
4274
  /**
4101
- * The current wallet balance expressed in credits.
4275
+ * The current wallet balance expressed in credits. This reflects the available balance after all transactions are settled.
4102
4276
  * @pattern ^[0-9]+.?[0-9]*$
4103
4277
  * @example "28.0"
4104
4278
  */
4105
4279
  credits_balance: string;
4106
4280
  /**
4107
- * The current wallet balance expressed in cents.
4281
+ * The current wallet balance expressed in cents. This reflects the available balance after all transactions are settled.
4108
4282
  * @example 1000
4109
4283
  */
4110
4284
  balance_cents: number;
@@ -4225,23 +4399,23 @@ export interface WalletObject {
4225
4399
  }[];
4226
4400
  }[];
4227
4401
  /**
4228
- * The wallet ongoing balance expressed in cents.
4402
+ * The ongoing wallet balance expressed in cents. This represents the `balance_cents` minus the `ongoing_usage_balance_cents`, showing the real time balance after accounting for current usage including taxes.
4229
4403
  * @example 800
4230
4404
  */
4231
4405
  ongoing_balance_cents: number;
4232
4406
  /**
4233
- * The wallet ongoing usage balance expressed in cents.
4407
+ * The ongoing usage balance of the wallet, expressed in cents. This reflects all current usage including taxes.
4234
4408
  * @example 200
4235
4409
  */
4236
4410
  ongoing_usage_balance_cents: number;
4237
4411
  /**
4238
- * The wallet ongoing balance expressed in credits.
4412
+ * The ongoing wallet balance expressed in credits. This represents the `credits_balance` minus the `credits_ongoing_usage_balance`, showing the real time balance after accounting for current usage including taxes.
4239
4413
  * @pattern ^[0-9]+.?[0-9]*$
4240
4414
  * @example "8.0"
4241
4415
  */
4242
4416
  credits_ongoing_balance: string;
4243
4417
  /**
4244
- * The wallet ongoing usage balance expressed in credits.
4418
+ * The ongoing usage balance of the wallet, expressed in credits. This reflects all current usage including taxes.
4245
4419
  * @pattern ^[0-9]+.?[0-9]*$
4246
4420
  * @example "2.0"
4247
4421
  */
@@ -4587,9 +4761,9 @@ export declare class HttpClient<SecurityDataType = unknown> {
4587
4761
  }
4588
4762
  /**
4589
4763
  * @title Lago API documentation
4590
- * @version 1.11.0
4764
+ * @version 1.12.2
4591
4765
  * @license AGPLv3
4592
- * @baseUrl https://{region}.getlago.com/api/v1
4766
+ * @baseUrl https://api{region}getlago.com/api/v1
4593
4767
  * @externalDocs https://github.com/getlago
4594
4768
  * @contact <tech@getlago.com>
4595
4769
  *
@@ -5104,7 +5278,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5104
5278
  */
5105
5279
  portal_url: string;
5106
5280
  };
5107
- }, ApiErrorForbidden | ApiErrorUnauthorized | ApiErrorNotFound>>;
5281
+ }, ApiErrorUnauthorized | ApiErrorNotFound>>;
5108
5282
  /**
5109
5283
  * @description This endpoint enables the retrieval of the usage-based billing data for a customer within the current period.
5110
5284
  *
@@ -5202,6 +5376,52 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5202
5376
  * @secure
5203
5377
  */
5204
5378
  createEvent: (data: EventInput, params?: RequestParams) => Promise<HttpResponse<Event, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5379
+ /**
5380
+ * @description This endpoint is used for retrieving all events.
5381
+ *
5382
+ * @tags events
5383
+ * @name FindAllEvents
5384
+ * @summary List all events
5385
+ * @request GET:/events
5386
+ * @secure
5387
+ */
5388
+ findAllEvents: (query?: {
5389
+ /**
5390
+ * Page number.
5391
+ * @example 1
5392
+ */
5393
+ page?: number;
5394
+ /**
5395
+ * Number of records per page.
5396
+ * @example 20
5397
+ */
5398
+ per_page?: number;
5399
+ /**
5400
+ * External subscription ID
5401
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5402
+ */
5403
+ external_subscription_id?: string;
5404
+ /**
5405
+ * Filter events by its code.
5406
+ * @example "event-123"
5407
+ */
5408
+ code?: string;
5409
+ /**
5410
+ * Filter events by timestamp starting from a specific date.
5411
+ * @format date-time
5412
+ * @example "2022-08-08T00:00:00Z"
5413
+ */
5414
+ timestamp_from?: string;
5415
+ /**
5416
+ * Filter events by timestamp up to a specific date.
5417
+ * @format date-time
5418
+ * @example "2022-08-08T00:00:00Z"
5419
+ */
5420
+ timestamp_to?: string;
5421
+ }, params?: RequestParams) => Promise<HttpResponse<{
5422
+ events: EventObject[];
5423
+ meta: PaginationMeta;
5424
+ }, ApiErrorUnauthorized>>;
5205
5425
  /**
5206
5426
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
5207
5427
  *
@@ -5373,7 +5593,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5373
5593
  */
5374
5594
  createInvoice: (data: InvoiceOneOffCreateInput, params?: RequestParams) => Promise<HttpResponse<Invoice, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5375
5595
  /**
5376
- * @description This endpoint is used for retrievign all invoices.
5596
+ * @description This endpoint is used for retrieving all invoices.
5377
5597
  *
5378
5598
  * @tags invoices
5379
5599
  * @name FindAllInvoices
@@ -5604,44 +5824,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5604
5824
  lago_invoice_ids: string[];
5605
5825
  };
5606
5826
  }, params?: RequestParams) => Promise<HttpResponse<{
5607
- payment_request: {
5608
- /**
5609
- * Unique identifier of the payment request, created by Lago.
5610
- * @format uuid
5611
- * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
5612
- */
5613
- lago_id: string;
5614
- /**
5615
- * The customer's email address used for sending dunning notifications
5616
- * @format email
5617
- * @example "dinesh@piedpiper.test"
5618
- */
5619
- email: string;
5620
- /**
5621
- * The sum of the total amounts of all the invoices included in the payment request, expressed in cents.
5622
- * @example 100
5623
- */
5624
- amount_cents: number;
5625
- /** The currency of the payment request. */
5626
- amount_currency: Currency;
5627
- /**
5628
- * The status of the payment associated with the payment request. It can have one of the following values:
5629
- * - `pending`: the payment is pending, waiting for payment processing in the payment provider or when the invoice is emitted but users have not updated the payment status through the endpoint.
5630
- * - `succeeded`: the payment of the payment request has been successfully processed.
5631
- * - `failed`: the payment of the payment request has failed or encountered an error during processing.
5632
- * @example "succeeded"
5633
- */
5634
- payment_status: "pending" | "succeeded" | "failed";
5635
- /**
5636
- * The date and time when the payment request was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the payment request was initially created.
5637
- * @format date-time
5638
- * @example "2022-04-29T08:59:51Z"
5639
- */
5640
- created_at: string;
5641
- /** The customer on which the payment request applies. It refers to the customer account or entity associated with the payment request. */
5642
- customer: any;
5643
- invoices: any[];
5644
- };
5827
+ payment_request: PaymentRequestObject;
5645
5828
  }, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5646
5829
  /**
5647
5830
  * @description This endpoint is used to list all existing payment requests.
@@ -5668,10 +5851,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5668
5851
  * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5669
5852
  */
5670
5853
  external_customer_id?: string;
5671
- }, params?: RequestParams) => Promise<HttpResponse<{
5672
- payment_requests: any[];
5673
- meta: PaginationMeta;
5674
- }, ApiErrorUnauthorized>>;
5854
+ }, params?: RequestParams) => Promise<HttpResponse<PaymentRequestsPaginated, ApiErrorUnauthorized>>;
5675
5855
  };
5676
5856
  plans: {
5677
5857
  /**
@@ -5819,6 +5999,26 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5819
5999
  */
5820
6000
  status?: string;
5821
6001
  }, params?: RequestParams) => Promise<HttpResponse<Subscription, ApiErrorUnauthorized | ApiErrorNotAllowed | ApiErrorNotFound>>;
6002
+ /**
6003
+ * @description This endpoint enables the retrieval of the lifetime usage of a subscription.
6004
+ *
6005
+ * @tags subscriptions
6006
+ * @name GetSubscriptionLifetimeUsage
6007
+ * @summary Retrive subscription lifetime usage
6008
+ * @request GET:/subscriptions/{external_id}/lifetime_usage
6009
+ * @secure
6010
+ */
6011
+ getSubscriptionLifetimeUsage: (externalId: string, params?: RequestParams) => Promise<HttpResponse<LifetimeUsage, ApiErrorUnauthorized | ApiErrorNotFound>>;
6012
+ /**
6013
+ * @description This endpoint allows you to update the lifetime usage of a subscription.
6014
+ *
6015
+ * @tags subscriptions
6016
+ * @name UpdateSubscriptionLifetimeUsage
6017
+ * @summary Update a subscription lifetime usage
6018
+ * @request PUT:/subscriptions/{external_id}/lifetime_usage
6019
+ * @secure
6020
+ */
6021
+ updateSubscriptionLifetimeUsage: (externalId: string, data: LifetimeUsageInput, params?: RequestParams) => Promise<HttpResponse<LifetimeUsage, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity | ApiErrorNotFound>>;
5822
6022
  };
5823
6023
  taxes: {
5824
6024
  /**
@@ -19,7 +19,7 @@ var ContentType;
19
19
  ContentType["Text"] = "text/plain";
20
20
  })(ContentType = exports.ContentType || (exports.ContentType = {}));
21
21
  class HttpClient {
22
- baseUrl = "https://{region}.getlago.com/api/v1";
22
+ baseUrl = "https://api{region}getlago.com/api/v1";
23
23
  securityData = null;
24
24
  securityWorker;
25
25
  abortControllers = new Map();
@@ -152,9 +152,9 @@ class HttpClient {
152
152
  exports.HttpClient = HttpClient;
153
153
  /**
154
154
  * @title Lago API documentation
155
- * @version 1.11.0
155
+ * @version 1.12.2
156
156
  * @license AGPLv3
157
- * @baseUrl https://{region}.getlago.com/api/v1
157
+ * @baseUrl https://api{region}getlago.com/api/v1
158
158
  * @externalDocs https://github.com/getlago
159
159
  * @contact <tech@getlago.com>
160
160
  *
@@ -837,6 +837,23 @@ class Api extends HttpClient {
837
837
  format: "json",
838
838
  ...params,
839
839
  }),
840
+ /**
841
+ * @description This endpoint is used for retrieving all events.
842
+ *
843
+ * @tags events
844
+ * @name FindAllEvents
845
+ * @summary List all events
846
+ * @request GET:/events
847
+ * @secure
848
+ */
849
+ findAllEvents: (query, params = {}) => this.request({
850
+ path: `/events`,
851
+ method: "GET",
852
+ query: query,
853
+ secure: true,
854
+ format: "json",
855
+ ...params,
856
+ }),
840
857
  /**
841
858
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
842
859
  *
@@ -978,7 +995,7 @@ class Api extends HttpClient {
978
995
  ...params,
979
996
  }),
980
997
  /**
981
- * @description This endpoint is used for retrievign all invoices.
998
+ * @description This endpoint is used for retrieving all invoices.
982
999
  *
983
1000
  * @tags invoices
984
1001
  * @name FindAllInvoices
@@ -1387,6 +1404,40 @@ class Api extends HttpClient {
1387
1404
  format: "json",
1388
1405
  ...params,
1389
1406
  }),
1407
+ /**
1408
+ * @description This endpoint enables the retrieval of the lifetime usage of a subscription.
1409
+ *
1410
+ * @tags subscriptions
1411
+ * @name GetSubscriptionLifetimeUsage
1412
+ * @summary Retrive subscription lifetime usage
1413
+ * @request GET:/subscriptions/{external_id}/lifetime_usage
1414
+ * @secure
1415
+ */
1416
+ getSubscriptionLifetimeUsage: (externalId, params = {}) => this.request({
1417
+ path: `/subscriptions/${externalId}/lifetime_usage`,
1418
+ method: "GET",
1419
+ secure: true,
1420
+ format: "json",
1421
+ ...params,
1422
+ }),
1423
+ /**
1424
+ * @description This endpoint allows you to update the lifetime usage of a subscription.
1425
+ *
1426
+ * @tags subscriptions
1427
+ * @name UpdateSubscriptionLifetimeUsage
1428
+ * @summary Update a subscription lifetime usage
1429
+ * @request PUT:/subscriptions/{external_id}/lifetime_usage
1430
+ * @secure
1431
+ */
1432
+ updateSubscriptionLifetimeUsage: (externalId, data, params = {}) => this.request({
1433
+ path: `/subscriptions/${externalId}/lifetime_usage`,
1434
+ method: "PUT",
1435
+ body: data,
1436
+ secure: true,
1437
+ type: ContentType.Json,
1438
+ format: "json",
1439
+ ...params,
1440
+ }),
1390
1441
  };
1391
1442
  taxes = {
1392
1443
  /**