lark-billing 0.0.8 → 0.1.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 (131) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/checkout/client/Client.d.ts +2 -2
  4. package/dist/cjs/api/resources/checkout/client/Client.js +2 -2
  5. package/dist/cjs/api/resources/checkout/client/requests/CreateSubscriptionCheckoutSessionRequest.d.ts +4 -2
  6. package/dist/cjs/api/resources/customerPortal/client/Client.d.ts +1 -1
  7. package/dist/cjs/api/resources/customerPortal/client/Client.js +1 -1
  8. package/dist/cjs/api/resources/customerPortal/client/requests/CreateCustomerPortalSessionRequest.d.ts +2 -1
  9. package/dist/cjs/api/resources/pricingMetrics/client/Client.d.ts +25 -6
  10. package/dist/cjs/api/resources/pricingMetrics/client/Client.js +72 -4
  11. package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricRequest.d.ts +9 -5
  12. package/dist/cjs/api/resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.d.ts +20 -0
  13. package/dist/cjs/api/resources/pricingMetrics/client/requests/index.d.ts +1 -0
  14. package/dist/cjs/api/resources/pricingMetrics/types/PricingMetricAggregation.d.ts +13 -1
  15. package/dist/cjs/api/resources/rateCards/client/Client.d.ts +28 -2
  16. package/dist/cjs/api/resources/rateCards/client/Client.js +28 -2
  17. package/dist/cjs/api/resources/rateCards/client/requests/CreateRateCardRequest.d.ts +38 -4
  18. package/dist/cjs/api/resources/subjects/client/Client.d.ts +8 -1
  19. package/dist/cjs/api/resources/subjects/client/Client.js +8 -1
  20. package/dist/cjs/api/resources/subjects/client/requests/CreateSubjectRequest.d.ts +8 -1
  21. package/dist/cjs/api/resources/subscriptions/client/Client.d.ts +1 -1
  22. package/dist/cjs/api/resources/subscriptions/client/Client.js +1 -1
  23. package/dist/cjs/api/resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.d.ts +2 -1
  24. package/dist/cjs/api/resources/usageEvents/client/Client.d.ts +7 -23
  25. package/dist/cjs/api/resources/usageEvents/client/Client.js +7 -72
  26. package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.ts +18 -5
  27. package/dist/cjs/api/resources/usageEvents/client/requests/index.d.ts +0 -1
  28. package/dist/cjs/api/types/Aggregation.d.ts +10 -1
  29. package/dist/cjs/api/types/Amount.d.ts +1 -0
  30. package/dist/cjs/api/types/BillingStateResponse.d.ts +2 -0
  31. package/dist/cjs/api/types/CountAggregationPricingMetricInterface.d.ts +3 -0
  32. package/dist/cjs/api/types/CreateCustomerPortalSessionResponse.d.ts +2 -0
  33. package/dist/cjs/api/types/CreateFixedRateRequest.d.ts +3 -1
  34. package/dist/cjs/api/types/CreateSimpleUsageBasedRateRequest.d.ts +4 -1
  35. package/dist/cjs/api/types/CreateSubscriptionCheckoutSessionResponse.d.ts +3 -0
  36. package/dist/cjs/api/types/CustomAggregationPricingMetricInterface.d.ts +10 -0
  37. package/dist/cjs/api/types/FixedRateInterface.d.ts +1 -1
  38. package/dist/cjs/api/types/InvoiceResource.d.ts +10 -2
  39. package/dist/cjs/api/types/LastAggregationPricingMetricInterface.d.ts +10 -0
  40. package/dist/cjs/api/types/LastAggregationPricingMetricResource.d.ts +7 -0
  41. package/dist/cjs/api/types/LastAggregationPricingMetricResource.js +5 -0
  42. package/dist/cjs/api/types/MaxAggregationPricingMetricInterface.d.ts +10 -0
  43. package/dist/cjs/api/types/MaxAggregationPricingMetricInterface.js +5 -0
  44. package/dist/cjs/api/types/MaxAggregationPricingMetricResource.d.ts +7 -0
  45. package/dist/cjs/api/types/MaxAggregationPricingMetricResource.js +5 -0
  46. package/dist/cjs/api/types/PricingMetricResource.d.ts +5 -0
  47. package/dist/cjs/api/types/PricingMetricSummaryResource.d.ts +16 -0
  48. package/dist/cjs/api/types/PricingMetricSummaryResource.js +5 -0
  49. package/dist/cjs/api/types/RateCardResource.d.ts +8 -1
  50. package/dist/cjs/api/types/SimpleUsageBasedRateInterface.d.ts +1 -1
  51. package/dist/cjs/api/types/SubscriptionResource.d.ts +11 -0
  52. package/dist/cjs/api/types/SumAggregationPricingMetricInterface.d.ts +3 -0
  53. package/dist/cjs/api/types/SumAggregationPricingMetricResource.d.ts +1 -0
  54. package/dist/cjs/api/types/index.d.ts +7 -4
  55. package/dist/cjs/api/types/index.js +7 -4
  56. package/dist/cjs/version.d.ts +1 -1
  57. package/dist/cjs/version.js +1 -1
  58. package/dist/esm/Client.mjs +2 -2
  59. package/dist/esm/api/resources/checkout/client/Client.d.mts +2 -2
  60. package/dist/esm/api/resources/checkout/client/Client.mjs +2 -2
  61. package/dist/esm/api/resources/checkout/client/requests/CreateSubscriptionCheckoutSessionRequest.d.mts +4 -2
  62. package/dist/esm/api/resources/customerPortal/client/Client.d.mts +1 -1
  63. package/dist/esm/api/resources/customerPortal/client/Client.mjs +1 -1
  64. package/dist/esm/api/resources/customerPortal/client/requests/CreateCustomerPortalSessionRequest.d.mts +2 -1
  65. package/dist/esm/api/resources/pricingMetrics/client/Client.d.mts +25 -6
  66. package/dist/esm/api/resources/pricingMetrics/client/Client.mjs +72 -4
  67. package/dist/esm/api/resources/pricingMetrics/client/requests/CreatePricingMetricRequest.d.mts +9 -5
  68. package/dist/esm/api/resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.d.mts +20 -0
  69. package/dist/esm/api/resources/pricingMetrics/client/requests/index.d.mts +1 -0
  70. package/dist/esm/api/resources/pricingMetrics/types/PricingMetricAggregation.d.mts +13 -1
  71. package/dist/esm/api/resources/rateCards/client/Client.d.mts +28 -2
  72. package/dist/esm/api/resources/rateCards/client/Client.mjs +28 -2
  73. package/dist/esm/api/resources/rateCards/client/requests/CreateRateCardRequest.d.mts +38 -4
  74. package/dist/esm/api/resources/subjects/client/Client.d.mts +8 -1
  75. package/dist/esm/api/resources/subjects/client/Client.mjs +8 -1
  76. package/dist/esm/api/resources/subjects/client/requests/CreateSubjectRequest.d.mts +8 -1
  77. package/dist/esm/api/resources/subscriptions/client/Client.d.mts +1 -1
  78. package/dist/esm/api/resources/subscriptions/client/Client.mjs +1 -1
  79. package/dist/esm/api/resources/subscriptions/client/requests/ChangeSubscriptionRateCardRequest.d.mts +2 -1
  80. package/dist/esm/api/resources/usageEvents/client/Client.d.mts +7 -23
  81. package/dist/esm/api/resources/usageEvents/client/Client.mjs +7 -72
  82. package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventRequest.d.mts +18 -5
  83. package/dist/esm/api/resources/usageEvents/client/requests/index.d.mts +0 -1
  84. package/dist/esm/api/types/Aggregation.d.mts +10 -1
  85. package/dist/esm/api/types/Amount.d.mts +1 -0
  86. package/dist/esm/api/types/BillingStateResponse.d.mts +2 -0
  87. package/dist/esm/api/types/CountAggregationPricingMetricInterface.d.mts +3 -0
  88. package/dist/esm/api/types/CreateCustomerPortalSessionResponse.d.mts +2 -0
  89. package/dist/esm/api/types/CreateFixedRateRequest.d.mts +3 -1
  90. package/dist/esm/api/types/CreateSimpleUsageBasedRateRequest.d.mts +4 -1
  91. package/dist/esm/api/types/CreateSubscriptionCheckoutSessionResponse.d.mts +3 -0
  92. package/dist/esm/api/types/CustomAggregationPricingMetricInterface.d.mts +10 -0
  93. package/dist/esm/api/types/FixedRateInterface.d.mts +1 -1
  94. package/dist/esm/api/types/InvoiceResource.d.mts +10 -2
  95. package/dist/esm/api/types/LastAggregationPricingMetricInterface.d.mts +10 -0
  96. package/dist/esm/api/types/LastAggregationPricingMetricResource.d.mts +7 -0
  97. package/dist/esm/api/types/LastAggregationPricingMetricResource.mjs +4 -0
  98. package/dist/esm/api/types/MaxAggregationPricingMetricInterface.d.mts +10 -0
  99. package/dist/esm/api/types/MaxAggregationPricingMetricInterface.mjs +4 -0
  100. package/dist/esm/api/types/MaxAggregationPricingMetricResource.d.mts +7 -0
  101. package/dist/esm/api/types/MaxAggregationPricingMetricResource.mjs +4 -0
  102. package/dist/esm/api/types/PricingMetricResource.d.mts +5 -0
  103. package/dist/esm/api/types/PricingMetricSummaryResource.d.mts +16 -0
  104. package/dist/esm/api/types/PricingMetricSummaryResource.mjs +4 -0
  105. package/dist/esm/api/types/RateCardResource.d.mts +8 -1
  106. package/dist/esm/api/types/SimpleUsageBasedRateInterface.d.mts +1 -1
  107. package/dist/esm/api/types/SubscriptionResource.d.mts +11 -0
  108. package/dist/esm/api/types/SumAggregationPricingMetricInterface.d.mts +3 -0
  109. package/dist/esm/api/types/SumAggregationPricingMetricResource.d.mts +1 -0
  110. package/dist/esm/api/types/index.d.mts +7 -4
  111. package/dist/esm/api/types/index.mjs +7 -4
  112. package/dist/esm/version.d.mts +1 -1
  113. package/dist/esm/version.mjs +1 -1
  114. package/package.json +1 -1
  115. package/reference.md +119 -72
  116. package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.d.ts +0 -30
  117. package/dist/cjs/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.js +0 -14
  118. package/dist/cjs/api/types/CreatePricingMetricResponse.d.ts +0 -11
  119. package/dist/cjs/api/types/CreateUsageEventSummaryResponse.d.ts +0 -10
  120. package/dist/cjs/api/types/GetPricingMetricResponse.d.ts +0 -11
  121. package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.d.mts +0 -30
  122. package/dist/esm/api/resources/usageEvents/client/requests/CreateUsageEventSummaryRequest.mjs +0 -11
  123. package/dist/esm/api/types/CreatePricingMetricResponse.d.mts +0 -11
  124. package/dist/esm/api/types/CreateUsageEventSummaryResponse.d.mts +0 -10
  125. package/dist/esm/api/types/GetPricingMetricResponse.d.mts +0 -11
  126. /package/dist/cjs/api/{types/CreatePricingMetricResponse.js → resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.js} +0 -0
  127. /package/dist/cjs/api/types/{CreateUsageEventSummaryResponse.js → CustomAggregationPricingMetricInterface.js} +0 -0
  128. /package/dist/cjs/api/types/{GetPricingMetricResponse.js → LastAggregationPricingMetricInterface.js} +0 -0
  129. /package/dist/esm/api/{types/CreatePricingMetricResponse.mjs → resources/pricingMetrics/client/requests/CreatePricingMetricSummaryRequest.mjs} +0 -0
  130. /package/dist/esm/api/types/{CreateUsageEventSummaryResponse.mjs → CustomAggregationPricingMetricInterface.mjs} +0 -0
  131. /package/dist/esm/api/types/{GetPricingMetricResponse.mjs → LastAggregationPricingMetricInterface.mjs} +0 -0
