lark-billing 0.0.7 → 0.0.9

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 (163) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/Client.d.ts +3 -0
  3. package/dist/cjs/Client.js +7 -2
  4. package/dist/cjs/api/resources/checkout/client/Client.d.ts +3 -3
  5. package/dist/cjs/api/resources/checkout/client/Client.js +3 -3
  6. package/dist/cjs/api/resources/checkout/client/requests/CreateSubscriptionCheckoutSessionRequest.d.ts +9 -4
  7. package/dist/cjs/api/resources/customerPortal/client/Client.d.ts +1 -1
  8. package/dist/cjs/api/resources/customerPortal/client/Client.js +1 -1
  9. package/dist/cjs/api/resources/customerPortal/client/requests/CreateCustomerPortalSessionRequest.d.ts +2 -1
  10. package/dist/cjs/api/resources/index.d.ts +4 -1
  11. package/dist/cjs/api/resources/index.js +5 -2
  12. package/dist/cjs/api/resources/invoices/client/Client.d.ts +50 -0
  13. package/dist/cjs/api/resources/invoices/client/Client.js +135 -0
  14. package/dist/cjs/api/resources/invoices/client/index.d.ts +2 -0
  15. package/dist/cjs/api/resources/invoices/client/index.js +17 -0
  16. package/dist/cjs/api/resources/invoices/client/requests/ListInvoicesInvoicesGetRequest.d.ts +17 -0
  17. package/dist/cjs/api/resources/invoices/client/requests/index.d.ts +1 -0
  18. package/dist/cjs/api/resources/invoices/client/requests/index.js +2 -0
  19. package/dist/cjs/api/resources/invoices/index.d.ts +1 -0
  20. package/dist/cjs/api/resources/invoices/index.js +17 -0
  21. package/dist/cjs/api/resources/pricingMetrics/client/Client.d.ts +13 -0
  22. package/dist/cjs/api/resources/pricingMetrics/client/Client.js +64 -0
  23. package/dist/cjs/api/resources/pricingMetrics/client/requests/ListPricingMetricsPricingMetricsGetRequest.d.ts +12 -0
  24. package/dist/cjs/api/resources/pricingMetrics/client/requests/index.d.ts +1 -0
  25. package/dist/cjs/api/resources/rateCards/client/Client.d.ts +1 -1
  26. package/dist/cjs/api/resources/rateCards/client/Client.js +1 -1
  27. package/dist/cjs/api/resources/rateCards/client/requests/CreateRateCardRequest.d.ts +9 -3
  28. package/dist/cjs/api/resources/rateCards/index.d.ts +1 -0
  29. package/dist/cjs/api/resources/rateCards/index.js +1 -0
  30. package/dist/cjs/api/resources/rateCards/types/CreateRateCardRequestUsageBasedRatesItem.d.ts +10 -0
  31. package/dist/cjs/api/resources/rateCards/types/index.d.ts +1 -0
  32. package/dist/cjs/api/resources/rateCards/types/index.js +17 -0
  33. package/dist/cjs/api/resources/subjects/client/requests/CreateSubjectRequest.d.ts +4 -0
  34. package/dist/cjs/api/resources/subjects/client/requests/UpdateSubjectRequest.d.ts +3 -1
  35. package/dist/cjs/api/resources/subscriptions/client/Client.d.ts +28 -2
  36. package/dist/cjs/api/resources/subscriptions/client/Client.js +126 -2
  37. package/dist/cjs/api/resources/subscriptions/client/requests/CancelSubscriptionRequest.d.ts +13 -0
  38. package/dist/cjs/api/resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.d.ts +13 -0
  39. package/dist/cjs/api/resources/subscriptions/client/requests/CreateSubscriptionRequest.d.ts +6 -3
  40. package/dist/cjs/api/resources/subscriptions/client/requests/index.d.ts +2 -0
  41. package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.ts +11 -1
  42. package/dist/cjs/api/types/Aggregation.d.ts +1 -10
  43. package/dist/cjs/api/types/Amount.d.ts +1 -0
  44. package/dist/cjs/api/types/CreateCustomerPortalSessionResponse.d.ts +2 -0
  45. package/dist/cjs/api/types/CreateFixedRateRequest.d.ts +11 -0
  46. package/dist/cjs/api/types/CreateFixedRateRequest.js +5 -0
  47. package/dist/cjs/api/types/CreateSimpleUsageBasedRateRequest.d.ts +15 -0
  48. package/dist/cjs/api/types/CreateSimpleUsageBasedRateRequest.js +5 -0
  49. package/dist/cjs/api/types/CreateSubjectResponse.d.ts +6 -0
  50. package/dist/cjs/api/types/CreateSubscriptionCheckoutSessionResponse.d.ts +3 -0
  51. package/dist/cjs/api/types/FixedRateInterface.d.ts +1 -1
  52. package/dist/cjs/api/types/InvoiceLineItemResource.d.ts +10 -0
  53. package/dist/cjs/api/types/InvoiceLineItemResource.js +5 -0
  54. package/dist/cjs/api/types/InvoiceResource.d.ts +33 -0
  55. package/dist/cjs/api/types/InvoiceResource.js +16 -0
  56. package/dist/cjs/api/types/{CreateFixedRateInterface.d.ts → ListInvoicesResponse.d.ts} +3 -4
  57. package/dist/cjs/api/types/ListInvoicesResponse.js +5 -0
  58. package/dist/cjs/api/types/ListPricingMetricsResponse.d.ts +8 -0
  59. package/dist/cjs/api/types/ListPricingMetricsResponse.js +5 -0
  60. package/dist/cjs/api/types/PeriodResource.d.ts +9 -0
  61. package/dist/cjs/api/types/PeriodResource.js +5 -0
  62. package/dist/cjs/api/types/PricingMetricResource.d.ts +11 -0
  63. package/dist/cjs/api/types/PricingMetricResource.js +5 -0
  64. package/dist/cjs/api/types/RateCardResource.d.ts +8 -1
  65. package/dist/cjs/api/types/SimpleUsageBasedRateInterface.d.ts +1 -3
  66. package/dist/cjs/api/types/SubjectResource.d.ts +6 -0
  67. package/dist/cjs/api/types/SubscriptionResource.d.ts +17 -2
  68. package/dist/cjs/api/types/SubscriptionResource.js +1 -0
  69. package/dist/cjs/api/types/index.d.ts +8 -5
  70. package/dist/cjs/api/types/index.js +8 -5
  71. package/dist/cjs/version.d.ts +1 -1
  72. package/dist/cjs/version.js +1 -1
  73. package/dist/esm/Client.d.mts +3 -0
  74. package/dist/esm/Client.mjs +7 -2
  75. package/dist/esm/api/resources/checkout/client/Client.d.mts +3 -3
  76. package/dist/esm/api/resources/checkout/client/Client.mjs +3 -3
  77. package/dist/esm/api/resources/checkout/client/requests/CreateSubscriptionCheckoutSessionRequest.d.mts +9 -4
  78. package/dist/esm/api/resources/customerPortal/client/Client.d.mts +1 -1
  79. package/dist/esm/api/resources/customerPortal/client/Client.mjs +1 -1
  80. package/dist/esm/api/resources/customerPortal/client/requests/CreateCustomerPortalSessionRequest.d.mts +2 -1
  81. package/dist/esm/api/resources/index.d.mts +4 -1
  82. package/dist/esm/api/resources/index.mjs +4 -1
  83. package/dist/esm/api/resources/invoices/client/Client.d.mts +50 -0
  84. package/dist/esm/api/resources/invoices/client/Client.mjs +98 -0
  85. package/dist/esm/api/resources/invoices/client/index.d.mts +2 -0
  86. package/dist/esm/api/resources/invoices/client/index.mjs +1 -0
  87. package/dist/esm/api/resources/invoices/client/requests/ListInvoicesInvoicesGetRequest.d.mts +17 -0
  88. package/dist/esm/api/resources/invoices/client/requests/index.d.mts +1 -0
  89. package/dist/esm/api/resources/invoices/client/requests/index.mjs +1 -0
  90. package/dist/esm/api/resources/invoices/index.d.mts +1 -0
  91. package/dist/esm/api/resources/invoices/index.mjs +1 -0
  92. package/dist/esm/api/resources/pricingMetrics/client/Client.d.mts +13 -0
  93. package/dist/esm/api/resources/pricingMetrics/client/Client.mjs +64 -0
  94. package/dist/esm/api/resources/pricingMetrics/client/requests/ListPricingMetricsPricingMetricsGetRequest.d.mts +12 -0
  95. package/dist/esm/api/resources/pricingMetrics/client/requests/index.d.mts +1 -0
  96. package/dist/esm/api/resources/rateCards/client/Client.d.mts +1 -1
  97. package/dist/esm/api/resources/rateCards/client/Client.mjs +1 -1
  98. package/dist/esm/api/resources/rateCards/client/requests/CreateRateCardRequest.d.mts +9 -3
  99. package/dist/esm/api/resources/rateCards/index.d.mts +1 -0
  100. package/dist/esm/api/resources/rateCards/index.mjs +1 -0
  101. package/dist/esm/api/resources/rateCards/types/CreateRateCardRequestUsageBasedRatesItem.d.mts +10 -0
  102. package/dist/esm/api/resources/rateCards/types/index.d.mts +1 -0
  103. package/dist/esm/api/resources/rateCards/types/index.mjs +1 -0
  104. package/dist/esm/api/resources/subjects/client/requests/CreateSubjectRequest.d.mts +4 -0
  105. package/dist/esm/api/resources/subjects/client/requests/UpdateSubjectRequest.d.mts +3 -1
  106. package/dist/esm/api/resources/subscriptions/client/Client.d.mts +28 -2
  107. package/dist/esm/api/resources/subscriptions/client/Client.mjs +126 -2
  108. package/dist/esm/api/resources/subscriptions/client/requests/CancelSubscriptionRequest.d.mts +13 -0
  109. package/dist/esm/api/resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.d.mts +13 -0
  110. package/dist/esm/api/resources/subscriptions/client/requests/CreateSubscriptionRequest.d.mts +6 -3
  111. package/dist/esm/api/resources/subscriptions/client/requests/index.d.mts +2 -0
  112. package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.mts +11 -1
  113. package/dist/esm/api/types/Aggregation.d.mts +1 -10
  114. package/dist/esm/api/types/Amount.d.mts +1 -0
  115. package/dist/esm/api/types/CreateCustomerPortalSessionResponse.d.mts +2 -0
  116. package/dist/esm/api/types/CreateFixedRateRequest.d.mts +11 -0
  117. package/dist/esm/api/types/CreateFixedRateRequest.mjs +4 -0
  118. package/dist/esm/api/types/CreateSimpleUsageBasedRateRequest.d.mts +15 -0
  119. package/dist/esm/api/types/CreateSimpleUsageBasedRateRequest.mjs +4 -0
  120. package/dist/esm/api/types/CreateSubjectResponse.d.mts +6 -0
  121. package/dist/esm/api/types/CreateSubscriptionCheckoutSessionResponse.d.mts +3 -0
  122. package/dist/esm/api/types/FixedRateInterface.d.mts +1 -1
  123. package/dist/esm/api/types/InvoiceLineItemResource.d.mts +10 -0
  124. package/dist/esm/api/types/InvoiceLineItemResource.mjs +4 -0
  125. package/dist/esm/api/types/InvoiceResource.d.mts +33 -0
  126. package/dist/esm/api/types/InvoiceResource.mjs +13 -0
  127. package/dist/esm/api/types/{CreateFixedRateInterface.d.mts → ListInvoicesResponse.d.mts} +3 -4
  128. package/dist/esm/api/types/ListInvoicesResponse.mjs +4 -0
  129. package/dist/esm/api/types/ListPricingMetricsResponse.d.mts +8 -0
  130. package/dist/esm/api/types/ListPricingMetricsResponse.mjs +4 -0
  131. package/dist/esm/api/types/PeriodResource.d.mts +9 -0
  132. package/dist/esm/api/types/PeriodResource.mjs +4 -0
  133. package/dist/esm/api/types/PricingMetricResource.d.mts +11 -0
  134. package/dist/esm/api/types/PricingMetricResource.mjs +4 -0
  135. package/dist/esm/api/types/RateCardResource.d.mts +8 -1
  136. package/dist/esm/api/types/SimpleUsageBasedRateInterface.d.mts +1 -3
  137. package/dist/esm/api/types/SubjectResource.d.mts +6 -0
  138. package/dist/esm/api/types/SubscriptionResource.d.mts +17 -2
  139. package/dist/esm/api/types/SubscriptionResource.mjs +1 -0
  140. package/dist/esm/api/types/index.d.mts +8 -5
  141. package/dist/esm/api/types/index.mjs +8 -5
  142. package/dist/esm/version.d.mts +1 -1
  143. package/dist/esm/version.mjs +1 -1
  144. package/package.json +1 -1
  145. package/reference.md +225 -7
  146. package/dist/cjs/api/types/CreateSimpleUsageBasedRateInterface.d.ts +0 -12
  147. package/dist/cjs/api/types/CustomPricingMetricResource.d.ts +0 -6
  148. package/dist/cjs/api/types/LastAggregationPricingMetricResource.d.ts +0 -6
  149. package/dist/cjs/api/types/MaxAggregationPricingMetricResource.d.ts +0 -6
  150. package/dist/esm/api/types/CreateSimpleUsageBasedRateInterface.d.mts +0 -12
  151. package/dist/esm/api/types/CustomPricingMetricResource.d.mts +0 -6
  152. package/dist/esm/api/types/LastAggregationPricingMetricResource.d.mts +0 -6
  153. package/dist/esm/api/types/MaxAggregationPricingMetricResource.d.mts +0 -6
  154. /package/dist/cjs/api/{types/CreateFixedRateInterface.js → resources/invoices/client/requests/ListInvoicesInvoicesGetRequest.js} +0 -0
  155. /package/dist/cjs/api/{types/CreateSimpleUsageBasedRateInterface.js → resources/pricingMetrics/client/requests/ListPricingMetricsPricingMetricsGetRequest.js} +0 -0
  156. /package/dist/cjs/api/{types/CustomPricingMetricResource.js → resources/rateCards/types/CreateRateCardRequestUsageBasedRatesItem.js} +0 -0
  157. /package/dist/cjs/api/{types/LastAggregationPricingMetricResource.js → resources/subscriptions/client/requests/CancelSubscriptionRequest.js} +0 -0
  158. /package/dist/cjs/api/{types/MaxAggregationPricingMetricResource.js → resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.js} +0 -0
  159. /package/dist/esm/api/{types/CreateFixedRateInterface.mjs → resources/invoices/client/requests/ListInvoicesInvoicesGetRequest.mjs} +0 -0
  160. /package/dist/esm/api/{types/CreateSimpleUsageBasedRateInterface.mjs → resources/pricingMetrics/client/requests/ListPricingMetricsPricingMetricsGetRequest.mjs} +0 -0
  161. /package/dist/esm/api/{types/CustomPricingMetricResource.mjs → resources/rateCards/types/CreateRateCardRequestUsageBasedRatesItem.mjs} +0 -0
  162. /package/dist/esm/api/{types/LastAggregationPricingMetricResource.mjs → resources/subscriptions/client/requests/CancelSubscriptionRequest.mjs} +0 -0
  163. /package/dist/esm/api/{types/MaxAggregationPricingMetricResource.mjs → resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.mjs} +0 -0
