lark-billing 0.1.5 → 0.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +17 -46
  3. package/client.d.mts +7 -10
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +7 -10
  6. package/client.d.ts.map +1 -1
  7. package/client.js +3 -6
  8. package/client.js.map +1 -1
  9. package/client.mjs +3 -6
  10. package/client.mjs.map +1 -1
  11. package/package.json +2 -2
  12. package/resources/customer-portal.d.mts +5 -0
  13. package/resources/customer-portal.d.mts.map +1 -1
  14. package/resources/customer-portal.d.ts +5 -0
  15. package/resources/customer-portal.d.ts.map +1 -1
  16. package/resources/index.d.mts +3 -4
  17. package/resources/index.d.mts.map +1 -1
  18. package/resources/index.d.ts +3 -4
  19. package/resources/index.d.ts.map +1 -1
  20. package/resources/index.js +1 -3
  21. package/resources/index.js.map +1 -1
  22. package/resources/index.mjs +0 -1
  23. package/resources/index.mjs.map +1 -1
  24. package/resources/invoices.d.mts +15 -5
  25. package/resources/invoices.d.mts.map +1 -1
  26. package/resources/invoices.d.ts +15 -5
  27. package/resources/invoices.d.ts.map +1 -1
  28. package/resources/pricing-metrics.d.mts +19 -19
  29. package/resources/pricing-metrics.d.mts.map +1 -1
  30. package/resources/pricing-metrics.d.ts +19 -19
  31. package/resources/pricing-metrics.d.ts.map +1 -1
  32. package/resources/pricing-metrics.js +12 -12
  33. package/resources/pricing-metrics.js.map +1 -1
  34. package/resources/pricing-metrics.mjs +12 -12
  35. package/resources/pricing-metrics.mjs.map +1 -1
  36. package/resources/rate-cards.d.mts +4 -23
  37. package/resources/rate-cards.d.mts.map +1 -1
  38. package/resources/rate-cards.d.ts +4 -23
  39. package/resources/rate-cards.d.ts.map +1 -1
  40. package/resources/rate-cards.js +0 -20
  41. package/resources/rate-cards.js.map +1 -1
  42. package/resources/rate-cards.mjs +0 -20
  43. package/resources/rate-cards.mjs.map +1 -1
  44. package/resources/subscriptions.d.mts +92 -14
  45. package/resources/subscriptions.d.mts.map +1 -1
  46. package/resources/subscriptions.d.ts +92 -14
  47. package/resources/subscriptions.d.ts.map +1 -1
  48. package/resources/subscriptions.js +8 -5
  49. package/resources/subscriptions.js.map +1 -1
  50. package/resources/subscriptions.mjs +8 -5
  51. package/resources/subscriptions.mjs.map +1 -1
  52. package/resources/usage-events.d.mts +1 -1
  53. package/resources/usage-events.d.ts +1 -1
  54. package/resources/usage-events.js +1 -1
  55. package/resources/usage-events.mjs +1 -1
  56. package/src/client.ts +11 -23
  57. package/src/resources/customer-portal.ts +6 -0
  58. package/src/resources/index.ts +4 -9
  59. package/src/resources/invoices.ts +21 -5
  60. package/src/resources/pricing-metrics.ts +22 -22
  61. package/src/resources/rate-cards.ts +5 -23
  62. package/src/resources/subscriptions.ts +108 -14
  63. package/src/resources/usage-events.ts +1 -1
  64. package/src/version.ts +1 -1
  65. package/version.d.mts +1 -1
  66. package/version.d.ts +1 -1
  67. package/version.js +1 -1
  68. package/version.mjs +1 -1
  69. package/resources/checkout.d.mts +0 -61
  70. package/resources/checkout.d.mts.map +0 -1
  71. package/resources/checkout.d.ts +0 -61
  72. package/resources/checkout.d.ts.map +0 -1
  73. package/resources/checkout.js +0 -15
  74. package/resources/checkout.js.map +0 -1
  75. package/resources/checkout.mjs +0 -11
  76. package/resources/checkout.mjs.map +0 -1
  77. package/src/resources/checkout.ts +0 -81
