@openmeter/sdk 1.0.0-beta.23 → 1.0.0-beta.231

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 (165) hide show
  1. package/README.md +234 -146
  2. package/dist/cjs/index.cjs +18 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/cjs/index.d.cts +1 -0
  5. package/dist/cjs/src/client/addons.cjs +105 -0
  6. package/dist/cjs/src/client/addons.cjs.map +1 -0
  7. package/dist/cjs/src/client/addons.d.cts +152 -0
  8. package/dist/cjs/src/client/apps.cjs +247 -0
  9. package/dist/cjs/src/client/apps.cjs.map +1 -0
  10. package/dist/cjs/src/client/apps.d.cts +327 -0
  11. package/dist/cjs/src/client/billing.cjs +375 -0
  12. package/dist/cjs/src/client/billing.cjs.map +1 -0
  13. package/dist/cjs/src/client/billing.d.cts +563 -0
  14. package/dist/cjs/src/client/common.cjs +47 -0
  15. package/dist/cjs/src/client/common.cjs.map +1 -0
  16. package/dist/cjs/src/client/common.d.cts +30 -0
  17. package/dist/cjs/src/client/customers.cjs +469 -0
  18. package/dist/cjs/src/client/customers.cjs.map +1 -0
  19. package/dist/cjs/src/client/customers.d.cts +620 -0
  20. package/dist/cjs/src/client/debug.cjs +27 -0
  21. package/dist/cjs/src/client/debug.cjs.map +1 -0
  22. package/dist/cjs/src/client/debug.d.cts +17 -0
  23. package/dist/cjs/src/client/entitlements.cjs +372 -0
  24. package/dist/cjs/src/client/entitlements.cjs.map +1 -0
  25. package/dist/cjs/src/client/entitlements.d.cts +670 -0
  26. package/dist/cjs/src/client/events.cjs +113 -0
  27. package/dist/cjs/src/client/events.cjs.map +1 -0
  28. package/dist/cjs/src/client/events.d.cts +48 -0
  29. package/dist/cjs/src/client/features.cjs +78 -0
  30. package/dist/cjs/src/client/features.cjs.map +1 -0
  31. package/dist/cjs/src/client/features.d.cts +90 -0
  32. package/dist/cjs/src/client/index.cjs +122 -0
  33. package/dist/cjs/src/client/index.cjs.map +1 -0
  34. package/dist/cjs/src/client/index.d.cts +54 -0
  35. package/dist/cjs/src/client/info.cjs +42 -0
  36. package/dist/cjs/src/client/info.cjs.map +1 -0
  37. package/dist/cjs/src/client/info.d.cts +34 -0
  38. package/dist/cjs/src/client/meters.cjs +160 -0
  39. package/dist/cjs/src/client/meters.cjs.map +1 -0
  40. package/dist/cjs/src/client/meters.d.cts +220 -0
  41. package/dist/cjs/src/client/notifications.cjs +269 -0
  42. package/dist/cjs/src/client/notifications.cjs.map +1 -0
  43. package/dist/cjs/src/client/notifications.d.cts +412 -0
  44. package/dist/cjs/src/client/plans.cjs +204 -0
  45. package/dist/cjs/src/client/plans.cjs.map +1 -0
  46. package/dist/cjs/src/client/plans.d.cts +252 -0
  47. package/dist/cjs/src/client/portal.cjs +55 -0
  48. package/dist/cjs/src/client/portal.cjs.map +1 -0
  49. package/dist/cjs/src/client/portal.d.cts +48 -0
  50. package/dist/cjs/src/client/schemas.cjs +3 -0
  51. package/dist/cjs/src/client/schemas.cjs.map +1 -0
  52. package/dist/cjs/src/client/schemas.d.cts +28002 -0
  53. package/dist/cjs/src/client/subjects.cjs +76 -0
  54. package/dist/cjs/src/client/subjects.cjs.map +1 -0
  55. package/dist/cjs/src/client/subjects.d.cts +79 -0
  56. package/dist/cjs/src/client/subscription-addons.cjs +70 -0
  57. package/dist/cjs/src/client/subscription-addons.cjs.map +1 -0
  58. package/dist/cjs/src/client/subscription-addons.d.cts +123 -0
  59. package/dist/cjs/src/client/subscriptions.cjs +132 -0
  60. package/dist/cjs/src/client/subscriptions.cjs.map +1 -0
  61. package/dist/cjs/src/client/subscriptions.d.cts +180 -0
  62. package/dist/cjs/src/client/utils.cjs +67 -0
  63. package/dist/cjs/src/client/utils.cjs.map +1 -0
  64. package/dist/cjs/src/client/utils.d.cts +12 -0
  65. package/dist/cjs/src/portal/index.cjs +89 -0
  66. package/dist/cjs/src/portal/index.cjs.map +1 -0
  67. package/dist/cjs/src/portal/index.d.cts +43 -0
  68. package/dist/cjs/src/react/context.cjs +35 -0
  69. package/dist/cjs/src/react/context.cjs.map +1 -0
  70. package/dist/cjs/src/react/context.d.cts +9 -0
  71. package/dist/cjs/src/zod/index.cjs +13679 -0
  72. package/dist/cjs/src/zod/index.cjs.map +1 -0
  73. package/dist/cjs/src/zod/index.d.cts +6360 -0
  74. package/dist/index.d.ts +1 -14
  75. package/dist/index.js +2 -15
  76. package/dist/index.js.map +1 -0
  77. package/dist/src/client/addons.d.ts +152 -0
  78. package/dist/src/client/addons.js +101 -0
  79. package/dist/src/client/addons.js.map +1 -0
  80. package/dist/src/client/apps.d.ts +327 -0
  81. package/dist/src/client/apps.js +240 -0
  82. package/dist/src/client/apps.js.map +1 -0
  83. package/dist/src/client/billing.d.ts +563 -0
  84. package/dist/src/client/billing.js +368 -0
  85. package/dist/src/client/billing.js.map +1 -0
  86. package/dist/src/client/common.d.ts +30 -0
  87. package/dist/src/client/common.js +42 -0
  88. package/dist/src/client/common.js.map +1 -0
  89. package/dist/src/client/customers.d.ts +620 -0
  90. package/dist/src/client/customers.js +461 -0
  91. package/dist/src/client/customers.js.map +1 -0
  92. package/dist/src/client/debug.d.ts +17 -0
  93. package/dist/src/client/debug.js +23 -0
  94. package/dist/src/client/debug.js.map +1 -0
  95. package/dist/src/client/entitlements.d.ts +670 -0
  96. package/dist/src/client/entitlements.js +365 -0
  97. package/dist/src/client/entitlements.js.map +1 -0
  98. package/dist/src/client/events.d.ts +48 -0
  99. package/dist/src/client/events.js +108 -0
  100. package/dist/src/client/events.js.map +1 -0
  101. package/dist/src/client/features.d.ts +90 -0
  102. package/dist/src/client/features.js +74 -0
  103. package/dist/src/client/features.js.map +1 -0
  104. package/dist/src/client/index.d.ts +54 -0
  105. package/dist/src/client/index.js +82 -0
  106. package/dist/src/client/index.js.map +1 -0
  107. package/dist/src/client/info.d.ts +34 -0
  108. package/dist/src/client/info.js +38 -0
  109. package/dist/src/client/info.js.map +1 -0
  110. package/dist/src/client/meters.d.ts +220 -0
  111. package/dist/src/client/meters.js +156 -0
  112. package/dist/src/client/meters.js.map +1 -0
  113. package/dist/src/client/notifications.d.ts +412 -0
  114. package/dist/src/client/notifications.js +262 -0
  115. package/dist/src/client/notifications.js.map +1 -0
  116. package/dist/src/client/plans.d.ts +252 -0
  117. package/dist/src/client/plans.js +199 -0
  118. package/dist/src/client/plans.js.map +1 -0
  119. package/dist/src/client/portal.d.ts +48 -0
  120. package/dist/src/client/portal.js +51 -0
  121. package/dist/src/client/portal.js.map +1 -0
  122. package/dist/src/client/schemas.d.ts +28002 -0
  123. package/dist/src/client/schemas.js +2 -0
  124. package/dist/src/client/schemas.js.map +1 -0
  125. package/dist/src/client/subjects.d.ts +79 -0
  126. package/dist/src/client/subjects.js +72 -0
  127. package/dist/src/client/subjects.js.map +1 -0
  128. package/dist/src/client/subscription-addons.d.ts +123 -0
  129. package/dist/src/client/subscription-addons.js +66 -0
  130. package/dist/src/client/subscription-addons.js.map +1 -0
  131. package/dist/src/client/subscriptions.d.ts +180 -0
  132. package/dist/src/client/subscriptions.js +128 -0
  133. package/dist/src/client/subscriptions.js.map +1 -0
  134. package/dist/src/client/utils.d.ts +12 -0
  135. package/dist/src/client/utils.js +61 -0
  136. package/dist/src/client/utils.js.map +1 -0
  137. package/dist/src/portal/index.d.ts +43 -0
  138. package/dist/src/portal/index.js +52 -0
  139. package/dist/src/portal/index.js.map +1 -0
  140. package/dist/src/react/context.d.ts +9 -0
  141. package/dist/src/react/context.js +16 -0
  142. package/dist/src/react/context.js.map +1 -0
  143. package/dist/src/zod/index.d.ts +6360 -0
  144. package/dist/src/zod/index.js +13615 -0
  145. package/dist/src/zod/index.js.map +1 -0
  146. package/dist/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +82 -40
  148. package/dist/clients/client.d.ts +0 -40
  149. package/dist/clients/client.js +0 -104
  150. package/dist/clients/event.d.ts +0 -79
  151. package/dist/clients/event.js +0 -53
  152. package/dist/clients/meter.d.ts +0 -71
  153. package/dist/clients/meter.js +0 -64
  154. package/dist/clients/portal.d.ts +0 -23
  155. package/dist/clients/portal.js +0 -37
  156. package/dist/next.d.ts +0 -15
  157. package/dist/next.js +0 -46
  158. package/dist/schemas/openapi.d.ts +0 -460
  159. package/dist/schemas/openapi.js +0 -5
  160. package/dist/test/agent.d.ts +0 -2
  161. package/dist/test/agent.js +0 -178
  162. package/dist/test/mocks.d.ts +0 -12
  163. package/dist/test/mocks.js +0 -32
  164. package/index.ts +0 -22
  165. package/next.ts +0 -76