@@ -50,15 +50,16 @@ export declare class PricingMetrics {
50
50
  *
51
51
  * @example
52
52
  * await client.pricingMetrics.createPricingMetric({
53
- * name: "name",
54
- * event_name: "event_name",
53
+ * name: "Compute Hours",
54
+ * event_name: "job_completed",
55
55
  * aggregation: {
56
- * aggregation_type: "count"
56
+ * aggregation_type: "sum",
57
+ * value_field: "value_field"
57
58
  * },
58
- * unit: "unit"
59
+ * unit: "hours"
59
60
  * })
60
61
  */
61
- createPricingMetric(request: Lark.CreatePricingMetricRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.CreatePricingMetricResponse>;
62
+ createPricingMetric(request: Lark.CreatePricingMetricRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricResource>;
62
63
  private __createPricingMetric;
63
64
  /**
64
65
  * @param {string} pricingMetricId
@@ -69,8 +70,26 @@ export declare class PricingMetrics {
69
70
  * @example
70
71
  * await client.pricingMetrics.getPricingMetric("pricing_metric_id")
71
72
  */
72
- getPricingMetric(pricingMetricId: string, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.GetPricingMetricResponse>;
73
+ getPricingMetric(pricingMetricId: string, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricResource>;
73
74
  private __getPricingMetric;
75
+ /**
76
+ * @param {string} pricingMetricId
77
+ * @param {Lark.CreatePricingMetricSummaryRequest} request
78
+ * @param {PricingMetrics.RequestOptions} requestOptions - Request-specific configuration.
79
+ *
80
+ * @throws {@link Lark.UnprocessableEntityError}
81
+ *
82
+ * @example
83
+ * await client.pricingMetrics.createPricingMetricSummary("pricing_metric_id", {
84
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
85
+ * period: {
86
+ * start: "2025-10-01T00:00:00Z",
87
+ * end: "2025-11-01T00:00:00Z"
88
+ * }
89
+ * })
90
+ */
91
+ createPricingMetricSummary(pricingMetricId: string, request: Lark.CreatePricingMetricSummaryRequest, requestOptions?: PricingMetrics.RequestOptions): core.HttpResponsePromise<Lark.PricingMetricSummaryResource>;
92
+ private __createPricingMetricSummary;
74
93
  protected _getCustomAuthorizationHeaders(): Promise<{
75
94
  "X-API-Key": string;
76
95
  }>;
@@ -91,12 +91,13 @@ export class PricingMetrics {
91
91
  *
92
92
  * @example
93
93
  * await client.pricingMetrics.createPricingMetric({
94
- * name: "name",
95
- * event_name: "event_name",
94
+ * name: "Compute Hours",
95
+ * event_name: "job_completed",
96
96
  * aggregation: {
97
- * aggregation_type: "count"
97
+ * aggregation_type: "sum",
98
+ * value_field: "value_field"
98
99
  * },
99
- * unit: "unit"
100
+ * unit: "hours"
100
101
  * })
101
102
  */
102
103
  createPricingMetric(request, requestOptions) {
@@ -207,6 +208,73 @@ export class PricingMetrics {
207
208
  }
208
209
  });
209
210
  }
211
+ /**
212
+ * @param {string} pricingMetricId
213
+ * @param {Lark.CreatePricingMetricSummaryRequest} request
214
+ * @param {PricingMetrics.RequestOptions} requestOptions - Request-specific configuration.
215
+ *
216
+ * @throws {@link Lark.UnprocessableEntityError}
217
+ *
218
+ * @example
219
+ * await client.pricingMetrics.createPricingMetricSummary("pricing_metric_id", {
220
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
221
+ * period: {
222
+ * start: "2025-10-01T00:00:00Z",
223
+ * end: "2025-11-01T00:00:00Z"
224
+ * }
225
+ * })
226
+ */
227
+ createPricingMetricSummary(pricingMetricId, request, requestOptions) {
228
+ return core.HttpResponsePromise.fromPromise(this.__createPricingMetricSummary(pricingMetricId, request, requestOptions));
229
+ }
230
+ __createPricingMetricSummary(pricingMetricId, request, requestOptions) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ var _a, _b, _c;
233
+ 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);
234
+ const _response = yield core.fetcher({
235
+ 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, `pricing-metrics/${encodeURIComponent(pricingMetricId)}/summary`),
236
+ method: "POST",
237
+ headers: _headers,
238
+ contentType: "application/json",
239
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
240
+ requestType: "json",
241
+ body: request,
242
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
243
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
244
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
245
+ });
246
+ if (_response.ok) {
247
+ return { data: _response.body, rawResponse: _response.rawResponse };
248
+ }
249
+ if (_response.error.reason === "status-code") {
250
+ switch (_response.error.statusCode) {
251
+ case 422:
252
+ throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
253
+ default:
254
+ throw new errors.LarkError({
255
+ statusCode: _response.error.statusCode,
256
+ body: _response.error.body,
257
+ rawResponse: _response.rawResponse,
258
+ });
259
+ }
260
+ }
261
+ switch (_response.error.reason) {
262
+ case "non-json":
263
+ throw new errors.LarkError({
264
+ statusCode: _response.error.statusCode,
265
+ body: _response.error.rawBody,
266
+ rawResponse: _response.rawResponse,
267
+ });
268
+ case "timeout":
269
+ throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /pricing-metrics/{pricing_metric_id}/summary.");
270
+ case "unknown":
271
+ throw new errors.LarkError({
272
+ message: _response.error.errorMessage,
273
+ rawResponse: _response.rawResponse,
274
+ });
275
+ }
276
+ });
277
+ }
210
278
  _getCustomAuthorizationHeaders() {
211
279
  return __awaiter(this, void 0, void 0, function* () {
212
280
  const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
@@ -5,18 +5,22 @@ import * as Lark from "../../../../index.mjs";
5
5
  /**
6
6
  * @example
7
7
  * {
8
- * name: "name",
9
- * event_name: "event_name",
8
+ * name: "Compute Hours",
9
+ * event_name: "job_completed",
10
10
  * aggregation: {
11
- * aggregation_type: "count"
11
+ * aggregation_type: "sum",
12
+ * value_field: "value_field"
12
13
  * },
13
- * unit: "unit"
14
+ * unit: "hours"
14
15
  * }
15
16
  */
16
17
  export interface CreatePricingMetricRequest {
18
+ /** The name of the pricing metric. */
17
19
  name: string;
20
+ /** The name of the event that the pricing metric is computed on. */
18
21
  event_name: string;
22
+ /** The aggregation function used to compute the value of the pricing metric. */
19
23
  aggregation: Lark.PricingMetricAggregation;
20
- /** Unit of measurement for the pricing metric */
24
+ /** Unit of measurement for the pricing metric. */
21
25
  unit: string;
22
26
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../../../../index.mjs";
5
+ /**
6
+ * @example
7
+ * {
8
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
9
+ * period: {
10
+ * start: "2025-10-01T00:00:00Z",
11
+ * end: "2025-11-01T00:00:00Z"
12
+ * }
13
+ * }
14
+ */
15
+ export interface CreatePricingMetricSummaryRequest {
16
+ /** The ID of the subject that the summary should be computed for. */
17
+ subject_id: string;
18
+ /** The period that the summary should be computed over. */
19
+ period: Lark.Period;
20
+ }
@@ -1,2 +1,3 @@
1
1
  export { type ListPricingMetricsPricingMetricsGetRequest } from "./ListPricingMetricsPricingMetricsGetRequest.mjs";
2
2
  export { type CreatePricingMetricRequest } from "./CreatePricingMetricRequest.mjs";
3
+ export { type CreatePricingMetricSummaryRequest } from "./CreatePricingMetricSummaryRequest.mjs";
@@ -2,11 +2,23 @@
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 PricingMetricAggregation = Lark.PricingMetricAggregation.Count | Lark.PricingMetricAggregation.Sum;
5
+ /**
6
+ * The aggregation function used to compute the value of the pricing metric.
7
+ */
8
+ export type PricingMetricAggregation = Lark.PricingMetricAggregation.Count | Lark.PricingMetricAggregation.Custom | Lark.PricingMetricAggregation.Last | Lark.PricingMetricAggregation.Max | Lark.PricingMetricAggregation.Sum;
6
9
  export declare namespace PricingMetricAggregation {
7
10
  interface Count extends Lark.CountAggregationPricingMetricInterface {
8
11
  aggregation_type: "count";
9
12
  }
13
+ interface Custom extends Lark.CustomAggregationPricingMetricInterface {
14
+ aggregation_type: "custom";
15
+ }
16
+ interface Last extends Lark.LastAggregationPricingMetricInterface {
17
+ aggregation_type: "last";
18
+ }
19
+ interface Max extends Lark.MaxAggregationPricingMetricInterface {
20
+ aggregation_type: "max";
21
+ }
10
22
  interface Sum extends Lark.SumAggregationPricingMetricInterface {
11
23
  aggregation_type: "sum";
12
24
  }
@@ -50,8 +50,34 @@ export declare class RateCards {
50
50
  *
51
51
  * @example
52
52
  * await client.rateCards.createRateCard({
53
- * name: "name",
54
- * billing_interval: "monthly"
53
+ * name: "Pro Plan",
54
+ * description: "For production applications with moderate usage.",
55
+ * billing_interval: "monthly",
56
+ * fixed_rates: [{
57
+ * name: "Base Rate",
58
+ * price: {
59
+ * price_type: "flat",
60
+ * amount: {
61
+ * value: "2500",
62
+ * currency_code: "usd"
63
+ * }
64
+ * }
65
+ * }],
66
+ * usage_based_rates: [{
67
+ * usage_based_rate_type: "simple",
68
+ * name: "name",
69
+ * price: {
70
+ * price_type: "flat",
71
+ * amount: {
72
+ * value: "2500",
73
+ * currency_code: "usd"
74
+ * }
75
+ * },
76
+ * pricing_metric_id: "pricing_metric_id"
77
+ * }],
78
+ * metadata: {
79
+ * "key": "value"
80
+ * }
55
81
  * })
56
82
  */
57
83
  createRateCard(request: Lark.CreateRateCardRequest, requestOptions?: RateCards.RequestOptions): core.HttpResponsePromise<Lark.RateCardResource>;
@@ -91,8 +91,34 @@ export class RateCards {
91
91
  *
92
92
  * @example
93
93
  * await client.rateCards.createRateCard({
94
- * name: "name",
95
- * billing_interval: "monthly"
94
+ * name: "Pro Plan",
95
+ * description: "For production applications with moderate usage.",
96
+ * billing_interval: "monthly",
97
+ * fixed_rates: [{
98
+ * name: "Base Rate",
99
+ * price: {
100
+ * price_type: "flat",
101
+ * amount: {
102
+ * value: "2500",
103
+ * currency_code: "usd"
104
+ * }
105
+ * }
106
+ * }],
107
+ * usage_based_rates: [{
108
+ * usage_based_rate_type: "simple",
109
+ * name: "name",
110
+ * price: {
111
+ * price_type: "flat",
112
+ * amount: {
113
+ * value: "2500",
114
+ * currency_code: "usd"
115
+ * }
116
+ * },
117
+ * pricing_metric_id: "pricing_metric_id"
118
+ * }],
119
+ * metadata: {
120
+ * "key": "value"
121
+ * }
96
122
  * })
97
123
  */
98
124
  createRateCard(request, requestOptions) {
@@ -5,19 +5,53 @@ import * as Lark from "../../../../index.mjs";
5
5
  /**
6
6
  * @example
7
7
  * {
8
- * name: "name",
9
- * billing_interval: "monthly"
8
+ * name: "Pro Plan",
9
+ * description: "For production applications with moderate usage.",
10
+ * billing_interval: "monthly",
11
+ * fixed_rates: [{
12
+ * name: "Base Rate",
13
+ * price: {
14
+ * price_type: "flat",
15
+ * amount: {
16
+ * value: "2500",
17
+ * currency_code: "usd"
18
+ * }
19
+ * }
20
+ * }],
21
+ * usage_based_rates: [{
22
+ * usage_based_rate_type: "simple",
23
+ * name: "name",
24
+ * price: {
25
+ * price_type: "flat",
26
+ * amount: {
27
+ * value: "2500",
28
+ * currency_code: "usd"
29
+ * }
30
+ * },
31
+ * pricing_metric_id: "pricing_metric_id"
32
+ * }],
33
+ * metadata: {
34
+ * "key": "value"
35
+ * }
10
36
  * }
11
37
  */
12
38
  export interface CreateRateCardRequest {
39
+ /** The name of the rate card displayed to the customer. */
13
40
  name: string;
41
+ /** The description of the rate card displayed to the customer. */
14
42
  description?: string;
15
- usage_based_rates?: Lark.CreateRateCardRequestUsageBasedRatesItem[];
16
- fixed_rates?: Lark.CreateFixedRateRequest[];
43
+ /** How often the customer will be billed for this rate card. */
17
44
  billing_interval: CreateRateCardRequest.BillingInterval;
45
+ /** The fixed rates of the rate card. These are billed at the start of each billing cycle. */
46
+ fixed_rates?: Lark.CreateFixedRateRequest[];
47
+ /** The usage based rates of the rate card. These are billed at the end of each billing cycle. */
48
+ usage_based_rates?: Lark.CreateRateCardRequestUsageBasedRatesItem[];
18
49
  metadata?: Record<string, string>;
19
50
  }
20
51
  export declare namespace CreateRateCardRequest {
52
+ /**
53
+ * How often the customer will be billed for this rate card.
54
+ */
21
55
  type BillingInterval = "monthly" | "yearly";
22
56
  const BillingInterval: {
23
57
  readonly Monthly: "monthly";
@@ -50,7 +50,14 @@ export declare class Subjects {
50
50
  * @throws {@link Lark.UnprocessableEntityError}
51
51
  *
52
52
  * @example
53
- * await client.subjects.createSubject()
53
+ * await client.subjects.createSubject({
54
+ * external_id: "user_1234567890",
55
+ * name: "John Doe",
56
+ * email: "john.doe@example.com",
57
+ * metadata: {
58
+ * "key": "value"
59
+ * }
60
+ * })
54
61
  */
55
62
  createSubject(request?: Lark.CreateSubjectRequest, requestOptions?: Subjects.RequestOptions): core.HttpResponsePromise<Lark.CreateSubjectResponse>;
56
63
  private __createSubject;
@@ -94,7 +94,14 @@ export class Subjects {
94
94
  * @throws {@link Lark.UnprocessableEntityError}
95
95
  *
96
96
  * @example
97
- * await client.subjects.createSubject()
97
+ * await client.subjects.createSubject({
98
+ * external_id: "user_1234567890",
99
+ * name: "John Doe",
100
+ * email: "john.doe@example.com",
101
+ * metadata: {
102
+ * "key": "value"
103
+ * }
104
+ * })
98
105
  */
99
106
  createSubject(request = {}, requestOptions) {
100
107
  return core.HttpResponsePromise.fromPromise(this.__createSubject(request, requestOptions));
@@ -3,7 +3,14 @@
3
3
  */
4
4
  /**
5
5
  * @example
6
- * {}
6
+ * {
7
+ * external_id: "user_1234567890",
8
+ * name: "John Doe",
9
+ * email: "john.doe@example.com",
10
+ * metadata: {
11
+ * "key": "value"
12
+ * }
13
+ * }
7
14
  */
8
15
  export interface CreateSubjectRequest {
9
16
  /** 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. */
@@ -90,7 +90,7 @@ export declare class Subscriptions {
90
90
  *
91
91
  * @example
92
92
  * await client.subscriptions.changeSubscriptionRateCard("subscription_id", {
93
- * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB"
93
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
94
94
  * })
95
95
  */
96
96
  changeSubscriptionRateCard(subscriptionId: string, request: Lark.ChangeSubscriptionRateCardRequest, requestOptions?: Subscriptions.RequestOptions): core.HttpResponsePromise<Lark.SubscriptionResource>;
@@ -281,7 +281,7 @@ export class Subscriptions {
281
281
  *
282
282
  * @example
283
283
  * await client.subscriptions.changeSubscriptionRateCard("subscription_id", {
284
- * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB"
284
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
285
285
  * })
286
286
  */
287
287
  changeSubscriptionRateCard(subscriptionId, request, requestOptions) {
@@ -4,9 +4,10 @@
4
4
  /**
5
5
  * @example
6
6
  * {
7
- * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB"
7
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
8
8
  * }
9
9
  */
10
10
  export interface ChangeSubscriptionRateCardRequest {
11
+ /** The ID of the rate card to change the subscription to. */
11
12
  rate_card_id: string;
12
13
  }
@@ -37,35 +37,19 @@ export declare class UsageEvents {
37
37
  *
38
38
  * @example
39
39
  * await client.usageEvents.createUsageEvent({
40
- * idempotency_key: "idempotency_key",
41
- * event_name: "event_name",
42
- * subject_id: "subject_id",
40
+ * idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
41
+ * event_name: "compute_hours",
42
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
43
+ * timestamp: "2025-10-31T20:29:47Z",
43
44
  * data: {
44
- * "key": "value"
45
+ * "compute_hours": 100,
46
+ * "instance_type": "t2.micro",
47
+ * "region": "us-east-1"
45
48
  * }
46
49
  * })
47
50
  */
48
51
  createUsageEvent(request: Lark.CreateUsageEventRequest, requestOptions?: UsageEvents.RequestOptions): core.HttpResponsePromise<unknown>;
49
52
  private __createUsageEvent;
50
- /**
51
- * @param {Lark.CreateUsageEventSummaryRequest} request
52
- * @param {UsageEvents.RequestOptions} requestOptions - Request-specific configuration.
53
- *
54
- * @throws {@link Lark.UnprocessableEntityError}
55
- *
56
- * @example
57
- * await client.usageEvents.createUsageEventSummary({
58
- * event_name: "event_name",
59
- * subject_id: "subject_id",
60
- * period: {
61
- * start: "2024-01-15T09:30:00Z",
62
- * end: "2024-01-15T09:30:00Z"
63
- * },
64
- * aggregation_type: "sum"
65
- * })
66
- */
67
- createUsageEventSummary(request: Lark.CreateUsageEventSummaryRequest, requestOptions?: UsageEvents.RequestOptions): core.HttpResponsePromise<Lark.CreateUsageEventSummaryResponse>;
68
- private __createUsageEventSummary;
69
53
  protected _getCustomAuthorizationHeaders(): Promise<{
70
54
  "X-API-Key": string;
71
55
  }>;
@@ -27,11 +27,14 @@ export class UsageEvents {
27
27
  *
28
28
  * @example
29
29
  * await client.usageEvents.createUsageEvent({
30
- * idempotency_key: "idempotency_key",
31
- * event_name: "event_name",
32
- * subject_id: "subject_id",
30
+ * idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
31
+ * event_name: "compute_hours",
32
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
33
+ * timestamp: "2025-10-31T20:29:47Z",
33
34
  * data: {
34
- * "key": "value"
35
+ * "compute_hours": 100,
36
+ * "instance_type": "t2.micro",
37
+ * "region": "us-east-1"
35
38
  * }
36
39
  * })
37
40
  */
@@ -86,74 +89,6 @@ export class UsageEvents {
86
89
  }
87
90
  });
88
91
  }
89
- /**
90
- * @param {Lark.CreateUsageEventSummaryRequest} request
91
- * @param {UsageEvents.RequestOptions} requestOptions - Request-specific configuration.
92
- *
93
- * @throws {@link Lark.UnprocessableEntityError}
94
- *
95
- * @example
96
- * await client.usageEvents.createUsageEventSummary({
97
- * event_name: "event_name",
98
- * subject_id: "subject_id",
99
- * period: {
100
- * start: "2024-01-15T09:30:00Z",
101
- * end: "2024-01-15T09:30:00Z"
102
- * },
103
- * aggregation_type: "sum"
104
- * })
105
- */
106
- createUsageEventSummary(request, requestOptions) {
107
- return core.HttpResponsePromise.fromPromise(this.__createUsageEventSummary(request, requestOptions));
108
- }
109
- __createUsageEventSummary(request, requestOptions) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- var _a, _b, _c;
112
- 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);
113
- const _response = yield core.fetcher({
114
- 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, "usage-events/summary"),
115
- method: "POST",
116
- headers: _headers,
117
- contentType: "application/json",
118
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
119
- requestType: "json",
120
- body: request,
121
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
122
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
123
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
124
- });
125
- if (_response.ok) {
126
- return { data: _response.body, rawResponse: _response.rawResponse };
127
- }
128
- if (_response.error.reason === "status-code") {
129
- switch (_response.error.statusCode) {
130
- case 422:
131
- throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
132
- default:
133
- throw new errors.LarkError({
134
- statusCode: _response.error.statusCode,
135
- body: _response.error.body,
136
- rawResponse: _response.rawResponse,
137
- });
138
- }
139
- }
140
- switch (_response.error.reason) {
141
- case "non-json":
142
- throw new errors.LarkError({
143
- statusCode: _response.error.statusCode,
144
- body: _response.error.rawBody,
145
- rawResponse: _response.rawResponse,
146
- });
147
- case "timeout":
148
- throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /usage-events/summary.");
149
- case "unknown":
150
- throw new errors.LarkError({
151
- message: _response.error.errorMessage,
152
- rawResponse: _response.rawResponse,
153
- });
154
- }
155
- });
156
- }
157
92
  _getCustomAuthorizationHeaders() {
158
93
  return __awaiter(this, void 0, void 0, function* () {
159
94
  const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
@@ -4,18 +4,31 @@
4
4
  /**
5
5
  * @example
6
6
  * {
7
- * idempotency_key: "idempotency_key",
8
- * event_name: "event_name",
9
- * subject_id: "subject_id",
7
+ * idempotency_key: "6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
8
+ * event_name: "compute_hours",
9
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE",
10
+ * timestamp: "2025-10-31T20:29:47Z",
10
11
  * data: {
11
- * "key": "value"
12
+ * "compute_hours": 100,
13
+ * "instance_type": "t2.micro",
14
+ * "region": "us-east-1"
12
15
  * }
13
16
  * }
14
17
  */
15
18
  export interface CreateUsageEventRequest {
19
+ /** The idempotency key for the usage event. This ensures that the same event is not processed multiple times. */
16
20
  idempotency_key: string;
21
+ /** The name of the event. This is used by pricing metrics to aggregate usage events. */
17
22
  event_name: string;
23
+ /** The ID of the subject that the usage event is for. */
18
24
  subject_id: string;
25
+ /** The timestamp of the usage event. It is highly recommended to provide a timestamp. If not provided, the current timestamp will be used. */
19
26
  timestamp?: string;
20
- data: Record<string, unknown>;
27
+ /** The data of the usage event. This should contain any data that is needed to aggregate the usage event. */
28
+ data: Record<string, CreateUsageEventRequest.Data.Value>;
29
+ }
30
+ export declare namespace CreateUsageEventRequest {
31
+ namespace Data {
32
+ type Value = string | number;
33
+ }
21
34
  }
@@ -1,2 +1 @@
1
1
  export { type CreateUsageEventRequest } from "./CreateUsageEventRequest.mjs";
2
- export { type CreateUsageEventSummaryRequest } from "./CreateUsageEventSummaryRequest.mjs";
@@ -2,11 +2,20 @@
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.Sum;
5
+ /**
6
+ * The aggregation function used to compute the value of the pricing metric.
7
+ */
8
+ export type Aggregation = Lark.Aggregation.Count | Lark.Aggregation.Last | Lark.Aggregation.Max | Lark.Aggregation.Sum;
6
9
  export declare namespace Aggregation {
7
10
  interface Count extends Lark.CountAggregationPricingMetricResource {
8
11
  aggregation_type: "count";
9
12
  }
13
+ interface Last extends Lark.LastAggregationPricingMetricResource {
14
+ aggregation_type: "last";
15
+ }
16
+ interface Max extends Lark.MaxAggregationPricingMetricResource {
17
+ aggregation_type: "max";
18
+ }
10
19
  interface Sum extends Lark.SumAggregationPricingMetricResource {
11
20
  aggregation_type: "sum";
12
21
  }
@@ -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
  }