@openmeter/client 1.0.0-beta.230 → 1.0.0-beta.232

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 (137) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +365 -76
  3. package/dist/core.d.ts +0 -1
  4. package/dist/core.js +11 -1
  5. package/dist/funcs/addons.d.ts +49 -1
  6. package/dist/funcs/addons.js +109 -12
  7. package/dist/funcs/apps.d.ts +55 -2
  8. package/dist/funcs/apps.js +179 -4
  9. package/dist/funcs/billing.d.ts +46 -1
  10. package/dist/funcs/billing.js +81 -8
  11. package/dist/funcs/currencies.d.ts +39 -2
  12. package/dist/funcs/currencies.js +93 -6
  13. package/dist/funcs/customers.d.ts +165 -2
  14. package/dist/funcs/customers.js +402 -40
  15. package/dist/funcs/defaults.d.ts +10 -1
  16. package/dist/funcs/defaults.js +11 -1
  17. package/dist/funcs/entitlements.d.ts +5 -1
  18. package/dist/funcs/entitlements.js +18 -4
  19. package/dist/funcs/events.d.ts +14 -1
  20. package/dist/funcs/events.js +18 -1
  21. package/dist/funcs/features.d.ts +42 -1
  22. package/dist/funcs/features.js +91 -10
  23. package/dist/funcs/governance.d.ts +14 -1
  24. package/dist/funcs/governance.js +15 -1
  25. package/dist/funcs/index.d.ts +0 -1
  26. package/dist/funcs/index.js +1 -1
  27. package/dist/funcs/invoices.d.ts +102 -2
  28. package/dist/funcs/invoices.js +247 -8
  29. package/dist/funcs/llmCost.d.ts +36 -1
  30. package/dist/funcs/llmCost.js +63 -6
  31. package/dist/funcs/meters.d.ts +53 -1
  32. package/dist/funcs/meters.js +113 -12
  33. package/dist/funcs/planAddons.d.ts +35 -1
  34. package/dist/funcs/planAddons.js +101 -18
  35. package/dist/funcs/plans.d.ts +49 -1
  36. package/dist/funcs/plans.js +109 -12
  37. package/dist/funcs/subscriptions.d.ts +59 -1
  38. package/dist/funcs/subscriptions.js +147 -18
  39. package/dist/funcs/tax.d.ts +25 -1
  40. package/dist/funcs/tax.js +60 -8
  41. package/dist/index.d.ts +4 -7
  42. package/dist/index.js +4 -6
  43. package/dist/lib/config.d.ts +2 -3
  44. package/dist/lib/config.js +1 -1
  45. package/dist/lib/encodings.d.ts +0 -1
  46. package/dist/lib/encodings.js +1 -1
  47. package/dist/lib/paginate.d.ts +56 -0
  48. package/dist/lib/paginate.js +60 -0
  49. package/dist/lib/request.d.ts +0 -1
  50. package/dist/lib/request.js +1 -1
  51. package/dist/lib/to-error.d.ts +0 -1
  52. package/dist/lib/to-error.js +1 -1
  53. package/dist/lib/types.d.ts +0 -1
  54. package/dist/lib/types.js +1 -1
  55. package/dist/lib/version.d.ts +1 -0
  56. package/dist/lib/version.js +5 -0
  57. package/dist/lib/wire.d.ts +4 -1
  58. package/dist/lib/wire.js +118 -7
  59. package/dist/models/errors.d.ts +13 -2
  60. package/dist/models/errors.js +31 -4
  61. package/dist/models/operations/addons.d.ts +0 -1
  62. package/dist/models/operations/addons.js +1 -1
  63. package/dist/models/operations/apps.d.ts +26 -5
  64. package/dist/models/operations/apps.js +1 -1
  65. package/dist/models/operations/billing.d.ts +0 -1
  66. package/dist/models/operations/billing.js +1 -1
  67. package/dist/models/operations/currencies.d.ts +10 -1
  68. package/dist/models/operations/currencies.js +1 -1
  69. package/dist/models/operations/customers.d.ts +11 -7
  70. package/dist/models/operations/customers.js +1 -1
  71. package/dist/models/operations/defaults.d.ts +0 -1
  72. package/dist/models/operations/defaults.js +1 -1
  73. package/dist/models/operations/entitlements.d.ts +0 -1
  74. package/dist/models/operations/entitlements.js +1 -1
  75. package/dist/models/operations/events.d.ts +0 -1
  76. package/dist/models/operations/events.js +1 -1
  77. package/dist/models/operations/features.d.ts +0 -1
  78. package/dist/models/operations/features.js +1 -1
  79. package/dist/models/operations/governance.d.ts +0 -1
  80. package/dist/models/operations/governance.js +1 -1
  81. package/dist/models/operations/invoices.d.ts +20 -7
  82. package/dist/models/operations/invoices.js +1 -1
  83. package/dist/models/operations/llmCost.d.ts +0 -1
  84. package/dist/models/operations/llmCost.js +1 -1
  85. package/dist/models/operations/meters.d.ts +0 -1
  86. package/dist/models/operations/meters.js +1 -1
  87. package/dist/models/operations/planAddons.d.ts +0 -1
  88. package/dist/models/operations/planAddons.js +1 -1
  89. package/dist/models/operations/plans.d.ts +0 -1
  90. package/dist/models/operations/plans.js +1 -1
  91. package/dist/models/operations/subscriptions.d.ts +0 -1
  92. package/dist/models/operations/subscriptions.js +1 -1
  93. package/dist/models/operations/tax.d.ts +0 -1
  94. package/dist/models/operations/tax.js +1 -1
  95. package/dist/models/schemas.d.ts +11651 -6090
  96. package/dist/models/schemas.js +991 -468
  97. package/dist/models/types.d.ts +941 -810
  98. package/dist/models/types.js +1 -1
  99. package/dist/sdk/addons.d.ts +60 -1
  100. package/dist/sdk/addons.js +63 -1
  101. package/dist/sdk/apps.d.ts +68 -2
  102. package/dist/sdk/apps.js +81 -2
  103. package/dist/sdk/billing.d.ts +57 -1
  104. package/dist/sdk/billing.js +60 -1
  105. package/dist/sdk/customers.d.ts +211 -2
  106. package/dist/sdk/customers.js +222 -2
  107. package/dist/sdk/defaults.d.ts +10 -1
  108. package/dist/sdk/defaults.js +11 -1
  109. package/dist/sdk/entitlements.d.ts +5 -1
  110. package/dist/sdk/entitlements.js +6 -1
  111. package/dist/sdk/events.d.ts +25 -1
  112. package/dist/sdk/events.js +28 -1
  113. package/dist/sdk/features.d.ts +53 -1
  114. package/dist/sdk/features.js +56 -1
  115. package/dist/sdk/internal.d.ts +328 -0
  116. package/dist/sdk/internal.js +404 -0
  117. package/dist/sdk/invoices.d.ts +5 -2
  118. package/dist/sdk/invoices.js +13 -2
  119. package/dist/sdk/llmCost.d.ts +57 -1
  120. package/dist/sdk/llmCost.js +62 -1
  121. package/dist/sdk/meters.d.ts +64 -1
  122. package/dist/sdk/meters.js +67 -1
  123. package/dist/sdk/planAddons.d.ts +46 -1
  124. package/dist/sdk/planAddons.js +49 -1
  125. package/dist/sdk/plans.d.ts +60 -1
  126. package/dist/sdk/plans.js +63 -1
  127. package/dist/sdk/sdk.d.ts +9 -13
  128. package/dist/sdk/sdk.js +11 -20
  129. package/dist/sdk/subscriptions.d.ts +72 -3
  130. package/dist/sdk/subscriptions.js +77 -5
  131. package/dist/sdk/tax.d.ts +34 -1
  132. package/dist/sdk/tax.js +37 -1
  133. package/package.json +30 -6
  134. package/dist/sdk/currencies.d.ts +0 -12
  135. package/dist/sdk/currencies.js +0 -21
  136. package/dist/sdk/governance.d.ts +0 -9
  137. package/dist/sdk/governance.js +0 -12
