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
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateRateCardRequestUsageBasedRatesItem.js"), exports);
@@ -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
  }>;
@@ -135,8 +135,8 @@ class Subscriptions {
135
135
  *
136
136
  * @example
137
137
  * await client.subscriptions.createSubscription({
138
- * rate_card_id: "rate_card_id",
139
- * subject_id: "subject_id"
138
+ * rate_card_id: "rc_AJWMxR81jxoRlli6p13uf3JB",
139
+ * subject_id: "subj_VyX6Q96h5avMho8O7QWlKeXE"
140
140
  * })
141
141
  */
142
142
  createSubscription(request, requestOptions) {
@@ -247,6 +247,130 @@ class Subscriptions {
247
247
  }
248
248
  });
249
249
  }
250
+ /**
251
+ * @param {string} subscriptionId
252
+ * @param {Lark.CancelSubscriptionRequest} request
253
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
254
+ *
255
+ * @throws {@link Lark.UnprocessableEntityError}
256
+ *
257
+ * @example
258
+ * await client.subscriptions.cancelSubscription("subscription_id")
259
+ */
260
+ cancelSubscription(subscriptionId, request = {}, requestOptions) {
261
+ return core.HttpResponsePromise.fromPromise(this.__cancelSubscription(subscriptionId, request, requestOptions));
262
+ }
263
+ __cancelSubscription(subscriptionId_1) {
264
+ return __awaiter(this, arguments, void 0, function* (subscriptionId, request = {}, requestOptions) {
265
+ var _a, _b, _c;
266
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
267
+ const _response = yield core.fetcher({
268
+ 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`),
269
+ method: "POST",
270
+ headers: _headers,
271
+ contentType: "application/json",
272
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
273
+ requestType: "json",
274
+ body: request,
275
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
276
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
277
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
278
+ });
279
+ if (_response.ok) {
280
+ return { data: _response.body, rawResponse: _response.rawResponse };
281
+ }
282
+ if (_response.error.reason === "status-code") {
283
+ switch (_response.error.statusCode) {
284
+ case 422:
285
+ throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
286
+ default:
287
+ throw new errors.LarkError({
288
+ statusCode: _response.error.statusCode,
289
+ body: _response.error.body,
290
+ rawResponse: _response.rawResponse,
291
+ });
292
+ }
293
+ }
294
+ switch (_response.error.reason) {
295
+ case "non-json":
296
+ throw new errors.LarkError({
297
+ statusCode: _response.error.statusCode,
298
+ body: _response.error.rawBody,
299
+ rawResponse: _response.rawResponse,
300
+ });
301
+ case "timeout":
302
+ throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /subscriptions/{subscription_id}/cancel.");
303
+ case "unknown":
304
+ throw new errors.LarkError({
305
+ message: _response.error.errorMessage,
306
+ rawResponse: _response.rawResponse,
307
+ });
308
+ }
309
+ });
310
+ }
311
+ /**
312
+ * @param {string} subscriptionId
313
+ * @param {Lark.ChangeSubscriptionRateCardRequest} request
314
+ * @param {Subscriptions.RequestOptions} requestOptions - Request-specific configuration.
315
+ *
316
+ * @throws {@link Lark.UnprocessableEntityError}
317
+ *
318
+ * @example
319
+ * await client.subscriptions.changeSubscriptionRateCard("subscription_id", {
320
+ * rate_card_id: "rc_jQK2n0wutCj6bBcAIrL6o07g"
321
+ * })
322
+ */
323
+ changeSubscriptionRateCard(subscriptionId, request, requestOptions) {
324
+ return core.HttpResponsePromise.fromPromise(this.__changeSubscriptionRateCard(subscriptionId, request, requestOptions));
325
+ }
326
+ __changeSubscriptionRateCard(subscriptionId, request, requestOptions) {
327
+ return __awaiter(this, void 0, void 0, function* () {
328
+ var _a, _b, _c;
329
+ let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
330
+ const _response = yield core.fetcher({
331
+ 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`),
332
+ method: "POST",
333
+ headers: _headers,
334
+ contentType: "application/json",
335
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
336
+ requestType: "json",
337
+ body: request,
338
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
339
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
340
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
341
+ });
342
+ if (_response.ok) {
343
+ return { data: _response.body, rawResponse: _response.rawResponse };
344
+ }
345
+ if (_response.error.reason === "status-code") {
346
+ switch (_response.error.statusCode) {
347
+ case 422:
348
+ throw new Lark.UnprocessableEntityError(_response.error.body, _response.rawResponse);
349
+ default:
350
+ throw new errors.LarkError({
351
+ statusCode: _response.error.statusCode,
352
+ body: _response.error.body,
353
+ rawResponse: _response.rawResponse,
354
+ });
355
+ }
356
+ }
357
+ switch (_response.error.reason) {
358
+ case "non-json":
359
+ throw new errors.LarkError({
360
+ statusCode: _response.error.statusCode,
361
+ body: _response.error.rawBody,
362
+ rawResponse: _response.rawResponse,
363
+ });
364
+ case "timeout":
365
+ throw new errors.LarkTimeoutError("Timeout exceeded when calling POST /subscriptions/{subscription_id}/change-rate-card.");
366
+ case "unknown":
367
+ throw new errors.LarkError({
368
+ message: _response.error.errorMessage,
369
+ rawResponse: _response.rawResponse,
370
+ });
371
+ }
372
+ });
373
+ }
250
374
  _getCustomAuthorizationHeaders() {
251
375
  return __awaiter(this, void 0, void 0, function* () {
252
376
  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.js";
2
2
  export { type CreateSubscriptionRequest } from "./CreateSubscriptionRequest.js";
3
+ export { type CancelSubscriptionRequest } from "./CancelSubscriptionRequest.js";
4
+ export { type ChangeSubscriptionRateCardRequest } from "./ChangeSubscriptionRateCardRequest.js";
@@ -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.js";
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.js";
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.js";
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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.js";
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.js";
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.js";
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.js";
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,16 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InvoiceResource = void 0;
7
+ var InvoiceResource;
8
+ (function (InvoiceResource) {
9
+ InvoiceResource.Status = {
10
+ Draft: "draft",
11
+ Open: "open",
12
+ Paid: "paid",
13
+ Uncollectible: "uncollectible",
14
+ Void: "void",
15
+ };
16
+ })(InvoiceResource || (exports.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.js";
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.js";
5
+ export interface ListPricingMetricsResponse {
6
+ pricing_metrics: Lark.PricingMetricResource[];
7
+ has_more: boolean;
8
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Lark from "../index.js";
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,13 +3,20 @@
3
3
  */
4
4
  import * as Lark from "../index.js";
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.js";
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;
@@ -2,10 +2,16 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  export interface SubjectResource {
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
  }