@@ -14,7 +14,7 @@ export declare class UsageEvents extends APIResource {
14
14
  * region: 'us-east-1',
15
15
  * },
16
16
  * event_name: 'compute_hours',
17
- * idempotency_key: 'cdd158d3-c865-4dc3-a652-053d81906a30',
17
+ * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
18
18
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
19
19
  * });
20
20
  * ```
@@ -14,7 +14,7 @@ export declare class UsageEvents extends APIResource {
14
14
  * region: 'us-east-1',
15
15
  * },
16
16
  * event_name: 'compute_hours',
17
- * idempotency_key: 'cdd158d3-c865-4dc3-a652-053d81906a30',
17
+ * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
18
18
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
19
19
  * });
20
20
  * ```
@@ -16,7 +16,7 @@ class UsageEvents extends resource_1.APIResource {
16
16
  * region: 'us-east-1',
17
17
  * },
18
18
  * event_name: 'compute_hours',
19
- * idempotency_key: 'cdd158d3-c865-4dc3-a652-053d81906a30',
19
+ * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
20
20
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
21
21
  * });
22
22
  * ```
@@ -13,7 +13,7 @@ export class UsageEvents extends APIResource {
13
13
  * region: 'us-east-1',
14
14
  * },
15
15
  * event_name: 'compute_hours',
16
- * idempotency_key: 'cdd158d3-c865-4dc3-a652-053d81906a30',
16
+ * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
17
17
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
18
18
  * });
19
19
  * ```
package/src/client.ts CHANGED
@@ -16,28 +16,21 @@ import * as Errors from './core/error';
16
16
  import * as Uploads from './core/uploads';
17
17
  import * as API from './resources/index';
18
18
  import { APIPromise } from './core/api-promise';
19
- import {
20
- AmountOutput,
21
- Checkout,
22
- CheckoutCallback,
23
- CheckoutCreateParams,
24
- CheckoutCreateResponse,
25
- } from './resources/checkout';
26
19
  import { CustomerAccess, CustomerAccessRetrieveBillingStateResponse } from './resources/customer-access';
27
20
  import {
28
21
  CustomerPortal,
29
22
  CustomerPortalCreateSessionParams,
30
23
  CustomerPortalCreateSessionResponse,
31
24
  } from './resources/customer-portal';
32
- import { InvoiceListParams, InvoiceListResponse, Invoices } from './resources/invoices';
25
+ import { AmountOutput, InvoiceListParams, InvoiceListResponse, Invoices } from './resources/invoices';
33
26
  import {
34
27
  Period,
35
- PricingMetric,
36
28
  PricingMetricCreateParams,
37
29
  PricingMetricCreateSummaryParams,
38
30
  PricingMetricCreateSummaryResponse,
39
31
  PricingMetricListParams,
40
32
  PricingMetricListResponse,
33
+ PricingMetricResource,
41
34
  PricingMetrics,
42
35
  } from './resources/pricing-metrics';
