@openmeter/client 1.0.0-beta-c2050360536d → 1.0.0-beta-cc5b24e44326

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.
package/README.md CHANGED
@@ -390,9 +390,10 @@ The full call path, HTTP route, and a short description are listed below.
390
390
 
391
391
  ### Charges
392
392
 
393
- | Method | HTTP | Description |
394
- | --------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
395
- | `client.charges.list` | `GET /openmeter/charges` | List charges. Returns the charges of every customer that are represented as either flat fee or usage-based charges. |
393
+ | Method | HTTP | Description |
394
+ | --------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
395
+ | `client.charges.get` | `GET /openmeter/charges/{chargeId}` | Get a flat fee or usage-based charge by ID. Deleted charges are returned with their status and realization history. |
396
+ | `client.charges.list` | `GET /openmeter/charges` | List charges. Returns the charges of every customer that are represented as either flat fee or usage-based charges. |
396
397
 
397
398
  ### Tax
398
399
 
@@ -1,6 +1,16 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
- import type { ListChargesRequest, ListChargesResponse } from '../models/operations/charges.js';
3
+ import type { GetChargeRequest, GetChargeResponse, ListChargesRequest, ListChargesResponse } from '../models/operations/charges.js';
4
+ /**
5
+ * Get charge
6
+ *
7
+ * Get a flat fee or usage-based charge by ID.
8
+ *
9
+ * Deleted charges are returned with their status and realization history.
10
+ *
11
+ * GET /openmeter/charges/{chargeId}
12
+ */
13
+ export declare function getCharge(client: Client, req: GetChargeRequest, options?: RequestOptions): Promise<Result<GetChargeResponse>>;
4
14
  /**
5
15
  * List charges
6
16
  *
@@ -2,8 +2,52 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
+ /**
8
+ * Get charge
9
+ *
10
+ * Get a flat fee or usage-based charge by ID.
11
+ *
12
+ * Deleted charges are returned with their status and realization history.
13
+ *
14
+ * GET /openmeter/charges/{chargeId}
15
+ */
16
+ export function getCharge(client, req, options) {
17
+ return request(() => {
18
+ const pathParamsInput = {
19
+ chargeId: req.chargeId,
20
+ };
21
+ const pathParams = client._options.validate
22
+ ? toPathWire(pathParamsInput, schemas.getChargePathParams)
23
+ : pathParamsInput;
24
+ if (client._options.validate) {
25
+ assertValid(schemas.getChargePathParamsWire, pathParams);
26
+ }
27
+ const path = `openmeter/charges/${(() => {
28
+ if (pathParams.chargeId === undefined) {
29
+ throw new Error('missing path parameter: chargeId');
30
+ }
31
+ return encodeURIComponent(String(pathParams.chargeId));
32
+ })()}`;
33
+ const query = toWire({
34
+ expand: req.expand,
35
+ }, schemas.getChargeQueryParams);
36
+ if (client._options.validate) {
37
+ assertValid(schemas.getChargeQueryParamsWire, query);
38
+ }
39
+ const searchParams = toURLSearchParams(query);
40
+ return http(client)
41
+ .get(path, { ...options, searchParams })
42
+ .json()
43
+ .then((data) => {
44
+ if (client._options.validate) {
45
+ assertValid(schemas.getChargeResponseWire, data);
46
+ }
47
+ return fromWire(data, schemas.getChargeResponse);
48
+ });
49
+ });
50
+ }
7
51
  /**
8
52
  * List charges
9
53
  *
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.0.0-beta-c2050360536d";
1
+ export declare const SDK_VERSION = "1.0.0-beta-cc5b24e44326";
@@ -2,4 +2,4 @@
2
2
  // The committed value is a dev placeholder. The publish flow
3
3
  // (`make -C api/spec publish-aip-sdk`) stamps the real release version here
4
4
  // before `pnpm publish`, after `pnpm version` updates package.json.
5
- export const SDK_VERSION = '1.0.0-beta-c2050360536d';
5
+ export const SDK_VERSION = '1.0.0-beta-cc5b24e44326';
@@ -1,5 +1,13 @@
1
1
  import type { AcceptDateStrings } from '../../lib/wire.js';
2
- import type { ChargePagePaginatedResponse, ListChargesParamsFilter, SortQueryInput } from '../types.js';
2
+ import type { Charge, ChargePagePaginatedResponse, ListChargesParamsFilter, SortQueryInput } from '../types.js';
3
+ export interface GetChargeQuery {
4
+ /** Expand related entities, realization details, or real-time usage. */
5
+ expand?: ('real_time_usage' | 'customer' | 'feature' | 'subscription' | 'realization.invoice' | 'realization.totals' | 'realization.detailed_lines')[];
6
+ }
7
+ export type GetChargeRequest = AcceptDateStrings<GetChargeQuery & {
8
+ chargeId: string;
9
+ }>;
10
+ export type GetChargeResponse = Charge;
3
11
  export interface ListChargesQuery {
4
12
  /** Determines which page of the collection to retrieve. */
5
13
  page?: {