@openmeter/client 1.0.0-beta-72c0e4789aae → 1.0.0-beta-e609679efd27

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.
@@ -1,17 +1,6 @@
1
1
  // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
2
  import { unwrap } from '../lib/types.js';
3
- import { paginatePages } from '../lib/paginate.js';
4
- import { createCustomerEntitlement, overrideCustomerEntitlement, getCustomerEntitlementHistory, getCustomerEntitlement, listCustomerEntitlements, resetCustomerEntitlementUsage, deleteCustomerEntitlement, createCustomerEntitlementGrant, listCustomerEntitlementGrants, voidCreditGrant, listCustomerCharges, createCustomerCharges, } from '../funcs/customers.js';
5
- import { getCustomerEntitlementAccess, getCustomerEntitlementValueByFeatureKey, listEntitlements, getEntitlement, getCustomerEntitlementValue, } from '../funcs/entitlements.js';
6
- import { listGrants, voidGrant } from '../funcs/grants.js';
7
- import { unscheduleSubscription, restoreSubscription, migrateSubscription, createSubscriptionAddon, updateSubscriptionAddon, } from '../funcs/subscriptions.js';
8
- import { uninstallApp, updateApp, listAppCatalog, getAppCatalogItem, installApp, } from '../funcs/apps.js';
9
- import { listInvoices, getInvoice, updateInvoice, deleteInvoice, advanceInvoice, approveInvoice, retryInvoice, snapshotQuantitiesInvoice, } from '../funcs/invoices.js';
10
- import { listCharges } from '../funcs/charges.js';
11
- import { listCurrencies, createCustomCurrency, getCustomCurrency, listCostBases, createCostBasis, } from '../funcs/currencies.js';
12
- import { listPlanAddons } from '../funcs/planAddons.js';
13
- import { queryEntitlementAccess } from '../funcs/entitlementAccess.js';
14
- import { listNotificationChannels, createNotificationChannel, getNotificationChannel, updateNotificationChannel, deleteNotificationChannel, } from '../funcs/notifications.js';
3
+ import { createSubscriptionAddon, updateSubscriptionAddon, } from '../funcs/subscriptions.js';
15
4
  /**
16
5
  * Operations marked internal in the API definition. They are not part of
17
6
  * the customer surface: they may require additional permissions, and they
@@ -22,493 +11,16 @@ export class Internal {
22
11
  constructor(_client) {
23
12
  this._client = _client;
24
13
  }
25
- _customers;
26
- get customers() {
27
- return (this._customers ??= new InternalCustomers(this._client));
28
- }
29
- _entitlements;
30
- get entitlements() {
31
- return (this._entitlements ??= new InternalEntitlements(this._client));
32
- }
33
- _grants;
34
- get grants() {
35
- return (this._grants ??= new InternalGrants(this._client));
36
- }
37
14
  _subscriptions;
38
15
  get subscriptions() {
39
16
  return (this._subscriptions ??= new InternalSubscriptions(this._client));
40
17
  }
41
- _apps;
42
- get apps() {
43
- return (this._apps ??= new InternalApps(this._client));
44
- }
45
- _invoices;
46
- get invoices() {
47
- return (this._invoices ??= new InternalInvoices(this._client));
48
- }
49
- _charges;
50
- get charges() {
51
- return (this._charges ??= new InternalCharges(this._client));
52
- }
53
- _currencies;
54
- get currencies() {
55
- return (this._currencies ??= new InternalCurrencies(this._client));
56
- }
57
- _planAddons;
58
- get planAddons() {
59
- return (this._planAddons ??= new InternalPlanAddons(this._client));
60
- }
61
- _entitlementAccess;
62
- get entitlementAccess() {
63
- return (this._entitlementAccess ??= new InternalEntitlementAccess(this._client));
64
- }
65
- _notifications;
66
- get notifications() {
67
- return (this._notifications ??= new InternalNotifications(this._client));
68
- }
69
- }
70
- export class InternalCustomers {
71
- _client;
72
- constructor(_client) {
73
- this._client = _client;
74
- }
75
- _entitlements;
76
- get entitlements() {
77
- return (this._entitlements ??= new InternalCustomersEntitlements(this._client));
78
- }
79
- _credits;
80
- get credits() {
81
- return (this._credits ??= new InternalCustomersCredits(this._client));
82
- }
83
- _charges;
84
- get charges() {
85
- return (this._charges ??= new InternalCustomersCharges(this._client));
86
- }
87
- }
88
- export class InternalCustomersEntitlements {
89
- _client;
90
- constructor(_client) {
91
- this._client = _client;
92
- }
93
- /**
94
- * Create customer entitlement
95
- *
96
- * Create an entitlement for the customer.
97
- *
98
- * A customer can have only one active entitlement per feature. The feature must be
99
- * compatible with the entitlement type. Entitlements cannot be modified after
100
- * creation, only deleted.
101
- *
102
- * POST /openmeter/customers/{customerId}/entitlements
103
- */
104
- async create(request, options) {
105
- return unwrap(await createCustomerEntitlement(this._client, request, options));
106
- }
107
- /**
108
- * Override customer entitlement
109
- *
110
- * Override an entitlement of the customer with a new one.
111
- *
112
- * The referenced entitlement ends and the new one starts at the same instant, so
113
- * access continues without a gap. Both must belong to the same feature. Use this
114
- * for upgrades and downgrades.
115
- *
116
- * Fails if the referenced entitlement does not exist, is deleted, or is no longer
117
- * active.
118
- *
119
- * PUT /openmeter/customers/{customerId}/entitlements/{entitlementId}/override
120
- */
121
- async override(request, options) {
122
- return unwrap(await overrideCustomerEntitlement(this._client, request, options));
123
- }
124
- /**
125
- * Get customer entitlement history
126
- *
127
- * Get the balance and usage history of a metered entitlement. The queried range
128
- * may span multiple usage periods.
129
- *
130
- * `windowed_history` groups usage into windows of the requested size and reports
131
- * the balance at the start of each window. `burndown_history` lists the periods in
132
- * which grants were consumed in a fixed order, together with the usage taken from
133
- * each grant.
134
- *
135
- * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/history
136
- */
137
- async getHistory(request, options) {
138
- return unwrap(await getCustomerEntitlementHistory(this._client, request, options));
139
- }
140
- /**
141
- * Get customer entitlement
142
- *
143
- * Get an entitlement of the customer by ID. For checking entitlement access, use
144
- * the entitlement access endpoints instead.
145
- *
146
- * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}
147
- */
148
- async get(request, options) {
149
- return unwrap(await getCustomerEntitlement(this._client, request, options));
150
- }
151
- /**
152
- * List customer entitlements
153
- *
154
- * List the entitlements of the customer that are active at the time of the
155
- * request. For checking entitlement access, use the entitlement access endpoints
156
- * instead.
157
- *
158
- * GET /openmeter/customers/{customerId}/entitlements
159
- */
160
- async list(request, options) {
161
- return unwrap(await listCustomerEntitlements(this._client, request, options));
162
- }
163
- /**
164
- * List customer entitlements
165
- *
166
- * List the entitlements of the customer that are active at the time of the
167
- * request. For checking entitlement access, use the entitlement access endpoints
168
- * instead.
169
- *
170
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
171
- *
172
- * GET /openmeter/customers/{customerId}/entitlements
173
- */
174
- listAll(request, options) {
175
- return paginatePages((req, opts) => listCustomerEntitlements(this._client, req, opts), request, options);
176
- }
177
- /**
178
- * Reset customer entitlement usage
179
- *
180
- * Reset the usage of a metered entitlement. The reset starts a new usage period:
181
- * usage is zeroed and grants roll over according to their rollover settings.
182
- *
183
- * Usage is reset automatically at the end of each usage period. Use this operation
184
- * to reset it earlier, for example to align the entitlement with the customer's
185
- * billing period. The usage period anchor can be moved at the same time.
186
- *
187
- * POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/reset
188
- */
189
- async resetUsage(request, options) {
190
- return unwrap(await resetCustomerEntitlementUsage(this._client, request, options));
191
- }
192
- /**
193
- * Delete customer entitlement
194
- *
195
- * Deletes the entitlement and revokes access to its feature. A customer can hold
196
- * only one active entitlement per feature, so migrating a feature requires
197
- * deleting the previous entitlement first.
198
- *
199
- * Deletion sets the `deleted_at` timestamp instead of removing history. Access and
200
- * status queries for earlier points in time still treat the entitlement as active,
201
- * so access changes are never retroactive.
202
- *
203
- * DELETE /openmeter/customers/{customerId}/entitlements/{entitlementId}
204
- */
205
- async delete(request, options) {
206
- return unwrap(await deleteCustomerEntitlement(this._client, request, options));
207
- }
208
- _grants;
209
- get grants() {
210
- return (this._grants ??= new InternalCustomersEntitlementsGrants(this._client));
211
- }
212
- }
213
- export class InternalCustomersEntitlementsGrants {
214
- _client;
215
- constructor(_client) {
216
- this._client = _client;
217
- }
218
- /**
219
- * Create customer entitlement grant
220
- *
221
- * Issue a grant for a metered entitlement of the customer. Boolean and static
222
- * entitlements cannot have grants, so the request is rejected for them.
223
- *
224
- * Grants are immutable. The amount is added to the balance from `effective_at`,
225
- * which cannot be earlier than the start of the current usage period.
226
- *
227
- * POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
228
- */
229
- async create(request, options) {
230
- return unwrap(await createCustomerEntitlementGrant(this._client, request, options));
231
- }
232
- /**
233
- * List customer entitlement grants
234
- *
235
- * List the grants issued for an entitlement of the customer. Grants only exist for
236
- * metered entitlements, so the list is empty for boolean and static entitlements.
237
- *
238
- * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
239
- * grants are always included, as they are part of the balance history.
240
- *
241
- * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
242
- */
243
- async list(request, options) {
244
- return unwrap(await listCustomerEntitlementGrants(this._client, request, options));
245
- }
246
- /**
247
- * List customer entitlement grants
248
- *
249
- * List the grants issued for an entitlement of the customer. Grants only exist for
250
- * metered entitlements, so the list is empty for boolean and static entitlements.
251
- *
252
- * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
253
- * grants are always included, as they are part of the balance history.
254
- *
255
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
256
- *
257
- * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
258
- */
259
- listAll(request, options) {
260
- return paginatePages((req, opts) => listCustomerEntitlementGrants(this._client, req, opts), request, options);
261
- }
262
- }
263
- export class InternalCustomersCredits {
264
- _client;
265
- constructor(_client) {
266
- this._client = _client;
267
- }
268
- _grants;
269
- get grants() {
270
- return (this._grants ??= new InternalCustomersCreditsGrants(this._client));
271
- }
272
- }
273
- export class InternalCustomersCreditsGrants {
274
- _client;
275
- constructor(_client) {
276
- this._client = _client;
277
- }
278
- /**
279
- * Void credit grant
280
- *
281
- * Void a credit grant, forfeiting the remaining unused balance.
282
- *
283
- * Voiding is a forward-looking, irreversible operation. Credits already consumed
284
- * by usage remain unaffected — only the remaining balance is forfeited. The grant
285
- * reads as `voided` status afterwards. Payment state is not adjusted when
286
- * `payment_adjustment` is `none`, so invoice-backed or externally collected
287
- * payments may still collect the original amount. Only `active` grants can be
288
- * voided; voiding a pending, expired, or fully consumed grant returns a conflict.
289
- * Retrying a successful void is an idempotent success.
290
- *
291
- * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void
292
- */
293
- async void(request, options) {
294
- return unwrap(await voidCreditGrant(this._client, request, options));
295
- }
296
- }
297
- export class InternalCustomersCharges {
298
- _client;
299
- constructor(_client) {
300
- this._client = _client;
301
- }
302
- /**
303
- * List customer charges
304
- *
305
- * List customer charges.
306
- *
307
- * Returns the customer's charges that are represented as either flat fee or
308
- * usage-based charges.
309
- *
310
- * GET /openmeter/customers/{customerId}/charges
311
- */
312
- async list(request, options) {
313
- return unwrap(await listCustomerCharges(this._client, request, options));
314
- }
315
- /**
316
- * List customer charges
317
- *
318
- * List customer charges.
319
- *
320
- * Returns the customer's charges that are represented as either flat fee or
321
- * usage-based charges.
322
- *
323
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
324
- *
325
- * GET /openmeter/customers/{customerId}/charges
326
- */
327
- listAll(request, options) {
328
- return paginatePages((req, opts) => listCustomerCharges(this._client, req, opts), request, options);
329
- }
330
- /**
331
- * Create customer charge
332
- *
333
- * Create customer charge.
334
- *
335
- * POST /openmeter/customers/{customerId}/charges
336
- */
337
- async create(request, options) {
338
- return unwrap(await createCustomerCharges(this._client, request, options));
339
- }
340
- }
341
- export class InternalEntitlements {
342
- _client;
343
- constructor(_client) {
344
- this._client = _client;
345
- }
346
- /**
347
- * Get customer entitlement access
348
- *
349
- * Get the customer's access to a single feature.
350
- *
351
- * GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}
352
- */
353
- async getCustomerAccess(request, options) {
354
- return unwrap(await getCustomerEntitlementAccess(this._client, request, options));
355
- }
356
- /**
357
- * Get customer entitlement value by feature key
358
- *
359
- * Get the customer's entitlement value for a feature at a point in time. Without
360
- * an active entitlement, the result denies access and omits the type.
361
- *
362
- * GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}/value
363
- */
364
- async getCustomerValueByFeatureKey(request, options) {
365
- return unwrap(await getCustomerEntitlementValueByFeatureKey(this._client, request, options));
366
- }
367
- /**
368
- * List entitlements
369
- *
370
- * List the active entitlements of all customers. Intended for administrative use.
371
- * To list the entitlements of a single customer, use the customer entitlements
372
- * endpoints; to check entitlement access, use the entitlement access endpoints.
373
- *
374
- * GET /openmeter/entitlements
375
- */
376
- async list(request, options) {
377
- return unwrap(await listEntitlements(this._client, request, options));
378
- }
379
- /**
380
- * List entitlements
381
- *
382
- * List the active entitlements of all customers. Intended for administrative use.
383
- * To list the entitlements of a single customer, use the customer entitlements
384
- * endpoints; to check entitlement access, use the entitlement access endpoints.
385
- *
386
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
387
- *
388
- * GET /openmeter/entitlements
389
- */
390
- listAll(request, options) {
391
- return paginatePages((req, opts) => listEntitlements(this._client, req, opts), request ?? {}, options);
392
- }
393
- /**
394
- * Get entitlement
395
- *
396
- * Get an entitlement by ID. To check entitlement access, use the entitlement
397
- * access endpoints instead.
398
- *
399
- * GET /openmeter/entitlements/{entitlementId}
400
- */
401
- async get(request, options) {
402
- return unwrap(await getEntitlement(this._client, request, options));
403
- }
404
- /**
405
- * Get customer entitlement value
406
- *
407
- * Get the customer's access through a single entitlement, optionally evaluated at
408
- * a point in time.
409
- *
410
- * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
411
- */
412
- async getCustomerValue(request, options) {
413
- return unwrap(await getCustomerEntitlementValue(this._client, request, options));
414
- }
415
- }
416
- export class InternalGrants {
417
- _client;
418
- constructor(_client) {
419
- this._client = _client;
420
- }
421
- /**
422
- * List grants
423
- *
424
- * List the grants of all customers and entitlements. To list the grants of a
425
- * single entitlement, use the customer entitlement grants endpoint.
426
- *
427
- * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
428
- * grants are always included, as they are part of the balance history.
429
- *
430
- * GET /openmeter/grants
431
- */
432
- async list(request, options) {
433
- return unwrap(await listGrants(this._client, request, options));
434
- }
435
- /**
436
- * List grants
437
- *
438
- * List the grants of all customers and entitlements. To list the grants of a
439
- * single entitlement, use the customer entitlement grants endpoint.
440
- *
441
- * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
442
- * grants are always included, as they are part of the balance history.
443
- *
444
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
445
- *
446
- * GET /openmeter/grants
447
- */
448
- listAll(request, options) {
449
- return paginatePages((req, opts) => listGrants(this._client, req, opts), request ?? {}, options);
450
- }
451
- /**
452
- * Void grant
453
- *
454
- * Void a grant so it no longer adds to the balance. Usage already deducted from
455
- * the grant is kept.
456
- *
457
- * DELETE /openmeter/grants/{grantId}
458
- */
459
- async void(request, options) {
460
- return unwrap(await voidGrant(this._client, request, options));
461
- }
462
18
  }