@@ -5,19 +5,25 @@ import * as Lark from "../../../../index.mjs";
5
5
  /**
6
6
  * @example
7
7
  * {
8
- * name: "name",
8
+ * name: "Pro Plan",
9
9
  * billing_interval: "monthly"
10
10
  * }
11
11
  */
12
12
  export interface CreateRateCardRequest {
13
+ /** The name of the rate card displayed to the customer. */
13
14
  name: string;
15
+ /** The description of the rate card displayed to the customer. */
14
16
  description?: string;
15
- usage_based_rates?: Lark.CreateSimpleUsageBasedRateInterface[];
16
- fixed_rates?: Lark.CreateFixedRateInterface[];
17
+ /** How often the customer will be billed for this rate card. */
17
18
  billing_interval: CreateRateCardRequest.BillingInterval;
19
+ fixed_rates?: Lark.CreateFixedRateRequest[];
20
+ usage_based_rates?: Lark.CreateRateCardRequestUsageBasedRatesItem[];
18
21
  metadata?: Record<string, string>;
19
22
  }
20
23
  export declare namespace CreateRateCardRequest {
24
+ /**
25
+ * How often the customer will be billed for this rate card.
26
+ */
21
27
  type BillingInterval = "monthly" | "yearly";
22
28
  const BillingInterval: {
23
29
  readonly Monthly: "monthly";
@@ -1 +1,2 @@
1
+ export * from "./types/index.mjs";
1
2
  export * from "./client/index.mjs";
@@ -1 +1,2 @@
1
+ export * from "./types/index.mjs";
1
2
  export * from "./client/index.mjs";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../../../index.mjs";
5
+ export type CreateRateCardRequestUsageBasedRatesItem = Lark.CreateRateCardRequestUsageBasedRatesItem.Simple;
6
+ export declare namespace CreateRateCardRequestUsageBasedRatesItem {
7
+ interface Simple extends Lark.CreateSimpleUsageBasedRateRequest {
8
+ usage_based_rate_type: "simple";
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ export * from "./CreateRateCardRequestUsageBasedRatesItem.mjs";
@@ -0,0 +1 @@
1
+ export * from "./CreateRateCardRequestUsageBasedRatesItem.mjs";
@@ -6,8 +6,12 @@
6
6
  * {}
7
7
  */
8
8
  export interface CreateSubjectRequest {
9
+ /** The ID of the subject in your system. If provided, you may use pass it to the API in place of the subject ID. Must be unique. */
9
10
  external_id?: string;
11
+ /** The name of the subject. Used for display in the dashboard. */
10
12
  name?: string;
13
+ /** The email of the subject. Must be a valid email address. */
11
14
  email?: string;
15
+ /** Additional metadata about the subject. You may use this to store any custom data about the subject. */
12
16
  metadata?: Record<string, string>;
13
17
  }
@@ -6,8 +6,10 @@
6
6
  * {}
7
7
  */
8
8
  export interface UpdateSubjectRequest {
9
- external_id?: string;
9
+ /** The name of the subject. Used for display in the dashboard. */
10
10
  name?: string;
11
+ /** The email of the subject. Must be a valid email address. */
11
12
  email?: string;
13
+ /** Additional metadata about the subject. You may use this to store any custom data about the subject. */
12
14
  metadata?: Record<string, string | undefined>;
13
15
  }
@@ -52,8 +52,8 @@ export declare class Subscriptions {
52
52
  *
53
53
  * @example
54
54
  * await client.subscriptions.createSubscription({
55
- * rate_card_id: "rate_card_id",
56
- * subject_id: "subject_id"
55
+ * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB",
56
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE"
57
57
  * })
58
58
  */
59
59
  createSubscription(request: Lark.CreateSubscriptionRequest, requestOptions?: Subscriptions.RequestOptions): core.HttpResponsePromise<Lark.SubscriptionResource>;
@@ -69,6 +69,32 @@ export declare class Subscriptions {
69
69
  */
70
70
  getSubscription(subscriptionId: string, requestOptions?: Subscriptions.RequestOptions): core.HttpResponsePromise<Lark.SubscriptionResource>;
71
71
  private __getSubscription;
72
+ /**
73
+ * @param {string} subscriptionId
74
+ * @param {Lark.CancelSubscriptionRequest} request
75
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link Lark.UnprocessableEntityError}
78
+ *
79
+ * @example
80
+ * await client.subscriptions.cancelSubscription("subscription_id")
81
+ */
82
+ cancelSubscription(subscriptionId: string, request?: Lark.CancelSubscriptionRequest, requestOptions?: Subscriptions.RequestOptions): core.HttpResponsePromise<Lark.SubscriptionResource>;
83
+ private __cancelSubscription;
84
+ /**
85
+ * @param {string} subscriptionId
86
+ * @param {Lark.ChangeSubscriptionRateCardRequest} request
87
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
88
+ *
89
+ * @throws {@link Lark.UnprocessableEntityError}
90
+ *
91
+ * @example
92
+ * await client.subscriptions.changeSubscriptionRateCard("subscription_id", {
93
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
94
+ * })
95
+ */
96
+ changeSubscriptionRateCard(subscriptionId: string, request: Lark.ChangeSubscriptionRateCardRequest, requestOptions?: Subscriptions.RequestOptions): core.HttpResponsePromise<Lark.SubscriptionResource>;
97
+ private __changeSubscriptionRateCard;
72
98
  protected _getCustomAuthorizationHeaders(): Promise<{
73
99
  "X-API-Key": string;
74
100
  }>;
@@ -99,8 +99,8 @@ export class Subscriptions {
99
99
  *
100
100
  * @example
101
101
  * await client.subscriptions.createSubscription({
102
- * rate_card_id: "rate_card_id",
103
- * subject_id: "subject_id"
102
+ * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB",
103
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE"
104
104
  * })
105
105
  */
106
106
  createSubscription(request, requestOptions) {
@@ -211,6 +211,130 @@ export class Subscriptions {
211
211
  }
212
212
  });
213
213
  }
214
+ /**
215
+ * @param {string} subscriptionId
216
+ * @param {Lark.CancelSubscriptionRequest} request
217
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
218
+ *
219
+ * @throws {@link Lark.UnprocessableEntityError}
220
+ *
221
+ * @example
222
+ * await client.subscriptions.cancelSubscription("subscription_id")
223
+ */
224
+ cancelSubscription(subscriptionId, request = {}, requestOptions) {
225
+ return core.HttpResponsePromise.fromPromise(this.__cancelSubscription(subscriptionId, request, requestOptions));
226
+ }
227
+ __cancelSubscription(subscriptionId_1) {
228
+ return __awaiter(this, arguments, void 0, function* (subscriptionId, request = {}, requestOptions) {
229
+ var _a, _b, _c;
230
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
231
+ const _response = yield core.fetcher({
232
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LarkEnvironment.Default, `subscriptions/${encodeURIComponent(subscriptionId)}/cancel`),
233
+ method: "POST",
234
+ headers: _headers,
235
+ contentType: "application/json",
236
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
237
+ requestType: "json",
238
+ body: request,
239
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
240
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
241
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
242
+ });
243
+ if (_response.ok) {
244
+ return { data: _response.body, rawResponse: _response.rawResponse };
245
+ }
246
+ if (_response.error.reason === "status-code") {
247
+ switch (_response.error.statusCode) {
248
+ case 422:
249
+ throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
250
+ default:
251
+ throw new errors.LarkError({
252
+ statusCode: _response.error.statusCode,
253
+ body: _response.error.body,
254
+ rawResponse: _response.rawResponse,
255
+ });
256
+ }
257
+ }
258
+ switch (_response.error.reason) {
259
+ case "non-json":
260
+ throw new errors.LarkError({
261
+ statusCode: _response.error.statusCode,
262
+ body: _response.error.rawBody,
263
+ rawResponse: _response.rawResponse,
264
+ });
265
+ case "timeout":
266
+ throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /subscriptions/{subscription_id}/cancel.");
267
+ case "unknown":
268
+ throw new errors.LarkError({
269
+ message: _response.error.errorMessage,
270
+ rawResponse: _response.rawResponse,
271
+ });
272
+ }
273
+ });
274
+ }
275
+ /**
276
+ * @param {string} subscriptionId
277
+ * @param {Lark.ChangeSubscriptionRateCardRequest} request
278
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
279
+ *
280
+ * @throws {@link Lark.UnprocessableEntityError}
281
+ *
282
+ * @example
283
+ * await client.subscriptions.changeSubscriptionRateCard("subscription_id", {
284
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
285
+ * })
286
+ */
287
+ changeSubscriptionRateCard(subscriptionId, request, requestOptions) {
288
+ return core.HttpResponsePromise.fromPromise(this.__changeSubscriptionRateCard(subscriptionId, request, requestOptions));
289
+ }
290
+ __changeSubscriptionRateCard(subscriptionId, request, requestOptions) {
291
+ return __awaiter(this, void 0, void 0, function* () {
292
+ var _a, _b, _c;
293
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
294
+ const _response = yield core.fetcher({
295
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LarkEnvironment.Default, `subscriptions/${encodeURIComponent(subscriptionId)}/change-rate-card`),
296
+ method: "POST",
297
+ headers: _headers,
298
+ contentType: "application/json",
299
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
300
+ requestType: "json",
301
+ body: request,
302
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
303
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
304
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
305
+ });
306
+ if (_response.ok) {
307
+ return { data: _response.body, rawResponse: _response.rawResponse };
308
+ }
309
+ if (_response.error.reason === "status-code") {
310
+ switch (_response.error.statusCode) {
311
+ case 422:
312
+ throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
313
+ default:
314
+ throw new errors.LarkError({
315
+ statusCode: _response.error.statusCode,
316
+ body: _response.error.body,
317
+ rawResponse: _response.rawResponse,
318
+ });
319
+ }
320
+ }
321
+ switch (_response.error.reason) {
322
+ case "non-json":
323
+ throw new errors.LarkError({
324
+ statusCode: _response.error.statusCode,
325
+ body: _response.error.rawBody,
326
+ rawResponse: _response.rawResponse,
327
+ });
328
+ case "timeout":
329
+ throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /subscriptions/{subscription_id}/change-rate-card.");
330
+ case "unknown":
331
+ throw new errors.LarkError({
332
+ message: _response.error.errorMessage,
333
+ rawResponse: _response.rawResponse,
334
+ });
335
+ }
336
+ });
337
+ }
214
338
  _getCustomAuthorizationHeaders() {
215
339
  return __awaiter(this, void 0, void 0, function* () {
216
340
  const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {}
7
+ */
8
+ export interface CancelSubscriptionRequest {
9
+ /** The reason for cancelling the subscription. */
10
+ reason?: string;
11
+ /** Whether to cancel the subscription at end of cycle. */
12
+ cancel_at_end_of_cycle?: boolean;
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
8
+ * }
9
+ */
10
+ export interface ChangeSubscriptionRateCardRequest {
11
+ /** The ID of the rate card to change the subscription to. */
12
+ rate_card_id: string;
13
+ }
@@ -4,12 +4,15 @@
4
4
  /**
5
5
  * @example
6
6
  * {
7
- * rate_card_id: "rate_card_id",
8
- * subject_id: "subject_id"
7
+ * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB",
8
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE"
9
9
  * }
10
10
  */
11
11
  export interface CreateSubscriptionRequest {
12
+ /** The ID of the rate card to use for the subscription. */
12
13
  rate_card_id: string;
14
+ /** The ID of the subject to create the subscription for. */
13
15
  subject_id: string;
14
- metadata?: Record<string, string | undefined>;
16
+ /** Additional metadata about the subscription. You may use this to store any custom data about the subscription. */
17
+ metadata?: Record<string, string>;
15
18
  }
@@ -1,2 +1,4 @@
1
1
  export { type ListSubscriptionsSubscriptionsGetRequest } from "./ListSubscriptionsSubscriptionsGetRequest.mjs";
2
2
  export { type CreateSubscriptionRequest } from "./CreateSubscriptionRequest.mjs";
3
+ export { type CancelSubscriptionRequest } from "./CancelSubscriptionRequest.mjs";
4
+ export { type ChangeSubscriptionRateCardRequest } from "./ChangeSubscriptionRateCardRequest.mjs";
@@ -13,9 +13,19 @@
13
13
  * }
14
14
  */
15
15
  export interface CreateUsageEventRequest {
16
+ /** The idempotency key for the usage event. This ensures that the same event is not processed multiple times. */
16
17
  idempotency_key: string;
18
+ /** The name of the event. This is used by pricing metrics to aggregate usage events. */
17
19
  event_name: string;
20
+ /** The ID of the subject that the usage event is for. */
18
21
  subject_id: string;
22
+ /** The timestamp of the usage event. It is highly recommended to provide a timestamp. If not provided, the current timestamp will be used. */
19
23
  timestamp?: string;
20
- data: Record<string, unknown>;
24
+ /** The data of the usage event. This should contain any data that is needed to aggregate the usage event. */
25
+ data: Record<string, CreateUsageEventRequest.Data.Value>;
26
+ }
27
+ export declare namespace CreateUsageEventRequest {
28
+ namespace Data {
29
+ type Value = string | number | number | boolean;
30
+ }
21
31
  }
@@ -2,20 +2,11 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Lark from "../index.mjs";
5
- export type Aggregation = Lark.Aggregation.Count | Lark.Aggregation.Custom | Lark.Aggregation.Last | Lark.Aggregation.Max | Lark.Aggregation.Sum;
5
+ export type Aggregation = Lark.Aggregation.Count | Lark.Aggregation.Sum;
6
6
  export declare namespace Aggregation {
7
7
  interface Count extends Lark.CountAggregationPricingMetricResource {
8
8
  aggregation_type: "count";
9
9
  }
10
- interface Custom extends Lark.CustomPricingMetricResource {
11
- aggregation_type: "custom";
12
- }
13
- interface Last extends Lark.LastAggregationPricingMetricResource {
14
- aggregation_type: "last";
15
- }
16
- interface Max extends Lark.MaxAggregationPricingMetricResource {
17
- aggregation_type: "max";
18
- }
19
10
  interface Sum extends Lark.SumAggregationPricingMetricResource {
20
11
  aggregation_type: "sum";
21
12
  }
@@ -4,5 +4,6 @@
4
4
  export interface Amount {
5
5
  /** The value of the amount in the smallest unit of the currency. */
6
6
  value: string;
7
+ /** The currency code of the amount. */
7
8
  currency_code: string;
8
9
  }
@@ -2,6 +2,8 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  export interface CreateCustomerPortalSessionResponse {
5
+ /** The ID of the subject for the customer portal session. */
5
6
  subject_id: string;
7
+ /** The URL to redirect to the customer portal session. */
6
8
  url: string;
7
9
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface CreateFixedRateRequest {
6
+ /** The name of the rate displayed to the customer. */
7
+ name: string;
8
+ /** The description of the rate displayed to the customer. */
9
+ description?: string;
10
+ price: Lark.Price;
11
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface CreateSimpleUsageBasedRateRequest {
6
+ /** The name of the rate displayed to the customer. */
7
+ name: string;
8
+ /** The description of the rate displayed to the customer. */
9
+ description?: string;
10
+ price: Lark.Price;
11
+ /** The number of units included in the rate before the price is applied. */
12
+ included_units?: number;
13
+ /** The ID of the pricing metric to use for this rate. */
14
+ pricing_metric_id: string;
15
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -2,10 +2,16 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  export interface CreateSubjectResponse {
5
+ /** The ID of the subject. */
5
6
  id: string;
7
+ /** The ID of the subject in your system. You may pass it to the API in place of the subject ID. */
6
8
  external_id?: string;
9
+ /** The name of the subject. Used for display in the dashboard. */
7
10
  name?: string;
11
+ /** The email of the subject. */
8
12
  email?: string;
13
+ /** Additional metadata about the subject. You may use this to store any custom data about the subject. */
9
14
  metadata: Record<string, string>;
15
+ /** The date and time the subject was created. */
10
16
  created_at: string;
11
17
  }
@@ -3,7 +3,10 @@
3
3
  */
4
4
  import * as Lark from "../index.mjs";
5
5
  export interface CreateSubscriptionCheckoutSessionResponse {
6
+ /** The ID of the checkout session. */
6
7
  id: string;
8
+ /** The amount of the checkout session. */
7
9
  amount: Lark.Amount;
10
+ /** The URL to redirect to the checkout session. */
8
11
  url: string;
9
12
  }
@@ -5,6 +5,6 @@ import * as Lark from "../index.mjs";
5
5
  export interface FixedRateInterface {
6
6
  id: string;
7
7
  name: string;
8
- description: string;
8
+ description?: string;
9
9
  price: Lark.Price;
10
10
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface InvoiceLineItemResource {
6
+ amount: Lark.Amount;
7
+ description: string;
8
+ quantity: number;
9
+ price_in_unit_amount: Lark.Amount;
10
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface InvoiceResource {
6
+ /** The ID of the invoice. */
7
+ id: string;
8
+ /** The total amount of the invoice. */
9
+ total_amount: Lark.Amount;
10
+ /** The ID of the subject for the invoice. */
11
+ subject_id: string;
12
+ /** The date and time the invoice was created. */
13
+ created_at: string;
14
+ /** The status of the invoice. */
15
+ status: InvoiceResource.Status;
16
+ /** The URL of the hosted invoice. */
17
+ hosted_url?: string;
18
+ /** The line items of the invoice. */
19
+ line_items: Lark.InvoiceLineItemResource[];
20
+ }
21
+ export declare namespace InvoiceResource {
22
+ /**
23
+ * The status of the invoice.
24
+ */
25
+ type Status = "draft" | "open" | "paid" | "uncollectible" | "void";
26
+ const Status: {
27
+ readonly Draft: "draft";
28
+ readonly Open: "open";
29
+ readonly Paid: "paid";
30
+ readonly Uncollectible: "uncollectible";
31
+ readonly Void: "void";
32
+ };
33
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export var InvoiceResource;
5
+ (function (InvoiceResource) {
6
+ InvoiceResource.Status = {
7
+ Draft: "draft",
8
+ Open: "open",
9
+ Paid: "paid",
10
+ Uncollectible: "uncollectible",
11
+ Void: "void",
12
+ };
13
+ })(InvoiceResource || (InvoiceResource = {}));
@@ -2,8 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Lark from "../index.mjs";
5
- export interface CreateFixedRateInterface {
6
- name?: string;
7
- description?: string;
8
- price: Lark.Price;
5
+ export interface ListInvoicesResponse {
6
+ invoices: Lark.InvoiceResource[];
7
+ has_more: boolean;
9
8
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface ListPricingMetricsResponse {
6
+ pricing_metrics: Lark.PricingMetricResource[];
7
+ has_more: boolean;
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface PeriodResource {
5
+ inclusive_start?: boolean;
6
+ inclusive_end?: boolean;
7
+ start: string;
8
+ end: string;
9
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.mjs";
5
+ export interface PricingMetricResource {
6
+ id: string;
7
+ name: string;
8
+ event_name: string;
9
+ aggregation: Lark.Aggregation;
10
+ unit: string;
11
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -3,13 +3,20 @@
3
3
  */
4
4
  import * as Lark from "../index.mjs";
5
5
  export interface RateCardResource {
6
+ /** The ID of the rate card. */
6
7
  id: string;
8
+ /** The name of the rate card. */
7
9
  name: string;
8
- description: string;
10
+ /** The description of the rate card. */
11
+ description?: string;
12
+ /** The usage based rates of the rate card. */
9
13
  usage_based_rates: Lark.RateCardResourceUsageBasedRatesItem[];
14
+ /** The fixed rates of the rate card. */
10
15
  fixed_rates: Lark.FixedRateInterface[];
11
16
  billing_interval: RateCardResource.BillingInterval;
17
+ /** The date and time the rate card was created. */
12
18
  created_at: string;
19
+ /** The date and time the rate card was last updated. */
13
20
  updated_at: string;
14
21
  metadata: Record<string, string>;
15
22
  }
@@ -4,10 +4,8 @@
4
4
  import * as Lark from "../index.mjs";
5
5
  export interface SimpleUsageBasedRateInterface {
6
6
  id: string;
7
- /** Code of this rate to be used for overrides and external reference. */
8
- code: string;
9
7
  name: string;
10
- description: string;
8
+ description?: string;
11
9
  price: Lark.Price;
12
10
  included_units: number;
13
11
  pricing_metric_id: string;