@@ -1,8 +1,14 @@
1
+ // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
1
2
  import { http } from '../core.js';
2
3
  import { request } from '../lib/request.js';
3
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
4
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
5
6
  import * as schemas from '../models/schemas.js';
7
+ /**
8
+ * Create customer
9
+ *
10
+ * POST /openmeter/customers
11
+ */
6
12
  export function createCustomer(client, req, options) {
7
13
  return request(() => {
8
14
  const body = toWire(req, schemas.createCustomerBody);
@@ -20,13 +26,27 @@ export function createCustomer(client, req, options) {
20
26
  });
21
27
  });
22
28
  }
29
+ /**
30
+ * Get customer
31
+ *
32
+ * GET /openmeter/customers/{customerId}
33
+ */
23
34
  export function getCustomer(client, req, options) {
24
35
  return request(() => {
36
+ const pathParamsInput = {
37
+ customerId: req.customerId,
38
+ };
39
+ const pathParams = client._options.validate
40
+ ? toPathWire(pathParamsInput, schemas.getCustomerPathParams)
41
+ : pathParamsInput;
42
+ if (client._options.validate) {
43
+ assertValid(schemas.getCustomerPathParamsWire, pathParams);
44
+ }
25
45
  const path = `openmeter/customers/${(() => {
26
- if (req.customerId === undefined) {
46
+ if (pathParams.customerId === undefined) {
27
47
  throw new Error('missing path parameter: customerId');
28
48
  }
29
- return encodeURIComponent(String(req.customerId));
49
+ return encodeURIComponent(String(pathParams.customerId));
30
50
  })()}`;
31
51
  return http(client)
32
52
  .get(path, options)
@@ -39,8 +59,16 @@ export function getCustomer(client, req, options) {
39
59
  });
40
60
  });