@@ -0,0 +1,327 @@
1
+ import type { Client } from 'openapi-fetch';
2
+ import type { RequestOptions } from './common.cjs';
3
+ import type { AppReplaceUpdate, CreateStripeCheckoutSessionRequest, operations, paths } from './schemas.cjs';
4
+ /**
5
+ * Apps
6
+ * Manage integrations for extending OpenMeter's functionality.
7
+ */
8
+ export declare class Apps {
9
+ private client;
10
+ marketplace: AppMarketplace;
11
+ stripe: AppStripe;
12
+ customInvoicing: AppCustomInvoicing;
13
+ constructor(client: Client<paths, `${string}/${string}`>);
14
+ /**
15
+ * List apps
16
+ * @param query - The query parameters
17
+ * @param signal - An optional abort signal
18
+ * @returns The apps
19
+ */
20
+ list(query?: operations['listApps']['parameters']['query'], options?: RequestOptions): Promise<{
21
+ totalCount: number;
22
+ page: number;
23
+ pageSize: number;
24
+ items: import("./schemas.cjs").components["schemas"]["App"][];
25
+ } | undefined>;
26
+ /**
27
+ * Get an app
28
+ * @param id - The ID of the app
29
+ * @param signal - An optional abort signal
30
+ * @returns The app
31
+ */
32
+ get(id: operations['getApp']['parameters']['path']['id'], options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
33
+ 200: {
34
+ headers: {
35
+ [name: string]: unknown;
36
+ };
37
+ content: {
38
+ "application/json": import("./schemas.cjs").components["schemas"]["App"];
39
+ };
40
+ };
41
+ 400: {
42
+ headers: {
43
+ [name: string]: unknown;
44
+ };
45
+ content: {
46
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["BadRequestProblemResponse"];
47
+ };
48
+ };
49
+ 401: {
50
+ headers: {
51
+ [name: string]: unknown;
52
+ };
53
+ content: {
54
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["UnauthorizedProblemResponse"];
55
+ };
56
+ };
57
+ 403: {
58
+ headers: {
59
+ [name: string]: unknown;
60
+ };
61
+ content: {
62
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["ForbiddenProblemResponse"];
63
+ };
64
+ };
65
+ 404: {
66
+ headers: {
67
+ [name: string]: unknown;
68
+ };
69
+ content: {
70
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["NotFoundProblemResponse"];
71
+ };
72
+ };
73
+ 412: {
74
+ headers: {
75
+ [name: string]: unknown;
76
+ };
77
+ content: {
78
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["PreconditionFailedProblemResponse"];
79
+ };
80
+ };
81
+ 500: {
82
+ headers: {
83
+ [name: string]: unknown;
84
+ };
85
+ content: {
86
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["InternalServerErrorProblemResponse"];
87
+ };
88
+ };
89
+ 503: {
90
+ headers: {
91
+ [name: string]: unknown;
92
+ };
93
+ content: {
94
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["ServiceUnavailableProblemResponse"];
95
+ };
96
+ };
97
+ default: {
98
+ headers: {
99
+ [name: string]: unknown;
100
+ };
101
+ content: {
102
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["UnexpectedProblemResponse"];
103
+ };
104
+ };
105
+ }, `${string}/${string}`> | undefined>;
106
+ /**
107
+ * Update an app
108
+ * @param id - The ID of the app
109
+ * @param body - The body of the request
110
+ * @param signal - An optional abort signal
111
+ * @returns The app
112
+ */
113
+ update(id: operations['updateApp']['parameters']['path']['id'], body: AppReplaceUpdate, options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
114
+ 200: {
115
+ headers: {
116
+ [name: string]: unknown;
117
+ };
118
+ content: {
119
+ "application/json": import("./schemas.cjs").components["schemas"]["App"];
120
+ };
121
+ };
122
+ 400: {
123
+ headers: {
124
+ [name: string]: unknown;
125
+ };
126
+ content: {
127
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["BadRequestProblemResponse"];
128
+ };
129
+ };
130
+ 401: {
131
+ headers: {
132
+ [name: string]: unknown;
133
+ };
134
+ content: {
135
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["UnauthorizedProblemResponse"];
136
+ };
137
+ };
138
+ 403: {
139
+ headers: {
140
+ [name: string]: unknown;
141
+ };
142
+ content: {
143
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["ForbiddenProblemResponse"];
144
+ };
145
+ };
146
+ 404: {
147
+ headers: {
148
+ [name: string]: unknown;
149
+ };
150
+ content: {
151
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["NotFoundProblemResponse"];
152
+ };
153
+ };
154
+ 412: {
155
+ headers: {
156
+ [name: string]: unknown;
157
+ };
158
+ content: {
159
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["PreconditionFailedProblemResponse"];
160
+ };
161
+ };
162
+ 500: {
163
+ headers: {
164
+ [name: string]: unknown;
165
+ };
166
+ content: {
167
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["InternalServerErrorProblemResponse"];
168
+ };
169
+ };
170
+ 503: {
171
+ headers: {
172
+ [name: string]: unknown;
173
+ };
174
+ content: {
175
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["ServiceUnavailableProblemResponse"];
176
+ };
177
+ };
178
+ default: {
179
+ headers: {
180
+ [name: string]: unknown;
181
+ };
182
+ content: {
183
+ "application/problem+json": import("./schemas.cjs").components["schemas"]["UnexpectedProblemResponse"];
184
+ };
185
+ };
186
+ }, `${string}/${string}`> | undefined>;
187
+ /**
188
+ * Uninstall an app
189
+ * @param id - The ID of the app
190
+ * @param signal - An optional abort signal
191
+ * @returns The app
192
+ */
193
+ uninstall(id: operations['uninstallApp']['parameters']['path']['id'], options?: RequestOptions): Promise<undefined>;
194
+ }
195
+ /**
196
+ * App Marketplace
197
+ * Available apps from the OpenMeter Marketplace.
198
+ */
199
+ export declare class AppMarketplace {
200
+ private client;
201
+ constructor(client: Client<paths, `${string}/${string}`>);
202
+ /**
203
+ * List available apps
204
+ * @param query - The query parameters
205
+ * @param signal - An optional abort signal
206
+ * @returns The apps
207
+ */
208
+ list(query?: operations['listMarketplaceListings']['parameters']['query'], options?: RequestOptions): Promise<{
209
+ totalCount: number;
210
+ page: number;
211
+ pageSize: number;
212
+ items: import("./schemas.cjs").components["schemas"]["MarketplaceListing"][];
213
+ } | undefined>;
214
+ /**
215
+ * Get details for a listing
216
+ * @param type - The type of the listing
217
+ * @param signal - An optional abort signal
218
+ * @returns The listing
219
+ */
220
+ get(type: operations['getMarketplaceListing']['parameters']['path']['type'], options?: RequestOptions): Promise<{
221
+ type: import("./schemas.cjs").components["schemas"]["AppType"];
222
+ name: string;
223
+ description: string;
224
+ capabilities: import("./schemas.cjs").components["schemas"]["AppCapability"][];
225
+ installMethods: import("./schemas.cjs").components["schemas"]["InstallMethod"][];
226
+ } | undefined>;
227
+ /**
228
+ * Install an app via OAuth. Returns a URL to start the OAuth 2.0 flow.
229
+ * @param type - The type of the listing
230
+ * @param signal - An optional abort signal
231
+ * @returns The OAuth2 install URL
232
+ */
233
+ getOauth2InstallUrl(type: operations['marketplaceOAuth2InstallGetURL']['parameters']['path']['type'], options?: RequestOptions): Promise<{
234
+ url: string;
235
+ } | undefined>;
236
+ /**
237
+ * Authorize OAuth2 code. Verifies the OAuth code and exchanges it for a token and refresh token
238
+ * @param type - The type of the listing
239
+ * @param signal - An optional abort signal
240
+ * @returns The authorization URL
241
+ */
242
+ authorizeOauth2(type: operations['marketplaceOAuth2InstallAuthorize']['parameters']['path']['type'], options?: RequestOptions): Promise<undefined>;
243
+ /**
244
+ * Install an app via API key.
245
+ * @param type - The type of the listing
246
+ * @param signal - An optional abort signal
247
+ * @returns The installation
248
+ */
249
+ installWithAPIKey(type: operations['marketplaceAppAPIKeyInstall']['parameters']['path']['type'], body: operations['marketplaceAppAPIKeyInstall']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
250
+ app: import("./schemas.cjs").components["schemas"]["App"];
251
+ defaultForCapabilityTypes: import("./schemas.cjs").components["schemas"]["AppCapabilityType"][];
252
+ } | undefined>;
253
+ }
254
+ /**
255
+ * Stripe App
256
+ */
257
+ export declare class AppStripe {
258
+ private client;
259
+ constructor(client: Client<paths, `${string}/${string}`>);
260
+ /**
261
+ * Create a checkout session
262
+ * @param body - The body of the request
263
+ * @param signal - An optional abort signal
264
+ * @returns The checkout session
265
+ */
266
+ createCheckoutSession(body: CreateStripeCheckoutSessionRequest, options?: RequestOptions): Promise<{
267
+ customerId: string;
268
+ stripeCustomerId: string;
269
+ sessionId: string;
270
+ setupIntentId: string;
271
+ clientSecret?: string;
272
+ clientReferenceId?: string;
273
+ customerEmail?: string;
274
+ currency?: import("./schemas.cjs").components["schemas"]["CurrencyCode"];
275
+ createdAt: Date;
276
+ expiresAt?: Date;
277
+ metadata?: {
278
+ [key: string]: string;
279
+ };
280
+ status?: string;
281
+ url?: string;
282
+ mode: import("./schemas.cjs").components["schemas"]["StripeCheckoutSessionMode"];
283
+ cancelURL?: string;
284
+ successURL?: string;
285
+ returnURL?: string;
286
+ } | undefined>;
287
+ /**
288
+ * Update Stripe API key
289
+ * @param id - The ID of the app
290
+ * @param body - The API key data
291
+ * @param options - The request options
292
+ * @returns The updated API key
293
+ * @deprecated
294
+ */
295
+ updateApiKey(id: string, body: operations['updateStripeAPIKey']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<undefined>;
296
+ }
297
+ /**
298
+ * Custom Invoicing App
299
+ */
300
+ export declare class AppCustomInvoicing {
301
+ private client;
302
+ constructor(client: Client<paths, `${string}/${string}`>);
303
+ /**
304
+ * Submit draft synchronization results
305
+ * @param invoiceId - The ID of the invoice
306
+ * @param body - The body of the request
307
+ * @param options - The request options
308
+ * @returns The synchronization result
309
+ */
310
+ draftSynchronized(invoiceId: string, body: operations['appCustomInvoicingDraftSynchronized']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<undefined>;
311
+ /**
312
+ * Submit issuing synchronization results
313
+ * @param invoiceId - The ID of the invoice
314
+ * @param body - The body of the request
315
+ * @param options - The request options
316
+ * @returns The synchronization result
317
+ */
318
+ issuingSynchronized(invoiceId: string, body: operations['appCustomInvoicingIssuingSynchronized']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<undefined>;
319
+ /**
320
+ * Update payment status
321
+ * @param invoiceId - The ID of the invoice
322
+ * @param body - The body of the request
323
+ * @param options - The request options
324
+ * @returns The payment status update result
325
+ */
326
+ updatePaymentStatus(invoiceId: string, body: operations['appCustomInvoicingUpdatePaymentStatus']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<undefined>;
327
+ }
@@ -0,0 +1,375 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingCustomers = exports.BillingInvoices = exports.BillingProfiles = exports.Billing = void 0;
4
+ const utils_js_1 = require("./utils.cjs");
5
+ /**
6
+ * Billing
7
+ */
8
+ class Billing {
9
+ client;
10
+ profiles;
11
+ invoices;
12
+ customers;
13
+ constructor(client) {
14
+ this.client = client;
15
+ this.profiles = new BillingProfiles(this.client);
16
+ this.invoices = new BillingInvoices(this.client);
17
+ this.customers = new BillingCustomers(this.client);
18
+ }
19
+ }
20
+ exports.Billing = Billing;
21
+ /**
22
+ * Billing Profiles
23
+ */
24
+ class BillingProfiles {
25
+ client;
26
+ constructor(client) {
27
+ this.client = client;
28
+ }
29
+ /**
30
+ * Create a billing profile
31
+ * @param billingProfile - The billing profile to create
32
+ * @param signal - An optional abort signal
33
+ * @returns The created billing profile
34
+ */
35
+ async create(billingProfile, options) {
36
+ const resp = await this.client.POST('/api/v1/billing/profiles', {
37
+ body: billingProfile,
38
+ ...options,
39
+ });
40
+ return (0, utils_js_1.transformResponse)(resp);
41
+ }
42
+ /**
43
+ * Get a billing profile by ID
44
+ * @param id - The ID of the billing profile to get
45
+ * @param signal - An optional abort signal
46
+ * @returns The billing profile
47
+ */
48
+ async get(id, options) {
49
+ const resp = await this.client.GET('/api/v1/billing/profiles/{id}', {
50
+ params: {
51
+ path: { id },
52
+ },
53
+ ...options,
54
+ });
55
+ return (0, utils_js_1.transformResponse)(resp);
56
+ }
57
+ /**
58
+ * List billing profiles
59
+ * @param query - The query parameters
60
+ * @param signal - An optional abort signal
61
+ * @returns The billing profiles
62
+ */
63
+ async list(query, options) {
64
+ const resp = await this.client.GET('/api/v1/billing/profiles', {
65
+ params: {
66
+ query,
67
+ },
68
+ ...options,
69
+ });
70
+ return (0, utils_js_1.transformResponse)(resp);
71
+ }
72
+ /**
73
+ * Update a billing profile
74
+ * @param id - The ID of the billing profile to update
75
+ * @param billingProfile - The billing profile to update
76
+ * @param signal - An optional abort signal
77
+ * @returns The updated billing profile
78
+ */
79
+ async update(id, billingProfile, options) {
80
+ const resp = await this.client.PUT('/api/v1/billing/profiles/{id}', {
81
+ body: billingProfile,
82
+ params: {
83
+ path: { id },
84
+ },
85
+ ...options,
86
+ });
87
+ return (0, utils_js_1.transformResponse)(resp);
88
+ }
89
+ /**
90
+ * Delete a billing profile
91
+ * @param id - The ID of the billing profile to delete
92
+ * @param options - The request options
93
+ * @returns The deleted billing profile
94
+ */
95
+ async delete(id, options) {
96
+ const resp = await this.client.DELETE('/api/v1/billing/profiles/{id}', {
97
+ params: {
98
+ path: { id },
99
+ },
100
+ ...options,
101
+ });
102
+ return (0, utils_js_1.transformResponse)(resp);
103
+ }
104
+ }
105
+ exports.BillingProfiles = BillingProfiles;
106
+ /**
107
+ * Billing Invoices
108
+ */
109
+ class BillingInvoices {
110
+ client;
111
+ constructor(client) {
112
+ this.client = client;
113
+ }
114
+ /**
115
+ * List invoices
116
+ * @param query - The query parameters
117
+ * @param signal - An optional abort signal
118
+ * @returns The invoices
119
+ */
120
+ async list(query, options) {
121
+ const resp = await this.client.GET('/api/v1/billing/invoices', {
122
+ params: {
123
+ query,
124
+ },
125
+ ...options,
126
+ });
127
+ return (0, utils_js_1.transformResponse)(resp);
128
+ }
129
+ /**
130
+ * Get an invoice by ID
131
+ * @param id - The ID of the invoice to get
132
+ * @param signal - An optional abort signal
133
+ * @returns The invoice
134
+ */
135
+ async get(id, options) {
136
+ const resp = await this.client.GET('/api/v1/billing/invoices/{invoiceId}', {
137
+ params: {
138
+ path: { invoiceId: id },
139
+ },
140
+ ...options,
141
+ });
142
+ return (0, utils_js_1.transformResponse)(resp);
143
+ }
144
+ /**
145
+ * Update an invoice
146
+ * @description Only invoices in draft or earlier status can be updated.
147
+ * @param id - The ID of the invoice to update
148
+ * @param invoice - The invoice to update
149
+ * @param signal - An optional abort signal
150
+ * @returns The updated invoice
151
+ */
152
+ async update(id, invoice, options) {
153
+ const resp = await this.client.PUT('/api/v1/billing/invoices/{invoiceId}', {
154
+ body: invoice,
155
+ params: { path: { invoiceId: id } },
156
+ ...options,
157
+ });
158
+ return (0, utils_js_1.transformResponse)(resp);
159
+ }
160
+ /**
161
+ * Delete an invoice
162
+ * @description Only invoices that are in the draft (or earlier) status can be deleted.
163
+ * @param id - The ID of the invoice to delete
164
+ * @param options - The request options
165
+ * @returns The deleted invoice
166
+ */
167
+ async delete(id, options) {
168
+ const resp = await this.client.DELETE('/api/v1/billing/invoices/{invoiceId}', {
169
+ params: { path: { invoiceId: id } },
170
+ ...options,
171
+ });
172
+ return (0, utils_js_1.transformResponse)(resp);
173
+ }
174
+ /**
175
+ * Advance the invoice to the next status
176
+ * @description The call doesn't "approve the invoice", it only advances the invoice to the next status if the transition would be automatic. The action can be called when the invoice's statusDetails' actions field contain the "advance" action.
177
+ * @param id - The ID of the invoice to advance
178
+ * @param signal - An optional abort signal
179
+ * @returns The advanced invoice
180
+ */
181
+ async advance(id, options) {
182
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/advance', {
183
+ params: { path: { invoiceId: id } },
184
+ ...options,
185
+ });
186
+ return (0, utils_js_1.transformResponse)(resp);
187
+ }
188
+ /**
189
+ * Approve an invoice
190
+ * @description This call instantly sends the invoice to the customer using the configured billing profile app.
191
+ * @param id - The ID of the invoice to approve
192
+ * @param signal - An optional abort signal
193
+ * @returns The approved invoice
194
+ */
195
+ async approve(id, options) {
196
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/approve', {
197
+ params: { path: { invoiceId: id } },
198
+ ...options,
199
+ });
200
+ return (0, utils_js_1.transformResponse)(resp);
201
+ }
202
+ /**
203
+ * Retry advancing the invoice after a failed attempt.
204
+ * @param id - The ID of the invoice to retry
205
+ * @param signal - An optional abort signal
206
+ * @returns The retried invoice
207
+ */
208
+ async retry(id, options) {
209
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/retry', {
210
+ params: { path: { invoiceId: id } },
211
+ ...options,
212
+ });
213
+ return (0, utils_js_1.transformResponse)(resp);
214
+ }
215
+ /**
216
+ * Void an invoice
217
+ * @description Void an invoice
218
+ *
219
+ * Only invoices that have been alread issued can be voided.
220
+ * @param id - The ID of the invoice to void
221
+ * @param signal - An optional abort signal
222
+ * @returns The voided invoice
223
+ */
224
+ async void(id, body, options) {
225
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/void', {
226
+ body,
227
+ params: { path: { invoiceId: id } },
228
+ ...options,
229
+ });
230
+ return (0, utils_js_1.transformResponse)(resp);
231
+ }
232
+ /**
233
+ * Recalculate an invoice's tax amounts
234
+ * @param id - The ID of the invoice to recalculate
235
+ * @param signal - An optional abort signal
236
+ * @returns The recalculated invoice
237
+ */
238
+ async recalculateTax(id, options) {
239
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/taxes/recalculate', {
240
+ params: { path: { invoiceId: id } },
241
+ ...options,
242
+ });
243
+ return (0, utils_js_1.transformResponse)(resp);
244
+ }
245
+ /**
246
+ * Snapshot invoice line item quantities
247
+ * @description Snapshot the quantities of the invoice line items. This is useful for invoices that have usage-based line items.
248
+ * @param id - The ID of the invoice to snapshot
249
+ * @param signal - An optional abort signal
250
+ * @returns The invoice with snapshotted quantities
251
+ */
252
+ async snapshotQuantities(id, options) {
253
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/snapshot-quantities', {
254
+ params: { path: { invoiceId: id } },
255
+ ...options,
256
+ });
257
+ return (0, utils_js_1.transformResponse)(resp);
258
+ }
259
+ /**
260
+ * Simulate an invoice for a customer
261
+ * @param id - The ID of the customer to simulate the invoice for
262
+ * @param signal - An optional abort signal
263
+ * @returns The simulated invoice
264
+ */
265
+ async simulate(id, body, options) {
266
+ const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/simulate', {
267
+ body,
268
+ params: { path: { customerId: id } },
269
+ ...options,
270
+ });
271
+ return (0, utils_js_1.transformResponse)(resp);
272
+ }
273
+ /**
274
+ * Create pending line items
275
+ * @description Create new pending line items (charges).
276
+ * This call is used to create a new pending line item for the customer if required a new
277
+ * gathering invoice will be created.
278
+ *
279
+ * A new invoice will be created if:
280
+ * - there is no invoice in gathering state
281
+ * - the currency of the line item doesn't match the currency of any invoices in gathering state
282
+ * @param customerId - The ID of the customer to create the line items for
283
+ * @param body - The line items to create
284
+ * @param signal - An optional abort signal
285
+ * @returns The created line items
286
+ */
287
+ async createLineItems(customerId, body, options) {
288
+ const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/pending-lines', {
289
+ body,
290
+ params: { path: { customerId } },
291
+ ...options,
292
+ });
293
+ return (0, utils_js_1.transformResponse)(resp);
294
+ }
295
+ /**
296
+ * Invoice a customer based on the pending line items
297
+ * @description Create a new invoice from the pending line items. This should only be called if for some reason we need to invoice a customer outside of the normal billing cycle.
298
+ * @param body - The invoice data
299
+ * @param options - The request options
300
+ * @returns The created invoices
301
+ */
302
+ async invoicePendingLines(body, options) {
303
+ const resp = await this.client.POST('/api/v1/billing/invoices/invoice', {
304
+ body,
305
+ ...options,
306
+ });
307
+ return (0, utils_js_1.transformResponse)(resp);
308
+ }
309
+ }
310
+ exports.BillingInvoices = BillingInvoices;
311
+ /**
312
+ * Billing Customer Invoices and Overrides
313
+ */
314
+ class BillingCustomers {
315
+ client;
316
+ constructor(client) {
317
+ this.client = client;
318
+ }
319
+ /**
320
+ * Create or update a customer override
321
+ * @param id - The ID of the customer to create the override for
322
+ * @param body - The customer override to create
323
+ * @param signal - An optional abort signal
324
+ * @returns The created customer override
325
+ */
326
+ async createOverride(id, body, options) {
327
+ const resp = await this.client.PUT('/api/v1/billing/customers/{customerId}', {
328
+ body,
329
+ params: { path: { customerId: id } },
330
+ ...options,
331
+ });
332
+ return (0, utils_js_1.transformResponse)(resp);
333
+ }
334
+ /**
335
+ * Get a customer override
336
+ * @param id - The ID of the customer to get the override for
337
+ * @param signal - An optional abort signal
338
+ * @returns The customer override
339
+ */
340
+ async getOverride(id, options) {
341
+ const resp = await this.client.GET('/api/v1/billing/customers/{customerId}', {
342
+ params: { path: { customerId: id } },
343
+ ...options,
344
+ });
345
+ return (0, utils_js_1.transformResponse)(resp);
346
+ }
347
+ /**
348
+ * List customer overrides
349
+ * @param query - The query parameters
350
+ * @param signal - An optional abort signal
351
+ * @returns The customer overrides
352
+ */
353
+ async listOverrides(query, options) {
354
+ const resp = await this.client.GET('/api/v1/billing/customers', {
355
+ params: { query },
356
+ ...options,
357
+ });
358
+ return (0, utils_js_1.transformResponse)(resp);
359
+ }
360
+ /**
361
+ * Delete a customer override
362
+ * @param id - The ID of the customer to delete the override for
363
+ * @param signal - An optional abort signal
364
+ * @returns The deleted customer override
365
+ */
366
+ async deleteOverride(id, options) {
367
+ const resp = await this.client.DELETE('/api/v1/billing/customers/{customerId}', {
368
+ params: { path: { customerId: id } },
369
+ ...options,
370
+ });
371
+ return (0, utils_js_1.transformResponse)(resp);
372
+ }
373
+ }
374
+ exports.BillingCustomers = BillingCustomers;
375
+ //# sourceMappingURL=billing.cjs.map