-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathevents.ts
More file actions
55 lines (52 loc) · 1.58 KB
/
Copy pathevents.ts
File metadata and controls
55 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { type Client, http } from '../core.js'
import { type Result, type RequestOptions } from '../lib/types.js'
import { request } from '../lib/request.js'
import { encodePath, toURLSearchParams, encodeSort } from '../lib/encodings.js'
import type {
ListMeteringEventsRequest,
ListMeteringEventsResponse,
IngestMeteringEventsRequest,
IngestMeteringEventsResponse,
ListEventSubjectsRequest,
ListEventSubjectsResponse,
} from '../models/operations/events.js'
export function listMeteringEvents(
client: Client,
req: ListMeteringEventsRequest = {},
options?: RequestOptions,
): Promise<Result<ListMeteringEventsResponse>> {
const searchParams = toURLSearchParams({
page: req.page,
filter: req.filter,
sort: encodeSort(req.sort),
})
return request(() =>
http(client)
.get('openmeter/events', { ...options, searchParams })
.json<ListMeteringEventsResponse>(),
)
}
export function ingestMeteringEvents(
client: Client,
req: IngestMeteringEventsRequest,
options?: RequestOptions,
): Promise<Result<IngestMeteringEventsResponse>> {
return request(async () => {
await http(client).post('openmeter/events', { ...options, json: req })
})
}
export function listEventSubjects(
client: Client,
req: ListEventSubjectsRequest = {},
options?: RequestOptions,
): Promise<Result<ListEventSubjectsResponse>> {
const searchParams = toURLSearchParams({
page: req.page,
filter: req.filter,
})
return request(() =>
http(client)
.get('openmeter/events/subjects', { ...options, searchParams })
.json<ListEventSubjectsResponse>(),
)
}