41
61
  }
62
+ /**
63
+ * List customers
64
+ *
65
+ * GET /openmeter/customers
66
+ */
42
67
  export function listCustomers(client, req = {}, options) {
43
68
  return request(() => {
69
+ if (client._options.validate && req.sort !== undefined) {
70
+ assertValid(schemas.listCustomersQueryParams.shape.sort, req.sort);
71
+ }
44
72
  const query = toWire({
45
73
  page: req.page,
46
74
  sort: encodeSort(req.sort, toSnakeCase),
@@ -61,13 +89,27 @@ export function listCustomers(client, req = {}, options) {
61
89
  });
62
90
  });
63
91
  }
92
+ /**
93
+ * Upsert customer
94
+ *
95
+ * PUT /openmeter/customers/{customerId}
96
+ */
64
97
  export function upsertCustomer(client, req, options) {
65
98
  return request(() => {
99
+ const pathParamsInput = {
100
+ customerId: req.customerId,
101
+ };
102
+ const pathParams = client._options.validate
103
+ ? toPathWire(pathParamsInput, schemas.upsertCustomerPathParams)
104
+ : pathParamsInput;
105
+ if (client._options.validate) {
106
+ assertValid(schemas.upsertCustomerPathParamsWire, pathParams);
107
+ }
66
108
  const path = `openmeter/customers/${(() => {
67
- if (req.customerId === undefined) {
109
+ if (pathParams.customerId === undefined) {
68
110
  throw new Error('missing path parameter: customerId');
69
111
  }
70
- return encodeURIComponent(String(req.customerId));
112
+ return encodeURIComponent(String(pathParams.customerId));
71
113
  })()}`;
72
114
  const body = toWire(req.body, schemas.upsertCustomerBody);
73
115
  if (client._options.validate) {
@@ -84,24 +126,52 @@ export function upsertCustomer(client, req, options) {
84
126
  });
85
127
  });
86
128
  }
129
+ /**
130
+ * Delete customer
131
+ *
132
+ * DELETE /openmeter/customers/{customerId}
133
+ */
87
134
  export function deleteCustomer(client, req, options) {
88
135
  return request(async () => {
136
+ const pathParamsInput = {
137
+ customerId: req.customerId,
138
+ };
139
+ const pathParams = client._options.validate
140
+ ? toPathWire(pathParamsInput, schemas.deleteCustomerPathParams)
141
+ : pathParamsInput;
142
+ if (client._options.validate) {
143
+ assertValid(schemas.deleteCustomerPathParamsWire, pathParams);
144
+ }
89
145
  const path = `openmeter/customers/${(() => {
90
- if (req.customerId === undefined) {
146
+ if (pathParams.customerId === undefined) {
91
147
  throw new Error('missing path parameter: customerId');
92
148
  }
93
- return encodeURIComponent(String(req.customerId));
149
+ return encodeURIComponent(String(pathParams.customerId));
94
150
  })()}`;
95
151
  await http(client).delete(path, options);
96
152
  });
97
153
  }
154
+ /**
155
+ * Get customer billing data
156
+ *
157
+ * GET /openmeter/customers/{customerId}/billing
158
+ */
98
159
  export function getCustomerBilling(client, req, options) {
99
160
  return request(() => {
161
+ const pathParamsInput = {
162
+ customerId: req.customerId,
163
+ };
164
+ const pathParams = client._options.validate
165
+ ? toPathWire(pathParamsInput, schemas.getCustomerBillingPathParams)
166
+ : pathParamsInput;
167
+ if (client._options.validate) {
168
+ assertValid(schemas.getCustomerBillingPathParamsWire, pathParams);
169
+ }
100
170
  const path = `openmeter/customers/${(() => {
101
- if (req.customerId === undefined) {
171
+ if (pathParams.customerId === undefined) {
102
172
  throw new Error('missing path parameter: customerId');
103
173
  }
104
- return encodeURIComponent(String(req.customerId));
174
+ return encodeURIComponent(String(pathParams.customerId));
105
175
  })()}/billing`;
106
176
  return http(client)
107
177
  .get(path, options)
@@ -114,13 +184,27 @@ export function getCustomerBilling(client, req, options) {
114
184
  });
115
185
  });
116
186
  }