43
36
  import {
@@ -63,10 +56,12 @@ import {
63
56
  Subjects,
64
57
  } from './resources/subjects';
65
58
  import {
59
+ CheckoutCallback,
66
60
  SubscriptionCancelParams,
67
61
  SubscriptionChangeRateCardParams,
68
62
  SubscriptionChangeRateCardResponse,
69
63
  SubscriptionCreateParams,
64
+ SubscriptionCreateResponse,
70
65
  SubscriptionListParams,
71
66
  SubscriptionListResponse,
72
67
  SubscriptionResource,
@@ -183,7 +178,7 @@ export class Lark {
183
178
  * API Client for interfacing with the Lark API.
184
179
  *
185
180
  * @param {string | undefined} [opts.apiKey=process.env['LARK_API_KEY'] ?? undefined]
186
- * @param {string} [opts.baseURL=process.env['LARK_BASE_URL'] ?? https://api.example.com] - Override the default base URL for the API.
181
+ * @param {string} [opts.baseURL=process.env['LARK_BASE_URL'] ?? https://api.uselark.ai] - Override the default base URL for the API.
187
182
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
188
183
  * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
189
184
  * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -205,7 +200,7 @@ export class Lark {
205
200
  const options: ClientOptions = {
206
201
  apiKey,
207
202
  ...opts,
208
- baseURL: baseURL || `https://api.example.com`,
203
+ baseURL: baseURL || `https://api.uselark.ai`,
209
204
  };
210
205
 
211
206
  this.baseURL = options.baseURL!;
@@ -251,7 +246,7 @@ export class Lark {
251
246
  * Check whether the base URL is set to its default.
252
247
  */
253
248
  #baseURLOverridden(): boolean {
254
- return this.baseURL !== 'https://api.example.com';
249
+ return this.baseURL !== 'https://api.uselark.ai';
255
250
  }
256
251
 
257
252
  protected defaultQuery(): Record<string, string | undefined> | undefined {
@@ -770,7 +765,6 @@ export class Lark {
770
765
 
771
766
  static toFile = Uploads.toFile;
772
767
 
773
- checkout: API.Checkout = new API.Checkout(this);
774
768
  customerPortal: API.CustomerPortal = new API.CustomerPortal(this);
775
769
  rateCards: API.RateCards = new API.RateCards(this);
776
770
  usageEvents: API.UsageEvents = new API.UsageEvents(this);
@@ -781,7 +775,6 @@ export class Lark {
781
775
  invoices: API.Invoices = new API.Invoices(this);
782
776
  }
783
777
 
784
- Lark.Checkout = Checkout;
785
778
  Lark.CustomerPortal = CustomerPortal;
786
779
  Lark.RateCards = RateCards;
787
780
  Lark.UsageEvents = UsageEvents;
@@ -794,14 +787,6 @@ Lark.Invoices = Invoices;
794
787
  export declare namespace Lark {
795
788
  export type RequestOptions = Opts.RequestOptions;
796
789
 
797
- export {
798
- Checkout as Checkout,
799
- type AmountOutput as AmountOutput,
800
- type CheckoutCallback as CheckoutCallback,
801
- type CheckoutCreateResponse as CheckoutCreateResponse,
802
- type CheckoutCreateParams as CheckoutCreateParams,
803
- };
804
-
805
790
  export {
806
791
  CustomerPortal as CustomerPortal,
807
792
  type CustomerPortalCreateSessionResponse as CustomerPortalCreateSessionResponse,
@@ -829,7 +814,9 @@ export declare namespace Lark {
829
814
 
830
815
  export {
831
816
  Subscriptions as Subscriptions,
817
+ type CheckoutCallback as CheckoutCallback,
832
818
  type SubscriptionResource as SubscriptionResource,
819
+ type SubscriptionCreateResponse as SubscriptionCreateResponse,
833
820
  type SubscriptionListResponse as SubscriptionListResponse,
834
821
  type SubscriptionChangeRateCardResponse as SubscriptionChangeRateCardResponse,
835
822
  type SubscriptionCreateParams as SubscriptionCreateParams,
@@ -852,7 +839,7 @@ export declare namespace Lark {
852
839
  export {
853
840
  PricingMetrics as PricingMetrics,
854
841
  type Period as Period,
855
- type PricingMetric as PricingMetric,
842
+ type PricingMetricResource as PricingMetricResource,
856
843
  type PricingMetricListResponse as PricingMetricListResponse,
857
844
  type PricingMetricCreateSummaryResponse as PricingMetricCreateSummaryResponse,
858
845
  type PricingMetricCreateParams as PricingMetricCreateParams,
@@ -867,6 +854,7 @@ export declare namespace Lark {
867
854
 
868
855
  export {
869
856
  Invoices as Invoices,
857
+ type AmountOutput as AmountOutput,
870
858
  type InvoiceListResponse as InvoiceListResponse,
871
859
  type InvoiceListParams as InvoiceListParams,
872
860
  };
@@ -34,6 +34,12 @@ export interface CustomerPortalCreateSessionResponse {
34
34
  }
35
35
 
36
36
  export interface CustomerPortalCreateSessionParams {
37
+ /**
38
+ * The URL to redirect customers to if they click the back button on the customer
39
+ * portal.
40
+ */
41
+ return_url: string;
42
+
37
43
  /**
38
44
  * The ID or external ID of the subject to create the customer portal session for.
39
45
  */
@@ -1,23 +1,16 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export {
4
- Checkout,
5
- type AmountOutput,
6
- type CheckoutCallback,
7
- type CheckoutCreateResponse,
8
- type CheckoutCreateParams,
9
- } from './checkout';
10
3
  export { CustomerAccess, type CustomerAccessRetrieveBillingStateResponse } from './customer-access';
11
4
  export {
12
5
  CustomerPortal,
13
6
  type CustomerPortalCreateSessionResponse,
14
7
  type CustomerPortalCreateSessionParams,
15
8
  } from './customer-portal';
16
- export { Invoices, type InvoiceListResponse, type InvoiceListParams } from './invoices';
9
+ export { Invoices, type AmountOutput, type InvoiceListResponse, type InvoiceListParams } from './invoices';
17
10
  export {
18
11
  PricingMetrics,
19
12
  type Period,
20
- type PricingMetric,
13
+ type PricingMetricResource,
21
14
  type PricingMetricListResponse,
22
15
  type PricingMetricCreateSummaryResponse,
23
16
  type PricingMetricCreateParams,
@@ -48,7 +41,9 @@ export {
48
41
  } from './subjects';
49
42
  export {
50
43
  Subscriptions,
44
+ type CheckoutCallback,
51
45
  type SubscriptionResource,
46
+ type SubscriptionCreateResponse,
52
47
  type SubscriptionListResponse,
53
48
  type SubscriptionChangeRateCardResponse,
54
49
  type SubscriptionCreateParams,
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
- import * as CheckoutAPI from './checkout';
4
+ import * as InvoicesAPI from './invoices';
5
5
  import { APIPromise } from '../core/api-promise';
6
6
  import { RequestOptions } from '../internal/request-options';
7
7
 
@@ -14,6 +14,18 @@ export class Invoices extends APIResource {
14
14
  }
15
15
  }
16
16
 
17
+ export interface AmountOutput {
18
+ /**
19
+ * The currency code of the amount.
20
+ */
21
+ currency_code: string;
22
+
23
+ /**
24
+ * The value of the amount in the smallest unit of the currency.
25
+ */
26
+ value: string;
27
+ }
28
+
17
29
  export interface InvoiceListResponse {
18
30
  has_more: boolean;
19
31
 
@@ -55,16 +67,16 @@ export namespace InvoiceListResponse {
55
67
  /**
56
68
  * The total amount of the invoice.
57
69
  */
58
- total_amount: CheckoutAPI.AmountOutput;
70
+ total_amount: InvoicesAPI.AmountOutput;
59
71
  }
60
72
 
61
73
  export namespace Invoice {
62
74
  export interface LineItem {
63
- amount: CheckoutAPI.AmountOutput;
75
+ amount: InvoicesAPI.AmountOutput;
64
76
 
65
77
  description: string;
66
78
 
67
- price_in_unit_amount: CheckoutAPI.AmountOutput;
79
+ price_in_unit_amount: InvoicesAPI.AmountOutput;
68
80
 
69
81
  quantity: number;
70
82
  }
@@ -83,5 +95,9 @@ export interface InvoiceListParams {
83
95
  }
84
96
 
85
97
  export declare namespace Invoices {
86
- export { type InvoiceListResponse as InvoiceListResponse, type InvoiceListParams as InvoiceListParams };
98
+ export {
99
+ type AmountOutput as AmountOutput,
100
+ type InvoiceListResponse as InvoiceListResponse,
101
+ type InvoiceListParams as InvoiceListParams,
102
+ };
87
103
  }
@@ -11,18 +11,19 @@ export class PricingMetrics extends APIResource {
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
- * const pricingMetric = await client.pricingMetrics.create({
15
- * aggregation: {
16
- * aggregation_type: 'sum',
17
- * value_field: 'compute_hours',
18
- * },
19
- * event_name: 'job_completed',
20
- * name: 'Compute Hours',
21
- * unit: 'hours',
22
- * });
14
+ * const pricingMetricResource =
15
+ * await client.pricingMetrics.create({
16
+ * aggregation: {
17
+ * aggregation_type: 'sum',
18
+ * value_field: 'compute_hours',
19
+ * },
20
+ * event_name: 'job_completed',
21
+ * name: 'Compute Hours',
22
+ * unit: 'hours',
23
+ * });
23
24
  * ```
24
25
  */
25
- create(body: PricingMetricCreateParams, options?: RequestOptions): APIPromise<PricingMetric> {
26
+ create(body: PricingMetricCreateParams, options?: RequestOptions): APIPromise<PricingMetricResource> {
26
27
  return this._client.post('/pricing-metrics', { body, ...options });
27
28
  }
28
29
 
@@ -31,12 +32,11 @@ export class PricingMetrics extends APIResource {
31
32
  *
32
33
  * @example
33
34
  * ```ts
34
- * const pricingMetric = await client.pricingMetrics.retrieve(
35
- * 'pricing_metric_id',
36
- * );
35
+ * const pricingMetricResource =
36
+ * await client.pricingMetrics.retrieve('pricing_metric_id');
37
37
  * ```
38
38
  */
39
- retrieve(pricingMetricID: string, options?: RequestOptions): APIPromise<PricingMetric> {
39
+ retrieve(pricingMetricID: string, options?: RequestOptions): APIPromise<PricingMetricResource> {
40
40
  return this._client.get(path`/pricing-metrics/${pricingMetricID}`, options);
41
41
  }
42
42
 
@@ -91,7 +91,7 @@ export interface Period {
91
91
  inclusive_start?: boolean;
92
92
  }
93
93
 
94
- export interface PricingMetric {
94
+ export interface PricingMetricResource {
95
95
  /**
96
96
  * The ID of the pricing metric.
97
97
  */
@@ -101,10 +101,10 @@ export interface PricingMetric {
101
101
  * The aggregation function used to compute the value of the pricing metric.
102
102
  */
103
103
  aggregation:
104
- | PricingMetric.SumAggregationPricingMetricResource
105
- | PricingMetric.CountAggregationPricingMetricResource
106
- | PricingMetric.MaxAggregationPricingMetricResource
107
- | PricingMetric.LastAggregationPricingMetricResource;
104
+ | PricingMetricResource.SumAggregationPricingMetricResource
105
+ | PricingMetricResource.CountAggregationPricingMetricResource
106
+ | PricingMetricResource.MaxAggregationPricingMetricResource
107
+ | PricingMetricResource.LastAggregationPricingMetricResource;
108
108
 
109
109
  /**
110
110
  * The event name that the pricing metric is computed on.
@@ -122,7 +122,7 @@ export interface PricingMetric {
122
122
  unit: string;
123
123
  }
124
124
 
125
- export namespace PricingMetric {
125
+ export namespace PricingMetricResource {
126
126
  export interface SumAggregationPricingMetricResource {
127
127
  aggregation_type: 'sum';
128
128
 
@@ -158,7 +158,7 @@ export namespace PricingMetric {
158
158
  export interface PricingMetricListResponse {
159
159
  has_more: boolean;
160
160
 
161
- pricing_metrics: Array<PricingMetric>;
161
+ pricing_metrics: Array<PricingMetricResource>;
162
162
  }
163
163
 
164
164
  export interface PricingMetricCreateSummaryResponse {
@@ -297,7 +297,7 @@ export interface PricingMetricCreateSummaryParams {
297
297
  export declare namespace PricingMetrics {
298
298
  export {
299
299
  type Period as Period,
300
- type PricingMetric as PricingMetric,
300
+ type PricingMetricResource as PricingMetricResource,
301
301
  type PricingMetricListResponse as PricingMetricListResponse,
302
302
  type PricingMetricCreateSummaryResponse as PricingMetricCreateSummaryResponse,
303
303
  type PricingMetricCreateParams as PricingMetricCreateParams,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as RateCardsAPI from './rate-cards';
5
- import * as CheckoutAPI from './checkout';
5
+ import * as InvoicesAPI from './invoices';
6
6
  import { APIPromise } from '../core/api-promise';
7
7
  import { RequestOptions } from '../internal/request-options';
8
8
  import { path } from '../internal/utils/path';
@@ -10,14 +10,6 @@ import { path } from '../internal/utils/path';
10
10
  export class RateCards extends APIResource {
11
11
  /**
12
12
  * Create Rate Card
13
- *
14
- * @example
15
- * ```ts
16
- * const rateCardResource = await client.rateCards.create({
17
- * billing_interval: 'monthly',
18
- * name: 'Pro Plan',
19
- * });
20
- * ```
21
13
  */
22
14
  create(body: RateCardCreateParams, options?: RequestOptions): APIPromise<RateCardResource> {
23
15
  return this._client.post('/rate-cards', { body, ...options });
@@ -25,13 +17,6 @@ export class RateCards extends APIResource {
25
17
 
26
18
  /**
27
19
  * Get Rate Card
28
- *
29
- * @example
30
- * ```ts
31
- * const rateCardResource = await client.rateCards.retrieve(
32
- * 'rate_card_id',
33
- * );
34
- * ```
35
20
  */
36
21
  retrieve(rateCardID: string, options?: RequestOptions): APIPromise<RateCardResource> {
37
22
  return this._client.get(path`/rate-cards/${rateCardID}`, options);
@@ -39,11 +24,6 @@ export class RateCards extends APIResource {
39
24
 
40
25
  /**
41
26
  * List Rate Cards
42
- *
43
- * @example
44
- * ```ts
45
- * const rateCards = await client.rateCards.list();
46
- * ```
47
27
  */
48
28
  list(
49
29
  query: RateCardListParams | null | undefined = {},
@@ -78,7 +58,7 @@ export interface FlatPriceInput {
78
58
  * Flat price is a price that linearly scales with the quantity.
79
59
  */
80
60
  export interface FlatPriceOutput {
81
- amount: CheckoutAPI.AmountOutput;
61
+ amount: InvoicesAPI.AmountOutput;
82
62
 
83
63
  price_type?: 'flat';
84
64
  }
@@ -104,7 +84,7 @@ export interface PackagePriceInput {
104
84
  * units, the rounding behavior will be applied.
105
85
  */
106
86
  export interface PackagePriceOutput {
107
- amount: CheckoutAPI.AmountOutput;
87
+ amount: InvoicesAPI.AmountOutput;
108
88
 
109
89
  package_units: number;
110
90
 
@@ -275,6 +255,8 @@ export namespace RateCardCreateParams {
275
255
 
276
256
  export interface RateCardListParams {
277
257
  limit?: number;
258
+
259
+ offset?: number;
278
260
  }
279
261
 
280
262
  export declare namespace RateCards {
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as SubscriptionsAPI from './subscriptions';
5
- import * as CheckoutAPI from './checkout';
6
5
  import { APIPromise } from '../core/api-promise';
7
6
  import { RequestOptions } from '../internal/request-options';
8
7
  import { path } from '../internal/utils/path';
@@ -13,14 +12,17 @@ export class Subscriptions extends APIResource {
13
12
  *
14
13
  * @example
15
14
  * ```ts
16
- * const subscriptionResource =
17
- * await client.subscriptions.create({
18
- * rate_card_id: 'rc_AJWMxR81jxoRlli6p13uf3JB',
19
- * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
20
- * });
15
+ * const subscription = await client.subscriptions.create({
16
+ * checkout_callback_urls: {
17
+ * cancelled_url: 'https://example.com/callback',
18
+ * success_url: 'https://example.com/callback',
19
+ * },
20
+ * rate_card_id: 'rc_AJWMxR81jxoRlli6p13uf3JB',
21
+ * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
22
+ * });
21
23
  * ```
22
24
  */
23
- create(body: SubscriptionCreateParams, options?: RequestOptions): APIPromise<SubscriptionResource> {
25
+ create(body: SubscriptionCreateParams, options?: RequestOptions): APIPromise<SubscriptionCreateResponse> {
24
26
  return this._client.post('/subscriptions', { body, ...options });
25
27
  }
26
28
 
@@ -95,6 +97,18 @@ export class Subscriptions extends APIResource {
95
97
  }
96
98
  }
97
99
 
100
+ export interface CheckoutCallback {
101
+ /**
102
+ * The URL to redirect to after the checkout is cancelled.
103
+ */
104
+ cancelled_url: string;
105
+
106
+ /**
107
+ * The URL to redirect to after the checkout is successful.
108
+ */
109
+ success_url: string;
110
+ }
111
+
98
112
  export interface SubscriptionResource {
99
113
  /**
100
114
  * The ID of the subscription.
@@ -154,6 +168,51 @@ export namespace SubscriptionResource {
154
168
  }
155
169
  }
156
170
 
171
+ export interface SubscriptionCreateResponse {
172
+ /**
173
+ * The result of the request. If the request is successful, the subscription
174
+ * resource will be returned. If the request is requires action, the action to take
175
+ * to complete the request will be returned.
176
+ */
177
+ result:
178
+ | SubscriptionCreateResponse.CreateSubscriptionRequiresActionResponse
179
+ | SubscriptionCreateResponse.CreateSubscriptionSuccessResponse;
180
+ }
181
+
182
+ export namespace SubscriptionCreateResponse {
183
+ export interface CreateSubscriptionRequiresActionResponse {
184
+ /**
185
+ * The action to take to complete the request.
186
+ */
187
+ action: CreateSubscriptionRequiresActionResponse.Action;
188
+
189
+ result_type: 'requires_action';
190
+ }
191
+
192
+ export namespace CreateSubscriptionRequiresActionResponse {
193
+ /**
194
+ * The action to take to complete the request.
195
+ */
196
+ export interface Action {
197
+ /**
198
+ * The URL of the checkout page to redirect to in order to complete the request.
199
+ */
200
+ checkout_url: string;
201
+
202
+ requires_action_type: 'checkout';
203
+ }
204
+ }
205
+
206
+ export interface CreateSubscriptionSuccessResponse {
207
+ result_type: 'success';
208
+
209
+ /**
210
+ * The created subscription resource.
211
+ */
212
+ subscription: SubscriptionsAPI.SubscriptionResource;
213
+ }
214
+ }
215
+
157
216
  export interface SubscriptionListResponse {
158
217
  has_more: boolean;
159
218
 
@@ -161,27 +220,44 @@ export interface SubscriptionListResponse {
161
220
  }
162
221
 
163
222
  export interface SubscriptionChangeRateCardResponse {
223
+ /**
224
+ * The result of the request. If the request is successful, the subscription
225
+ * resource will be returned. If the request is requires action, the action to take
226
+ * to complete the request will be returned.
227
+ */
164
228
  result:
165
- | SubscriptionChangeRateCardResponse.RequiresActionResponse
166
- | SubscriptionChangeRateCardResponse.SuccessResponse;
229
+ | SubscriptionChangeRateCardResponse.ChangeSubscriptionRateCardRequiresActionResponse
230
+ | SubscriptionChangeRateCardResponse.ChangeSubscriptionRateCardSuccessResponse;
167
231
  }
168
232
 
169
233
  export namespace SubscriptionChangeRateCardResponse {
170
- export interface RequiresActionResponse {
171
- action: RequiresActionResponse.Action;
234
+ export interface ChangeSubscriptionRateCardRequiresActionResponse {
235
+ /**
236
+ * The action to take to complete the request.
237
+ */
238
+ action: ChangeSubscriptionRateCardRequiresActionResponse.Action;
172
239
 
173
240
  type: 'requires_action';
174
241
  }
175
242
 
176
- export namespace RequiresActionResponse {
243
+ export namespace ChangeSubscriptionRateCardRequiresActionResponse {
244
+ /**
245
+ * The action to take to complete the request.
246
+ */
177
247
  export interface Action {
248
+ /**
249
+ * The URL of the checkout page to redirect to in order to complete the request.
250
+ */
178
251
  checkout_url: string;
179
252
 
180
253
  type: 'checkout';
181
254
  }
182
255
  }
183
256
 
184
- export interface SuccessResponse {
257
+ export interface ChangeSubscriptionRateCardSuccessResponse {
258
+ /**
259
+ * The updated subscription resource.
260
+ */
185
261
  subscription: SubscriptionsAPI.SubscriptionResource;
186
262
 
187
263
  type: 'success';
@@ -189,6 +265,12 @@ export namespace SubscriptionChangeRateCardResponse {
189
265
  }
190
266
 
191
267
  export interface SubscriptionCreateParams {
268
+ /**
269
+ * The URLs to redirect to after the checkout is completed or cancelled, if a
270
+ * checkout is required.
271
+ */
272
+ checkout_callback_urls: CheckoutCallback;
273
+
192
274
  /**
193
275
  * The ID of the rate card to use for the subscription.
194
276
  */
@@ -199,6 +281,14 @@ export interface SubscriptionCreateParams {
199
281
  */
200
282
  subject_id: string;
201
283
 
284
+ /**
285
+ * Determines whether a checkout session is always required even if the subject has
286
+ * a payment method on file. By default, if the subject has a payment method on
287
+ * file or the subscription is for a free plan, the subscription will be created
288
+ * and billed for immediately (if for a paid plan).
289
+ */
290
+ create_checkout_session?: 'when_required' | 'always';
291
+
202
292
  /**
203
293
  * Additional metadata about the subscription. You may use this to store any custom
204
294
  * data about the subscription.
@@ -209,6 +299,8 @@ export interface SubscriptionCreateParams {
209
299
  export interface SubscriptionListParams {
210
300
  limit?: number;
211
301
 
302
+ offset?: number;
303
+
212
304
  /**
213
305
  * The ID of the rate card to list subscriptions for. Cannot be used with
214
306
  * subject_id.
@@ -239,7 +331,7 @@ export interface SubscriptionChangeRateCardParams {
239
331
  * The URLs to redirect to after the checkout is completed or cancelled, if a
240
332
  * checkout is required.
241
333
  */
242
- checkout_callback_urls: CheckoutAPI.CheckoutCallback;
334
+ checkout_callback_urls: CheckoutCallback;
243
335
 
244
336
  /**
245
337
  * The ID of the rate card to change the subscription to.
@@ -256,7 +348,9 @@ export interface SubscriptionChangeRateCardParams {
256
348
 
257
349
  export declare namespace Subscriptions {
258
350
  export {
351
+ type CheckoutCallback as CheckoutCallback,
259
352
  type SubscriptionResource as SubscriptionResource,
353
+ type SubscriptionCreateResponse as SubscriptionCreateResponse,
260
354
  type SubscriptionListResponse as SubscriptionListResponse,
261
355
  type SubscriptionChangeRateCardResponse as SubscriptionChangeRateCardResponse,
262
356
  type SubscriptionCreateParams as SubscriptionCreateParams,
@@ -17,7 +17,7 @@ export class UsageEvents extends APIResource {
17
17
  * region: 'us-east-1',
18
18
  * },
19
19
  * event_name: 'compute_hours',
20
- * idempotency_key: 'cdd158d3-c865-4dc3-a652-053d81906a30',
20
+ * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
21
21
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
22
22
  * });
23
23
  * ```
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.1.5'; // x-release-please-version
1
+ export const VERSION = '0.3.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.5";
1
+ export declare const VERSION = "0.3.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.5";
1
+ export declare const VERSION = "0.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map