463
19
  export class InternalSubscriptions {
464
20
  _client;
465
21
  constructor(_client) {
466
22
  this._client = _client;
467
23
  }
468
- /**
469
- * Unschedule subscription
470
- *
471
- * Deletes a scheduled subscription that has not yet become active, removing it and
472
- * resolving any scheduling conflict it was holding. This is distinct from
473
- * canceling: cancel ends a running subscription, whereas unscheduling removes a
474
- * not-yet-active one. Only scheduled subscriptions can be unscheduled;
475
- * unscheduling an active or already-started subscription is rejected.
476
- *
477
- * POST /openmeter/subscriptions/{subscriptionId}/unschedule
478
- */
479
- async unschedule(request, options) {
480
- return unwrap(await unscheduleSubscription(this._client, request, options));
481
- }
482
- /**
483
- * Restore subscription
484
- *
485
- * Restores the subscription by deleting any later-scheduled successor
486
- * subscriptions and continuing this one indefinitely. This is the inverse of a
487
- * future-dated change, which schedules a successor. Restore is not available when
488
- * multi-subscription is enabled.
489
- *
490
- * POST /openmeter/subscriptions/{subscriptionId}/restore
491
- */
492
- async restore(request, options) {
493
- return unwrap(await restoreSubscription(this._client, request, options));
494
- }
495
- /**
496
- * Migrate subscription
497
- *
498
- * Migrates to a later version of the current plan. With starting_phase omitted and
499
- * billing_anchor omitted or unchanged, migration amends the subscription in place:
500
- * unchanged items retain their service periods and both response entries have the
501
- * same ID. Existing addons must remain compatible with the target plan.
502
- * Incompatible phase timelines or billing settings return an error. Providing
503
- * starting_phase or a different billing_anchor explicitly requests replacement,
504
- * which resets the phase timeline, may produce billing adjustments, and does not
505
- * transfer addons. Custom subscriptions cannot be migrated.
506
- *
507
- * POST /openmeter/subscriptions/{subscriptionId}/migrate
508
- */
509
- async migrate(request, options) {
510
- return unwrap(await migrateSubscription(this._client, request, options));
511
- }
512
24
  /**
513
25
  * Create a new subscription add-on
514
26
  *
@@ -532,450 +44,3 @@ export class InternalSubscriptions {
532
44
  return unwrap(await updateSubscriptionAddon(this._client, request, options));
533
45
  }
534
46
  }
535
- export class InternalApps {
536
- _client;
537
- constructor(_client) {
538
- this._client = _client;
539
- }
540
- /**
541
- * Uninstall app
542
- *
543
- * Uninstall an app by ID.
544
- *
545
- * DELETE /openmeter/apps/{appId}
546
- */
547
- async uninstall(request, options) {
548
- return unwrap(await uninstallApp(this._client, request, options));
549
- }
550
- /**
551
- * Update app
552
- *
553
- * Update an installed app.
554
- *
555
- * PUT /openmeter/apps/{appId}
556
- */
557
- async update(request, options) {
558
- return unwrap(await updateApp(this._client, request, options));
559
- }
560
- /**
561
- * List app catalog
562
- *
563
- * List available apps.
564
- *
565
- * GET /openmeter/app-catalog
566
- */
567
- async listCatalog(request, options) {
568
- return unwrap(await listAppCatalog(this._client, request, options));
569
- }
570
- /**
571
- * List app catalog
572
- *
573
- * List available apps.
574
- *
575
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
576
- *
577
- * GET /openmeter/app-catalog
578
- */
579
- listCatalogAll(request, options) {
580
- return paginatePages((req, opts) => listAppCatalog(this._client, req, opts), request ?? {}, options);
581
- }
582
- /**
583
- * Get app catalog item by type
584
- *
585
- * Get an app catalog item by type.
586
- *
587
- * GET /openmeter/app-catalog/{appType}
588
- */
589
- async getCatalogItem(request, options) {
590
- return unwrap(await getAppCatalogItem(this._client, request, options));
591
- }
592
- /**
593
- * Install app from the catalog
594
- *
595
- * Install an app from the catalog.
596
- *
597
- * POST /openmeter/app-catalog/install
598
- */
599
- async install(request, options) {
600
- return unwrap(await installApp(this._client, request, options));
601
- }
602
- }
603
- export class InternalInvoices {
604
- _client;
605
- constructor(_client) {
606
- this._client = _client;
607
- }
608
- /**
609
- * List billing invoices
610
- *
611
- * List billing invoices.
612
- *
613
- * Returns a page of invoices. Gathering invoices are never included. Use `filter`
614
- * to narrow by status, customer, dates, or service period start. Use `sort` to
615
- * control ordering.
616
- *
617
- * GET /openmeter/billing/invoices
618
- */
619
- async list(request, options) {
620
- return unwrap(await listInvoices(this._client, request, options));
621
- }
622
- /**
623
- * List billing invoices
624
- *
625
- * List billing invoices.
626
- *
627
- * Returns a page of invoices. Gathering invoices are never included. Use `filter`
628
- * to narrow by status, customer, dates, or service period start. Use `sort` to
629
- * control ordering.
630
- *
631
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
632
- *
633
- * GET /openmeter/billing/invoices
634
- */
635
- listAll(request, options) {
636
- return paginatePages((req, opts) => listInvoices(this._client, req, opts), request ?? {}, options);
637
- }
638
- /**
639
- * Get a billing invoice
640
- *
641
- * Get a billing invoice by ID.
642
- *
643
- * Returns the full invoice resource including line items, status details, totals,
644
- * and workflow configuration snapshot.
645
- *
646
- * GET /openmeter/billing/invoices/{invoiceId}
647
- */
648
- async get(request, options) {
649
- return unwrap(await getInvoice(this._client, request, options));
650
- }
651
- /**
652
- * Update a billing invoice
653
- *
654
- * Update a billing invoice.
655
- *
656
- * Only the mutable fields of the invoice can be edited: description, labels,
657
- * supplier, customer, workflow settings, and top-level lines. Top-level lines are
658
- * matched by `id`; lines without an `id` are created, and existing lines omitted
659
- * from `lines` are deleted. Detailed (child) lines are always computed and cannot
660
- * be edited directly. Only invoices in draft status can be updated.
661
- *
662
- * PUT /openmeter/billing/invoices/{invoiceId}
663
- */
664
- async update(request, options) {
665
- return unwrap(await updateInvoice(this._client, request, options));
666
- }
667
- /**
668
- * Delete a billing invoice
669
- *
670
- * Delete a billing invoice.
671
- *
672
- * Only standard invoices in draft status can be deleted. Deleting an invoice will
673
- * also delete all associated line items and workflow configuration.
674
- *
675
- * DELETE /openmeter/billing/invoices/{invoiceId}
676
- */
677
- async delete(request, options) {
678
- return unwrap(await deleteInvoice(this._client, request, options));
679
- }
680
- /**
681
- * Advance billing invoice's next status
682
- *
683
- * Advance a billing invoice.
684
- *
685
- * Advances the invoice to the next workflow state. The next state is determined by
686
- * the invoice's current status and workflow configuration. Only invoices in draft
687
- * or issued status can be advanced.
688
- *
689
- * POST /openmeter/billing/invoices/{invoiceId}/advance
690
- */
691
- async advance(request, options) {
692
- return unwrap(await advanceInvoice(this._client, request, options));
693
- }
694
- /**
695
- * Send the invoice to the customer
696
- *
697
- * Approve a billing invoice.
698
- *
699
- * This call instantly sends the invoice to the customer using the configured
700
- * billing profile app.
701
- *
702
- * This call is valid in two invoice statuses:
703
- *
704
- * - draft: the invoice will be sent to the customer, the invoice state becomes
705
- * issued
706
- * - manual_approval_needed: the invoice will be sent to the customer, the invoice
707
- * state becomes issued
708
- *
709
- * POST /openmeter/billing/invoices/{invoiceId}/approve
710
- */
711
- async approve(request, options) {
712
- return unwrap(await approveInvoice(this._client, request, options));
713
- }
714
- /**
715
- * Retry advancing the invoice after a failed attempt
716
- *
717
- * Retry sending a billing invoice.
718
- *
719
- * Retry advancing the invoice after a failed attempt.
720
- *
721
- * The action can be called when the invoice's statusDetails' actions field contain
722
- * the "retry" action.
723
- *
724
- * POST /openmeter/billing/invoices/{invoiceId}/retry
725
- */
726
- async retry(request, options) {
727
- return unwrap(await retryInvoice(this._client, request, options));
728
- }
729
- /**
730
- * Snapshot quantities for usage based line items
731
- *
732
- * Snapshot quantities for usage-based line items.
733
- *
734
- * This call will snapshot the quantities for all usage based line items in the
735
- * invoice.
736
- *
737
- * This call is only valid in draft.waiting_for_collection status, where the
738
- * collection period can be skipped using this action.
739
- *
740
- * POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
741
- */
742
- async snapshotQuantities(request, options) {
743
- return unwrap(await snapshotQuantitiesInvoice(this._client, request, options));
744
- }
745
- }
746
- export class InternalCharges {
747
- _client;
748
- constructor(_client) {
749
- this._client = _client;
750
- }
751
- /**
752
- * List charges
753
- *
754
- * List charges.
755
- *
756
- * Returns the charges of every customer that are represented as either flat fee or
757
- * usage-based charges.
758
- *
759
- * GET /openmeter/charges
760
- */
761
- async list(request, options) {
762
- return unwrap(await listCharges(this._client, request, options));
763
- }
764
- /**
765
- * List charges
766
- *
767
- * List charges.
768
- *
769
- * Returns the charges of every customer that are represented as either flat fee or
770
- * usage-based charges.
771
- *
772
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
773
- *
774
- * GET /openmeter/charges
775
- */
776
- listAll(request, options) {
777
- return paginatePages((req, opts) => listCharges(this._client, req, opts), request ?? {}, options);
778
- }
779
- }
780
- export class InternalCurrencies {
781
- _client;
782
- constructor(_client) {
783
- this._client = _client;
784
- }
785
- /**
786
- * List currencies
787
- *
788
- * List currencies supported by the billing system.
789
- *
790
- * GET /openmeter/currencies
791
- */
792
- async list(request, options) {
793
- return unwrap(await listCurrencies(this._client, request, options));
794
- }
795
- /**
796
- * List currencies
797
- *
798
- * List currencies supported by the billing system.
799
- *
800
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
801
- *
802
- * GET /openmeter/currencies
803
- */
804
- listAll(request, options) {
805
- return paginatePages((req, opts) => listCurrencies(this._client, req, opts), request ?? {}, options);
806
- }
807
- /**
808
- * Create custom currency
809
- *
810
- * Create a custom currency. This operation allows defining your own custom
811
- * currency for billing purposes.
812
- *
813
- * POST /openmeter/currencies/custom
814
- */
815
- async createCustomCurrency(request, options) {
816
- return unwrap(await createCustomCurrency(this._client, request, options));
817
- }
818
- /**
819
- * Get custom currency
820
- *
821
- * Get a custom currency.
822
- *
823
- * GET /openmeter/currencies/custom/{currencyId}
824
- */
825
- async getCustomCurrency(request, options) {
826
- return unwrap(await getCustomCurrency(this._client, request, options));
827
- }
828
- /**
829
- * List cost bases
830
- *
831
- * List cost bases for a currency. For custom currencies, there can be multiple
832
- * cost bases with different `effective_from` dates.
833
- *
834
- * GET /openmeter/currencies/custom/{currencyId}/cost-bases
835
- */
836
- async listCostBases(request, options) {
837
- return unwrap(await listCostBases(this._client, request, options));
838
- }
839
- /**
840
- * List cost bases
841
- *
842
- * List cost bases for a currency. For custom currencies, there can be multiple
843
- * cost bases with different `effective_from` dates.
844
- *
845
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
846
- *
847
- * GET /openmeter/currencies/custom/{currencyId}/cost-bases
848
- */
849
- listCostBasesAll(request, options) {
850
- return paginatePages((req, opts) => listCostBases(this._client, req, opts), request, options);
851
- }
852
- /**
853
- * Create cost basis
854
- *
855
- * Create a cost basis for a currency.
856
- *
857
- * POST /openmeter/currencies/custom/{currencyId}/cost-bases
858
- */
859
- async createCostBasis(request, options) {
860
- return unwrap(await createCostBasis(this._client, request, options));
861
- }
862
- }
863
- export class InternalPlanAddons {
864
- _client;
865
- constructor(_client) {
866
- this._client = _client;
867
- }
868
- /**
869
- * List add-ons for plan
870
- *
871
- * List add-ons associated with a plan.
872
- *
873
- * GET /openmeter/plans/{planId}/addons
874
- */
875
- async list(request, options) {
876
- return unwrap(await listPlanAddons(this._client, request, options));
877
- }
878
- /**
879
- * List add-ons for plan
880
- *
881
- * List add-ons associated with a plan.
882
- *
883
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
884
- *
885
- * GET /openmeter/plans/{planId}/addons
886
- */
887
- listAll(request, options) {
888
- return paginatePages((req, opts) => listPlanAddons(this._client, req, opts), request, options);
889
- }
890
- }
891
- export class InternalEntitlementAccess {
892
- _client;
893
- constructor(_client) {
894
- this._client = _client;
895
- }
896
- /**
897
- * Query entitlement access
898
- *
899
- * Query feature access for a list of customers.
900
- *
901
- * The endpoint resolves each provided identifier to a customer and returns the
902
- * access status for the requested features, plus optional credit balance
903
- * availability.
904
- *
905
- * _Designed to be called on a fixed refresh interval and the query response is
906
- * intended to be cached._
907
- *
908
- * POST /openmeter/entitlement-access/query
909
- */
910
- async query(request, options) {
911
- return unwrap(await queryEntitlementAccess(this._client, request, options));
912
- }
913
- }
914
- export class InternalNotifications {
915
- _client;
916
- constructor(_client) {
917
- this._client = _client;
918
- }
919
- /**
920
- * List notification channels
921
- *
922
- * List all notification channels.
923
- *
924
- * GET /openmeter/notification/channels
925
- */
926
- async listChannels(request, options) {
927
- return unwrap(await listNotificationChannels(this._client, request, options));
928
- }
929
- /**
930
- * List notification channels
931
- *
932
- * List all notification channels.
933
- *
934
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
935
- *
936
- * GET /openmeter/notification/channels
937
- */
938
- listChannelsAll(request, options) {
939
- return paginatePages((req, opts) => listNotificationChannels(this._client, req, opts), request ?? {}, options);
940
- }
941
- /**
942
- * Create notification channel
943
- *
944
- * Create a notification channel.
945
- *
946
- * POST /openmeter/notification/channels
947
- */
948
- async createChannel(request, options) {
949
- return unwrap(await createNotificationChannel(this._client, request, options));
950
- }
951
- /**
952
- * Get notification channel
953
- *
954
- * Get a notification channel by id.
955
- *
956
- * GET /openmeter/notification/channels/{notificationChannelId}
957
- */
958
- async getChannel(request, options) {
959
- return unwrap(await getNotificationChannel(this._client, request, options));
960
- }
961
- /**
962
- * Update notification channel
963
- *
964
- * Update a notification channel by id.
965
- *
966
- * PUT /openmeter/notification/channels/{notificationChannelId}
967
- */
968
- async updateChannel(request, options) {
969
- return unwrap(await updateNotificationChannel(this._client, request, options));
970
- }
971
- /**
972
- * Delete notification channel
973
- *
974
- * Delete a notification channel by id.
975
- *
976
- * DELETE /openmeter/notification/channels/{notificationChannelId}
977
- */
978
- async deleteChannel(request, options) {
979
- return unwrap(await deleteNotificationChannel(this._client, request, options));
980
- }
981
- }