187
+ /**
188
+ * Update customer billing data
189
+ *
190
+ * PUT /openmeter/customers/{customerId}/billing
191
+ */
117
192
  export function updateCustomerBilling(client, req, options) {
118
193
  return request(() => {
194
+ const pathParamsInput = {
195
+ customerId: req.customerId,
196
+ };
197
+ const pathParams = client._options.validate
198
+ ? toPathWire(pathParamsInput, schemas.updateCustomerBillingPathParams)
199
+ : pathParamsInput;
200
+ if (client._options.validate) {
201
+ assertValid(schemas.updateCustomerBillingPathParamsWire, pathParams);
202
+ }
119
203
  const path = `openmeter/customers/${(() => {
120
- if (req.customerId === undefined) {
204
+ if (pathParams.customerId === undefined) {
121
205
  throw new Error('missing path parameter: customerId');
122
206
  }
123
- return encodeURIComponent(String(req.customerId));
207
+ return encodeURIComponent(String(pathParams.customerId));
124
208
  })()}/billing`;
125
209
  const body = toWire(req.body, schemas.updateCustomerBillingBody);
126
210
  if (client._options.validate) {
@@ -137,13 +221,27 @@ export function updateCustomerBilling(client, req, options) {
137
221
  });
138
222
  });
139
223
  }
224
+ /**
225
+ * Update customer billing app data
226
+ *
227
+ * PUT /openmeter/customers/{customerId}/billing/app-data
228
+ */
140
229
  export function updateCustomerBillingAppData(client, req, options) {
141
230
  return request(() => {
231
+ const pathParamsInput = {
232
+ customerId: req.customerId,
233
+ };
234
+ const pathParams = client._options.validate
235
+ ? toPathWire(pathParamsInput, schemas.updateCustomerBillingAppDataPathParams)
236
+ : pathParamsInput;
237
+ if (client._options.validate) {
238
+ assertValid(schemas.updateCustomerBillingAppDataPathParamsWire, pathParams);
239
+ }
142
240
  const path = `openmeter/customers/${(() => {
143
- if (req.customerId === undefined) {
241
+ if (pathParams.customerId === undefined) {
144
242
  throw new Error('missing path parameter: customerId');
145
243
  }
146
- return encodeURIComponent(String(req.customerId));
244
+ return encodeURIComponent(String(pathParams.customerId));
147
245
  })()}/billing/app-data`;
148
246
  const body = toWire(req.body, schemas.updateCustomerBillingAppDataBody);
149
247
  if (client._options.validate) {
@@ -160,13 +258,39 @@ export function updateCustomerBillingAppData(client, req, options) {
160
258
  });
161
259
  });
162
260
  }
261
+ /**
262
+ * Create Stripe Checkout Session
263
+ *
264
+ * Create a [Stripe Checkout Session](https://docs.stripe.com/payments/checkout)
265
+ * for the customer.
266
+ *
267
+ * Creates a Checkout Session for collecting payment method information from
268
+ * customers. The session operates in "setup" mode, which collects payment details
269
+ * without charging the customer immediately. The collected payment method can be
270
+ * used for future subscription billing.
271
+ *
272
+ * For hosted checkout sessions, redirect customers to the returned URL. For
273
+ * embedded sessions, use the client_secret to initialize Stripe.js in your
274
+ * application.
275
+ *
276
+ * POST /openmeter/customers/{customerId}/billing/stripe/checkout-sessions
277
+ */
163
278
  export function createCustomerStripeCheckoutSession(client, req, options) {
164
279
  return request(() => {
280
+ const pathParamsInput = {
281
+ customerId: req.customerId,
282
+ };
283
+ const pathParams = client._options.validate
284
+ ? toPathWire(pathParamsInput, schemas.createCustomerStripeCheckoutSessionPathParams)
285
+ : pathParamsInput;
286
+ if (client._options.validate) {
287
+ assertValid(schemas.createCustomerStripeCheckoutSessionPathParamsWire, pathParams);
288
+ }
165
289
  const path = `openmeter/customers/${(() => {
166
- if (req.customerId === undefined) {
290
+ if (pathParams.customerId === undefined) {
167
291
  throw new Error('missing path parameter: customerId');
168
292
  }
169
- return encodeURIComponent(String(req.customerId));
293
+ return encodeURIComponent(String(pathParams.customerId));
170
294
  })()}/billing/stripe/checkout-sessions`;
171
295
  const body = toWire(req.body, schemas.createCustomerStripeCheckoutSessionBody);
172
296
  if (client._options.validate) {
@@ -183,13 +307,34 @@ export function createCustomerStripeCheckoutSession(client, req, options) {
183
307
  });
184
308
  });
185
309
  }
310
+ /**
311
+ * Create Stripe customer portal session
312
+ *
313
+ * Create Stripe Customer Portal Session.
314
+ *
315
+ * Useful to redirect the customer to the Stripe Customer Portal to manage their
316
+ * payment methods, change their billing address and access their invoice history.
317
+ * Only returns URL if the customer billing profile is linked to a stripe app and
318
+ * customer.
319
+ *
320
+ * POST /openmeter/customers/{customerId}/billing/stripe/portal-sessions
321
+ */
186
322
  export function createCustomerStripePortalSession(client, req, options) {
187
323
  return request(() => {
324
+ const pathParamsInput = {
325
+ customerId: req.customerId,
326
+ };
327
+ const pathParams = client._options.validate
328
+ ? toPathWire(pathParamsInput, schemas.createCustomerStripePortalSessionPathParams)
329
+ : pathParamsInput;
330
+ if (client._options.validate) {
331
+ assertValid(schemas.createCustomerStripePortalSessionPathParamsWire, pathParams);
332
+ }
188
333
  const path = `openmeter/customers/${(() => {
189
- if (req.customerId === undefined) {
334
+ if (pathParams.customerId === undefined) {
190
335
  throw new Error('missing path parameter: customerId');
191
336
  }
192
- return encodeURIComponent(String(req.customerId));
337
+ return encodeURIComponent(String(pathParams.customerId));
193
338
  })()}/billing/stripe/portal-sessions`;
194
339
  const body = toWire(req.body, schemas.createCustomerStripePortalSessionBody);
195
340
  if (client._options.validate) {
@@ -206,13 +351,30 @@ export function createCustomerStripePortalSession(client, req, options) {
206
351
  });
207
352
  });
208
353
  }
354
+ /**
355
+ * Create a new credit grant
356
+ *
357
+ * Create a new credit grant. A credit grant represents an allocation of prepaid
358
+ * credits to a customer.
359
+ *
360
+ * POST /openmeter/customers/{customerId}/credits/grants
361
+ */
209
362
  export function createCreditGrant(client, req, options) {
210
363
  return request(() => {
364
+ const pathParamsInput = {
365
+ customerId: req.customerId,
366
+ };
367
+ const pathParams = client._options.validate
368
+ ? toPathWire(pathParamsInput, schemas.createCreditGrantPathParams)
369
+ : pathParamsInput;
370
+ if (client._options.validate) {
371
+ assertValid(schemas.createCreditGrantPathParamsWire, pathParams);
372
+ }
211
373
  const path = `openmeter/customers/${(() => {
212
- if (req.customerId === undefined) {
374
+ if (pathParams.customerId === undefined) {
213
375
  throw new Error('missing path parameter: customerId');
214
376
  }
215
- return encodeURIComponent(String(req.customerId));
377
+ return encodeURIComponent(String(pathParams.customerId));
216
378
  })()}/credits/grants`;
217
379
  const body = toWire(req.body, schemas.createCreditGrantBody);
218
380
  if (client._options.validate) {
@@ -229,18 +391,35 @@ export function createCreditGrant(client, req, options) {
229
391
  });
230
392
  });
231
393
  }
394
+ /**
395
+ * Get a credit grant
396
+ *
397
+ * Get a credit grant.
398
+ *
399
+ * GET /openmeter/customers/{customerId}/credits/grants/{creditGrantId}
400
+ */
232
401
  export function getCreditGrant(client, req, options) {
233
402
  return request(() => {
403
+ const pathParamsInput = {
404
+ customerId: req.customerId,
405
+ creditGrantId: req.creditGrantId,
406
+ };
407
+ const pathParams = client._options.validate
408
+ ? toPathWire(pathParamsInput, schemas.getCreditGrantPathParams)
409
+ : pathParamsInput;
410
+ if (client._options.validate) {
411
+ assertValid(schemas.getCreditGrantPathParamsWire, pathParams);
412
+ }
234
413
  const path = `openmeter/customers/${(() => {
235
- if (req.customerId === undefined) {
414
+ if (pathParams.customerId === undefined) {
236
415
  throw new Error('missing path parameter: customerId');
237
416
  }
238
- return encodeURIComponent(String(req.customerId));
417
+ return encodeURIComponent(String(pathParams.customerId));
239
418
  })()}/credits/grants/${(() => {
240
- if (req.creditGrantId === undefined) {
419
+ if (pathParams.creditGrantId === undefined) {
241
420
  throw new Error('missing path parameter: creditGrantId');
242
421
  }
243
- return encodeURIComponent(String(req.creditGrantId));
422
+ return encodeURIComponent(String(pathParams.creditGrantId));
244
423
  })()}`;
245
424
  return http(client)
246
425
  .get(path, options)
@@ -253,13 +432,29 @@ export function getCreditGrant(client, req, options) {
253
432
  });
254
433
  });
255
434
  }
435
+ /**
436
+ * List credit grants
437
+ *
438
+ * List credit grants.
439
+ *
440
+ * GET /openmeter/customers/{customerId}/credits/grants
441
+ */
256
442
  export function listCreditGrants(client, req, options) {
257
443
  return request(() => {
444
+ const pathParamsInput = {
445
+ customerId: req.customerId,
446
+ };
447
+ const pathParams = client._options.validate
448
+ ? toPathWire(pathParamsInput, schemas.listCreditGrantsPathParams)
449
+ : pathParamsInput;
450
+ if (client._options.validate) {
451
+ assertValid(schemas.listCreditGrantsPathParamsWire, pathParams);
452
+ }
258
453
  const path = `openmeter/customers/${(() => {
259
- if (req.customerId === undefined) {
454
+ if (pathParams.customerId === undefined) {
260
455
  throw new Error('missing path parameter: customerId');
261
456
  }
262
- return encodeURIComponent(String(req.customerId));
457
+ return encodeURIComponent(String(pathParams.customerId));
263
458
  })()}/credits/grants`;
264
459
  const query = toWire({
265
460
  page: req.page,
@@ -280,13 +475,29 @@ export function listCreditGrants(client, req, options) {
280
475
  });
281
476
  });
282
477
  }
478
+ /**
479
+ * Get a customer's credit balance
480
+ *
481
+ * Get a credit balance.
482
+ *
483
+ * GET /openmeter/customers/{customerId}/credits/balance
484
+ */
283
485
  export function getCustomerCreditBalance(client, req, options) {
284
486
  return request(() => {
487
+ const pathParamsInput = {
488
+ customerId: req.customerId,
489
+ };
490
+ const pathParams = client._options.validate
491
+ ? toPathWire(pathParamsInput, schemas.getCustomerCreditBalancePathParams)
492
+ : pathParamsInput;
493
+ if (client._options.validate) {
494
+ assertValid(schemas.getCustomerCreditBalancePathParamsWire, pathParams);
495
+ }
285
496
  const path = `openmeter/customers/${(() => {
286
- if (req.customerId === undefined) {
497
+ if (pathParams.customerId === undefined) {
287
498
  throw new Error('missing path parameter: customerId');
288
499
  }
289
- return encodeURIComponent(String(req.customerId));
500
+ return encodeURIComponent(String(pathParams.customerId));
290
501
  })()}/credits/balance`;
291
502
  const query = toWire({
292
503
  timestamp: req.timestamp,
@@ -307,13 +518,34 @@ export function getCustomerCreditBalance(client, req, options) {
307
518
  });
308
519
  });
309
520
  }
521
+ /**
522
+ * Create a credit adjustment
523
+ *
524
+ * A credit adjustment can be used to make manual adjustments to a customer's
525
+ * credit balance.
526
+ *
527
+ * Supported use-cases:
528
+ *
529
+ * - Usage correction
530
+ *
531
+ * POST /openmeter/customers/{customerId}/credits/adjustments
532
+ */
310
533
  export function createCreditAdjustment(client, req, options) {
311
534
  return request(() => {
535
+ const pathParamsInput = {
536
+ customerId: req.customerId,
537
+ };
538
+ const pathParams = client._options.validate
539
+ ? toPathWire(pathParamsInput, schemas.createCreditAdjustmentPathParams)
540
+ : pathParamsInput;
541
+ if (client._options.validate) {
542
+ assertValid(schemas.createCreditAdjustmentPathParamsWire, pathParams);
543
+ }
312
544
  const path = `openmeter/customers/${(() => {
313
- if (req.customerId === undefined) {
545
+ if (pathParams.customerId === undefined) {
314
546
  throw new Error('missing path parameter: customerId');
315
547
  }
316
- return encodeURIComponent(String(req.customerId));
548
+ return encodeURIComponent(String(pathParams.customerId));
317
549
  })()}/credits/adjustments`;
318
550
  const body = toWire(req.body, schemas.createCreditAdjustmentBody);
319
551
  if (client._options.validate) {
@@ -330,18 +562,91 @@ export function createCreditAdjustment(client, req, options) {
330
562
  });
331
563
  });
332
564
  }
565
+ /**
566
+ * Void credit grant
567
+ *
568
+ * Void a credit grant, forfeiting the remaining unused balance.
569
+ *
570
+ * Voiding is a forward-looking, irreversible operation. Credits already consumed
571
+ * by usage remain unaffected — only the remaining balance is forfeited. The grant
572
+ * reads as `voided` status afterwards. Payment state is not adjusted when
573
+ * `payment_adjustment` is `none`, so invoice-backed or externally collected
574
+ * payments may still collect the original amount. Only `active` grants can be
575
+ * voided; voiding a pending, expired, or fully consumed grant returns a conflict.
576
+ * Retrying a successful void is an idempotent success.
577
+ *
578
+ * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void
579
+ */
580
+ export function voidCreditGrant(client, req, options) {
581
+ return request(() => {
582
+ const pathParamsInput = {
583
+ customerId: req.customerId,
584
+ creditGrantId: req.creditGrantId,
585
+ };
586
+ const pathParams = client._options.validate
587
+ ? toPathWire(pathParamsInput, schemas.voidCreditGrantPathParams)
588
+ : pathParamsInput;
589
+ if (client._options.validate) {
590
+ assertValid(schemas.voidCreditGrantPathParamsWire, pathParams);
591
+ }
592
+ const path = `openmeter/customers/${(() => {
593
+ if (pathParams.customerId === undefined) {
594
+ throw new Error('missing path parameter: customerId');
595
+ }
596
+ return encodeURIComponent(String(pathParams.customerId));
597
+ })()}/credits/grants/${(() => {
598
+ if (pathParams.creditGrantId === undefined) {
599
+ throw new Error('missing path parameter: creditGrantId');
600
+ }
601
+ return encodeURIComponent(String(pathParams.creditGrantId));
602
+ })()}/void`;
603
+ const body = toWire(req.body, schemas.voidCreditGrantBody);
604
+ if (client._options.validate) {
605
+ assertValid(schemas.voidCreditGrantBodyWire, body);
606
+ }
607
+ return http(client)
608
+ .post(path, { ...options, json: body })
609
+ .json()
610
+ .then((data) => {
611
+ if (client._options.validate) {
612
+ assertValid(schemas.voidCreditGrantResponseWire, data);
613
+ }
614
+ return fromWire(data, schemas.voidCreditGrantResponse);
615
+ });
616
+ });
617
+ }
618
+ /**
619
+ * Update credit grant external settlement status
620
+ *
621
+ * Update the payment settlement status of an externally funded credit grant.
622
+ *
623
+ * Use this endpoint to synchronize the payment state of an external payment with
624
+ * the system so that revenue recognition and credit availability work as expected.
625
+ *
626
+ * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/settlement/external
627
+ */
333
628
  export function updateCreditGrantExternalSettlement(client, req, options) {
334
629
  return request(() => {
630
+ const pathParamsInput = {
631
+ customerId: req.customerId,
632
+ creditGrantId: req.creditGrantId,
633
+ };
634
+ const pathParams = client._options.validate
635
+ ? toPathWire(pathParamsInput, schemas.updateCreditGrantExternalSettlementPathParams)
636
+ : pathParamsInput;
637
+ if (client._options.validate) {
638
+ assertValid(schemas.updateCreditGrantExternalSettlementPathParamsWire, pathParams);
639
+ }
335
640
  const path = `openmeter/customers/${(() => {
336
- if (req.customerId === undefined) {
641
+ if (pathParams.customerId === undefined) {
337
642
  throw new Error('missing path parameter: customerId');
338
643
  }
339
- return encodeURIComponent(String(req.customerId));
644
+ return encodeURIComponent(String(pathParams.customerId));
340
645
  })()}/credits/grants/${(() => {
341
- if (req.creditGrantId === undefined) {
646
+ if (pathParams.creditGrantId === undefined) {
342
647
  throw new Error('missing path parameter: creditGrantId');
343
648
  }
344
- return encodeURIComponent(String(req.creditGrantId));
649
+ return encodeURIComponent(String(pathParams.creditGrantId));
345
650
  })()}/settlement/external`;
346
651
  const body = toWire(req.body, schemas.updateCreditGrantExternalSettlementBody);
347
652
  if (client._options.validate) {
@@ -358,13 +663,33 @@ export function updateCreditGrantExternalSettlement(client, req, options) {
358
663
  });
359
664
  });
360
665
  }
666
+ /**
667
+ * List credit transactions
668
+ *
669
+ * List credit transactions for a customer.
670
+ *
671
+ * Returns an immutable, chronological record of credit movements: funded credits
672
+ * and consumed credits. Transactions are returned in reverse chronological order
673
+ * by default.
674
+ *
675
+ * GET /openmeter/customers/{customerId}/credits/transactions
676
+ */
361
677
  export function listCreditTransactions(client, req, options) {
362
678
  return request(() => {
679
+ const pathParamsInput = {
680
+ customerId: req.customerId,
681
+ };
682
+ const pathParams = client._options.validate
683
+ ? toPathWire(pathParamsInput, schemas.listCreditTransactionsPathParams)
684
+ : pathParamsInput;
685
+ if (client._options.validate) {
686
+ assertValid(schemas.listCreditTransactionsPathParamsWire, pathParams);
687
+ }
363
688
  const path = `openmeter/customers/${(() => {
364
- if (req.customerId === undefined) {
689
+ if (pathParams.customerId === undefined) {
365
690
  throw new Error('missing path parameter: customerId');
366
691
  }
367
- return encodeURIComponent(String(req.customerId));
692
+ return encodeURIComponent(String(pathParams.customerId));
368
693
  })()}/credits/transactions`;
369
694
  const query = toWire({
370
695
  page: req.page,
@@ -385,14 +710,36 @@ export function listCreditTransactions(client, req, options) {
385
710
  });
386
711
  });
387
712
  }
713
+ /**
714
+ * List customer charges
715
+ *
716
+ * List customer charges.
717
+ *
718
+ * Returns the customer's charges that are represented as either flat fee or
719
+ * usage-based charges.
720
+ *
721
+ * GET /openmeter/customers/{customerId}/charges
722
+ */
388
723
  export function listCustomerCharges(client, req, options) {
389
724
  return request(() => {
725
+ const pathParamsInput = {
726
+ customerId: req.customerId,
727
+ };
728
+ const pathParams = client._options.validate
729
+ ? toPathWire(pathParamsInput, schemas.listCustomerChargesPathParams)
730
+ : pathParamsInput;
731
+ if (client._options.validate) {
732
+ assertValid(schemas.listCustomerChargesPathParamsWire, pathParams);
733
+ }
390
734
  const path = `openmeter/customers/${(() => {
391
- if (req.customerId === undefined) {
735
+ if (pathParams.customerId === undefined) {
392
736
  throw new Error('missing path parameter: customerId');
393
737
  }
394
- return encodeURIComponent(String(req.customerId));
738
+ return encodeURIComponent(String(pathParams.customerId));
395
739
  })()}/charges`;
740
+ if (client._options.validate && req.sort !== undefined) {
741
+ assertValid(schemas.listCustomerChargesQueryParams.shape.sort, req.sort);
742
+ }
396
743
  const query = toWire({
397
744
  page: req.page,
398
745
  sort: encodeSort(req.sort, toSnakeCase),
@@ -414,13 +761,29 @@ export function listCustomerCharges(client, req, options) {
414
761
  });
415
762
  });
416
763
  }
764
+ /**
765
+ * Create customer charge
766
+ *
767
+ * Create customer charge.
768
+ *
769
+ * POST /openmeter/customers/{customerId}/charges
770
+ */
417
771
  export function createCustomerCharges(client, req, options) {
418
772
  return request(() => {
773
+ const pathParamsInput = {
774
+ customerId: req.customerId,
775
+ };
776
+ const pathParams = client._options.validate
777
+ ? toPathWire(pathParamsInput, schemas.createCustomerChargesPathParams)
778
+ : pathParamsInput;
779
+ if (client._options.validate) {
780
+ assertValid(schemas.createCustomerChargesPathParamsWire, pathParams);
781
+ }
419
782
  const path = `openmeter/customers/${(() => {
420
- if (req.customerId === undefined) {
783
+ if (pathParams.customerId === undefined) {
421
784
  throw new Error('missing path parameter: customerId');
422
785
  }
423
- return encodeURIComponent(String(req.customerId));
786
+ return encodeURIComponent(String(pathParams.customerId));
424
787
  })()}/charges`;
425
788
  const body = toWire(req.body, schemas.createCustomerChargesBody);
426
789
  if (client._options.validate) {
@@ -437,4 +800,3 @@ export function createCustomerCharges(client, req, options) {
437
800
  });
438
801
  });
439
802
  }
440
- //# sourceMappingURL=customers.js.map
@@ -1,6 +1,15 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
3
  import type { GetOrganizationDefaultTaxCodesRequest, GetOrganizationDefaultTaxCodesResponse, UpdateOrganizationDefaultTaxCodesRequest, UpdateOrganizationDefaultTaxCodesResponse } from '../models/operations/defaults.js';
4
+ /**
5
+ * Get organization default tax codes
6
+ *
7
+ * GET /openmeter/defaults/tax-codes
8
+ */
4
9
  export declare function getOrganizationDefaultTaxCodes(client: Client, req: GetOrganizationDefaultTaxCodesRequest, options?: RequestOptions): Promise<Result<GetOrganizationDefaultTaxCodesResponse>>;
10
+ /**
11
+ * Update organization default tax codes
12
+ *
13
+ * PUT /openmeter/defaults/tax-codes
14
+ */
5
15
  export declare function updateOrganizationDefaultTaxCodes(client: Client, req: UpdateOrganizationDefaultTaxCodesRequest, options?: RequestOptions): Promise<Result<UpdateOrganizationDefaultTaxCodesResponse>>;
6
- //# sourceMappingURL=defaults.d.ts.map