@openmeter/client 1.0.0-beta-4ffb0202fcfc → 1.0.0-beta-be2666bd959f
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 +7 -6
- package/dist/funcs/addons.js +111 -28
- package/dist/funcs/apps.js +37 -8
- package/dist/funcs/billing.js +79 -16
- package/dist/funcs/currencies.js +82 -22
- package/dist/funcs/customers.js +384 -99
- package/dist/funcs/defaults.js +24 -4
- package/dist/funcs/entitlements.js +19 -5
- package/dist/funcs/events.js +26 -8
- package/dist/funcs/features.js +99 -27
- package/dist/funcs/governance.js +27 -9
- package/dist/funcs/invoices.d.ts +2 -1
- package/dist/funcs/invoices.js +61 -11
- package/dist/funcs/llmCost.js +77 -23
- package/dist/funcs/meters.js +113 -32
- package/dist/funcs/planAddons.js +103 -28
- package/dist/funcs/plans.js +113 -24
- package/dist/funcs/subscriptions.js +175 -44
- package/dist/funcs/tax.js +78 -21
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/encodings.d.ts +1 -1
- package/dist/lib/encodings.js +5 -4
- package/dist/lib/wire.d.ts +14 -0
- package/dist/lib/wire.js +256 -0
- package/dist/models/operations/invoices.d.ts +6 -1
- package/dist/models/operations/tax.d.ts +1 -1
- package/dist/models/schemas.d.ts +22216 -3312
- package/dist/models/schemas.js +5545 -419
- package/dist/models/types.d.ts +979 -545
- package/dist/sdk/invoices.d.ts +2 -1
- package/dist/sdk/invoices.js +4 -1
- package/package.json +3 -2
package/dist/funcs/customers.js
CHANGED
|
@@ -1,155 +1,440 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function createCustomer(client, req, options) {
|
|
5
|
-
return request(() =>
|
|
6
|
-
|
|
7
|
-
.
|
|
7
|
+
return request(() => {
|
|
8
|
+
const body = toWire(req, schemas.createCustomerBody);
|
|
9
|
+
if (client._options.validate) {
|
|
10
|
+
assertValid(schemas.createCustomerBodyWire, body);
|
|
11
|
+
}
|
|
12
|
+
return http(client)
|
|
13
|
+
.post('openmeter/customers', { ...options, json: body })
|
|
14
|
+
.json()
|
|
15
|
+
.then((data) => {
|
|
16
|
+
if (client._options.validate) {
|
|
17
|
+
assertValid(schemas.createCustomerResponseWire, data);
|
|
18
|
+
}
|
|
19
|
+
return fromWire(data, schemas.createCustomerResponse);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
8
22
|
}
|
|
9
23
|
export function getCustomer(client, req, options) {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
return request(() => {
|
|
25
|
+
const path = `openmeter/customers/${(() => {
|
|
26
|
+
if (req.customerId === undefined) {
|
|
27
|
+
throw new Error('missing path parameter: customerId');
|
|
28
|
+
}
|
|
29
|
+
return encodeURIComponent(String(req.customerId));
|
|
30
|
+
})()}`;
|
|
31
|
+
return http(client)
|
|
32
|
+
.get(path, options)
|
|
33
|
+
.json()
|
|
34
|
+
.then((data) => {
|
|
35
|
+
if (client._options.validate) {
|
|
36
|
+
assertValid(schemas.getCustomerResponseWire, data);
|
|
37
|
+
}
|
|
38
|
+
return fromWire(data, schemas.getCustomerResponse);
|
|
39
|
+
});
|
|
12
40
|
});
|
|
13
|
-
return request(() => http(client).get(path, options).json());
|
|
14
41
|
}
|
|
15
42
|
export function listCustomers(client, req = {}, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
return request(() => {
|
|
44
|
+
const query = toWire({
|
|
45
|
+
page: req.page,
|
|
46
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
47
|
+
filter: req.filter,
|
|
48
|
+
}, schemas.listCustomersQueryParams);
|
|
49
|
+
if (client._options.validate) {
|
|
50
|
+
assertValid(schemas.listCustomersQueryParamsWire, query);
|
|
51
|
+
}
|
|
52
|
+
const searchParams = toURLSearchParams(query);
|
|
53
|
+
return http(client)
|
|
54
|
+
.get('openmeter/customers', { ...options, searchParams })
|
|
55
|
+
.json()
|
|
56
|
+
.then((data) => {
|
|
57
|
+
if (client._options.validate) {
|
|
58
|
+
assertValid(schemas.listCustomersResponseWire, data);
|
|
59
|
+
}
|
|
60
|
+
return fromWire(data, schemas.listCustomersResponse);
|
|
61
|
+
});
|
|
20
62
|
});
|
|
21
|
-
return request(() => http(client)
|
|
22
|
-
.get('openmeter/customers', { ...options, searchParams })
|
|
23
|
-
.json());
|
|
24
63
|
}
|
|
25
64
|
export function upsertCustomer(client, req, options) {
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
return request(() => {
|
|
66
|
+
const path = `openmeter/customers/${(() => {
|
|
67
|
+
if (req.customerId === undefined) {
|
|
68
|
+
throw new Error('missing path parameter: customerId');
|
|
69
|
+
}
|
|
70
|
+
return encodeURIComponent(String(req.customerId));
|
|
71
|
+
})()}`;
|
|
72
|
+
const body = toWire(req.body, schemas.upsertCustomerBody);
|
|
73
|
+
if (client._options.validate) {
|
|
74
|
+
assertValid(schemas.upsertCustomerBodyWire, body);
|
|
75
|
+
}
|
|
76
|
+
return http(client)
|
|
77
|
+
.put(path, { ...options, json: body })
|
|
78
|
+
.json()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.upsertCustomerResponseWire, data);
|
|
82
|
+
}
|
|
83
|
+
return fromWire(data, schemas.upsertCustomerResponse);
|
|
84
|
+
});
|
|
28
85
|
});
|
|
29
|
-
return request(() => http(client)
|
|
30
|
-
.put(path, { ...options, json: req.body })
|
|
31
|
-
.json());
|
|
32
86
|
}
|
|
33
87
|
export function deleteCustomer(client, req, options) {
|
|
34
|
-
const path = encodePath('openmeter/customers/{customerId}', {
|
|
35
|
-
customerId: req.customerId,
|
|
36
|
-
});
|
|
37
88
|
return request(async () => {
|
|
89
|
+
const path = `openmeter/customers/${(() => {
|
|
90
|
+
if (req.customerId === undefined) {
|
|
91
|
+
throw new Error('missing path parameter: customerId');
|
|
92
|
+
}
|
|
93
|
+
return encodeURIComponent(String(req.customerId));
|
|
94
|
+
})()}`;
|
|
38
95
|
await http(client).delete(path, options);
|
|
39
96
|
});
|
|
40
97
|
}
|
|
41
98
|
export function getCustomerBilling(client, req, options) {
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
return request(() => {
|
|
100
|
+
const path = `openmeter/customers/${(() => {
|
|
101
|
+
if (req.customerId === undefined) {
|
|
102
|
+
throw new Error('missing path parameter: customerId');
|
|
103
|
+
}
|
|
104
|
+
return encodeURIComponent(String(req.customerId));
|
|
105
|
+
})()}/billing`;
|
|
106
|
+
return http(client)
|
|
107
|
+
.get(path, options)
|
|
108
|
+
.json()
|
|
109
|
+
.then((data) => {
|
|
110
|
+
if (client._options.validate) {
|
|
111
|
+
assertValid(schemas.getCustomerBillingResponseWire, data);
|
|
112
|
+
}
|
|
113
|
+
return fromWire(data, schemas.getCustomerBillingResponse);
|
|
114
|
+
});
|
|
44
115
|
});
|
|
45
|
-
return request(() => http(client).get(path, options).json());
|
|
46
116
|
}
|
|
47
117
|
export function updateCustomerBilling(client, req, options) {
|
|
48
|
-
|
|
49
|
-
|
|
118
|
+
return request(() => {
|
|
119
|
+
const path = `openmeter/customers/${(() => {
|
|
120
|
+
if (req.customerId === undefined) {
|
|
121
|
+
throw new Error('missing path parameter: customerId');
|
|
122
|
+
}
|
|
123
|
+
return encodeURIComponent(String(req.customerId));
|
|
124
|
+
})()}/billing`;
|
|
125
|
+
const body = toWire(req.body, schemas.updateCustomerBillingBody);
|
|
126
|
+
if (client._options.validate) {
|
|
127
|
+
assertValid(schemas.updateCustomerBillingBodyWire, body);
|
|
128
|
+
}
|
|
129
|
+
return http(client)
|
|
130
|
+
.put(path, { ...options, json: body })
|
|
131
|
+
.json()
|
|
132
|
+
.then((data) => {
|
|
133
|
+
if (client._options.validate) {
|
|
134
|
+
assertValid(schemas.updateCustomerBillingResponseWire, data);
|
|
135
|
+
}
|
|
136
|
+
return fromWire(data, schemas.updateCustomerBillingResponse);
|
|
137
|
+
});
|
|
50
138
|
});
|
|
51
|
-
return request(() => http(client)
|
|
52
|
-
.put(path, { ...options, json: req.body })
|
|
53
|
-
.json());
|
|
54
139
|
}
|
|
55
140
|
export function updateCustomerBillingAppData(client, req, options) {
|
|
56
|
-
|
|
57
|
-
|
|
141
|
+
return request(() => {
|
|
142
|
+
const path = `openmeter/customers/${(() => {
|
|
143
|
+
if (req.customerId === undefined) {
|
|
144
|
+
throw new Error('missing path parameter: customerId');
|
|
145
|
+
}
|
|
146
|
+
return encodeURIComponent(String(req.customerId));
|
|
147
|
+
})()}/billing/app-data`;
|
|
148
|
+
const body = toWire(req.body, schemas.updateCustomerBillingAppDataBody);
|
|
149
|
+
if (client._options.validate) {
|
|
150
|
+
assertValid(schemas.updateCustomerBillingAppDataBodyWire, body);
|
|
151
|
+
}
|
|
152
|
+
return http(client)
|
|
153
|
+
.put(path, { ...options, json: body })
|
|
154
|
+
.json()
|
|
155
|
+
.then((data) => {
|
|
156
|
+
if (client._options.validate) {
|
|
157
|
+
assertValid(schemas.updateCustomerBillingAppDataResponseWire, data);
|
|
158
|
+
}
|
|
159
|
+
return fromWire(data, schemas.updateCustomerBillingAppDataResponse);
|
|
160
|
+
});
|
|
58
161
|
});
|
|
59
|
-
return request(() => http(client)
|
|
60
|
-
.put(path, { ...options, json: req.body })
|
|
61
|
-
.json());
|
|
62
162
|
}
|
|
63
163
|
export function createCustomerStripeCheckoutSession(client, req, options) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
164
|
+
return request(() => {
|
|
165
|
+
const path = `openmeter/customers/${(() => {
|
|
166
|
+
if (req.customerId === undefined) {
|
|
167
|
+
throw new Error('missing path parameter: customerId');
|
|
168
|
+
}
|
|
169
|
+
return encodeURIComponent(String(req.customerId));
|
|
170
|
+
})()}/billing/stripe/checkout-sessions`;
|
|
171
|
+
const body = toWire(req.body, schemas.createCustomerStripeCheckoutSessionBody);
|
|
172
|
+
if (client._options.validate) {
|
|
173
|
+
assertValid(schemas.createCustomerStripeCheckoutSessionBodyWire, body);
|
|
174
|
+
}
|
|
175
|
+
return http(client)
|
|
176
|
+
.post(path, { ...options, json: body })
|
|
177
|
+
.json()
|
|
178
|
+
.then((data) => {
|
|
179
|
+
if (client._options.validate) {
|
|
180
|
+
assertValid(schemas.createCustomerStripeCheckoutSessionResponseWire, data);
|
|
181
|
+
}
|
|
182
|
+
return fromWire(data, schemas.createCustomerStripeCheckoutSessionResponse);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
68
185
|
}
|
|
69
186
|
export function createCustomerStripePortalSession(client, req, options) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
187
|
+
return request(() => {
|
|
188
|
+
const path = `openmeter/customers/${(() => {
|
|
189
|
+
if (req.customerId === undefined) {
|
|
190
|
+
throw new Error('missing path parameter: customerId');
|
|
191
|
+
}
|
|
192
|
+
return encodeURIComponent(String(req.customerId));
|
|
193
|
+
})()}/billing/stripe/portal-sessions`;
|
|
194
|
+
const body = toWire(req.body, schemas.createCustomerStripePortalSessionBody);
|
|
195
|
+
if (client._options.validate) {
|
|
196
|
+
assertValid(schemas.createCustomerStripePortalSessionBodyWire, body);
|
|
197
|
+
}
|
|
198
|
+
return http(client)
|
|
199
|
+
.post(path, { ...options, json: body })
|
|
200
|
+
.json()
|
|
201
|
+
.then((data) => {
|
|
202
|
+
if (client._options.validate) {
|
|
203
|
+
assertValid(schemas.createCustomerStripePortalSessionResponseWire, data);
|
|
204
|
+
}
|
|
205
|
+
return fromWire(data, schemas.createCustomerStripePortalSessionResponse);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
74
208
|
}
|
|
75
209
|
export function createCreditGrant(client, req, options) {
|
|
76
|
-
|
|
77
|
-
|
|
210
|
+
return request(() => {
|
|
211
|
+
const path = `openmeter/customers/${(() => {
|
|
212
|
+
if (req.customerId === undefined) {
|
|
213
|
+
throw new Error('missing path parameter: customerId');
|
|
214
|
+
}
|
|
215
|
+
return encodeURIComponent(String(req.customerId));
|
|
216
|
+
})()}/credits/grants`;
|
|
217
|
+
const body = toWire(req.body, schemas.createCreditGrantBody);
|
|
218
|
+
if (client._options.validate) {
|
|
219
|
+
assertValid(schemas.createCreditGrantBodyWire, body);
|
|
220
|
+
}
|
|
221
|
+
return http(client)
|
|
222
|
+
.post(path, { ...options, json: body })
|
|
223
|
+
.json()
|
|
224
|
+
.then((data) => {
|
|
225
|
+
if (client._options.validate) {
|
|
226
|
+
assertValid(schemas.createCreditGrantResponseWire, data);
|
|
227
|
+
}
|
|
228
|
+
return fromWire(data, schemas.createCreditGrantResponse);
|
|
229
|
+
});
|
|
78
230
|
});
|
|
79
|
-
return request(() => http(client)
|
|
80
|
-
.post(path, { ...options, json: req.body })
|
|
81
|
-
.json());
|
|
82
231
|
}
|
|
83
232
|
export function getCreditGrant(client, req, options) {
|
|
84
|
-
|
|
85
|
-
|
|
233
|
+
return request(() => {
|
|
234
|
+
const path = `openmeter/customers/${(() => {
|
|
235
|
+
if (req.customerId === undefined) {
|
|
236
|
+
throw new Error('missing path parameter: customerId');
|
|
237
|
+
}
|
|
238
|
+
return encodeURIComponent(String(req.customerId));
|
|
239
|
+
})()}/credits/grants/${(() => {
|
|
240
|
+
if (req.creditGrantId === undefined) {
|
|
241
|
+
throw new Error('missing path parameter: creditGrantId');
|
|
242
|
+
}
|
|
243
|
+
return encodeURIComponent(String(req.creditGrantId));
|
|
244
|
+
})()}`;
|
|
245
|
+
return http(client)
|
|
246
|
+
.get(path, options)
|
|
247
|
+
.json()
|
|
248
|
+
.then((data) => {
|
|
249
|
+
if (client._options.validate) {
|
|
250
|
+
assertValid(schemas.getCreditGrantResponseWire, data);
|
|
251
|
+
}
|
|
252
|
+
return fromWire(data, schemas.getCreditGrantResponse);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
86
255
|
}
|
|
87
256
|
export function listCreditGrants(client, req, options) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
257
|
+
return request(() => {
|
|
258
|
+
const path = `openmeter/customers/${(() => {
|
|
259
|
+
if (req.customerId === undefined) {
|
|
260
|
+
throw new Error('missing path parameter: customerId');
|
|
261
|
+
}
|
|
262
|
+
return encodeURIComponent(String(req.customerId));
|
|
263
|
+
})()}/credits/grants`;
|
|
264
|
+
const query = toWire({
|
|
265
|
+
page: req.page,
|
|
266
|
+
filter: req.filter,
|
|
267
|
+
}, schemas.listCreditGrantsQueryParams);
|
|
268
|
+
if (client._options.validate) {
|
|
269
|
+
assertValid(schemas.listCreditGrantsQueryParamsWire, query);
|
|
270
|
+
}
|
|
271
|
+
const searchParams = toURLSearchParams(query);
|
|
272
|
+
return http(client)
|
|
273
|
+
.get(path, { ...options, searchParams })
|
|
274
|
+
.json()
|
|
275
|
+
.then((data) => {
|
|
276
|
+
if (client._options.validate) {
|
|
277
|
+
assertValid(schemas.listCreditGrantsResponseWire, data);
|
|
278
|
+
}
|
|
279
|
+
return fromWire(data, schemas.listCreditGrantsResponse);
|
|
280
|
+
});
|
|
91
281
|
});
|
|
92
|
-
const path = encodePath('openmeter/customers/{customerId}/credits/grants', {
|
|
93
|
-
customerId: req.customerId,
|
|
94
|
-
});
|
|
95
|
-
return request(() => http(client)
|
|
96
|
-
.get(path, { ...options, searchParams })
|
|
97
|
-
.json());
|
|
98
282
|
}
|
|
99
283
|
export function getCustomerCreditBalance(client, req, options) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
284
|
+
return request(() => {
|
|
285
|
+
const path = `openmeter/customers/${(() => {
|
|
286
|
+
if (req.customerId === undefined) {
|
|
287
|
+
throw new Error('missing path parameter: customerId');
|
|
288
|
+
}
|
|
289
|
+
return encodeURIComponent(String(req.customerId));
|
|
290
|
+
})()}/credits/balance`;
|
|
291
|
+
const query = toWire({
|
|
292
|
+
timestamp: req.timestamp,
|
|
293
|
+
filter: req.filter,
|
|
294
|
+
}, schemas.getCustomerCreditBalanceQueryParams);
|
|
295
|
+
if (client._options.validate) {
|
|
296
|
+
assertValid(schemas.getCustomerCreditBalanceQueryParamsWire, query);
|
|
297
|
+
}
|
|
298
|
+
const searchParams = toURLSearchParams(query);
|
|
299
|
+
return http(client)
|
|
300
|
+
.get(path, { ...options, searchParams })
|
|
301
|
+
.json()
|
|
302
|
+
.then((data) => {
|
|
303
|
+
if (client._options.validate) {
|
|
304
|
+
assertValid(schemas.getCustomerCreditBalanceResponseWire, data);
|
|
305
|
+
}
|
|
306
|
+
return fromWire(data, schemas.getCustomerCreditBalanceResponse);
|
|
307
|
+
});
|
|
106
308
|
});
|
|
107
|
-
return request(() => http(client)
|
|
108
|
-
.get(path, { ...options, searchParams })
|
|
109
|
-
.json());
|
|
110
309
|
}
|
|
111
310
|
export function createCreditAdjustment(client, req, options) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
311
|
+
return request(() => {
|
|
312
|
+
const path = `openmeter/customers/${(() => {
|
|
313
|
+
if (req.customerId === undefined) {
|
|
314
|
+
throw new Error('missing path parameter: customerId');
|
|
315
|
+
}
|
|
316
|
+
return encodeURIComponent(String(req.customerId));
|
|
317
|
+
})()}/credits/adjustments`;
|
|
318
|
+
const body = toWire(req.body, schemas.createCreditAdjustmentBody);
|
|
319
|
+
if (client._options.validate) {
|
|
320
|
+
assertValid(schemas.createCreditAdjustmentBodyWire, body);
|
|
321
|
+
}
|
|
322
|
+
return http(client)
|
|
323
|
+
.post(path, { ...options, json: body })
|
|
324
|
+
.json()
|
|
325
|
+
.then((data) => {
|
|
326
|
+
if (client._options.validate) {
|
|
327
|
+
assertValid(schemas.createCreditAdjustmentResponseWire, data);
|
|
328
|
+
}
|
|
329
|
+
return fromWire(data, schemas.createCreditAdjustmentResponse);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
116
332
|
}
|
|
117
333
|
export function updateCreditGrantExternalSettlement(client, req, options) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
334
|
+
return request(() => {
|
|
335
|
+
const path = `openmeter/customers/${(() => {
|
|
336
|
+
if (req.customerId === undefined) {
|
|
337
|
+
throw new Error('missing path parameter: customerId');
|
|
338
|
+
}
|
|
339
|
+
return encodeURIComponent(String(req.customerId));
|
|
340
|
+
})()}/credits/grants/${(() => {
|
|
341
|
+
if (req.creditGrantId === undefined) {
|
|
342
|
+
throw new Error('missing path parameter: creditGrantId');
|
|
343
|
+
}
|
|
344
|
+
return encodeURIComponent(String(req.creditGrantId));
|
|
345
|
+
})()}/settlement/external`;
|
|
346
|
+
const body = toWire(req.body, schemas.updateCreditGrantExternalSettlementBody);
|
|
347
|
+
if (client._options.validate) {
|
|
348
|
+
assertValid(schemas.updateCreditGrantExternalSettlementBodyWire, body);
|
|
349
|
+
}
|
|
350
|
+
return http(client)
|
|
351
|
+
.post(path, { ...options, json: body })
|
|
352
|
+
.json()
|
|
353
|
+
.then((data) => {
|
|
354
|
+
if (client._options.validate) {
|
|
355
|
+
assertValid(schemas.updateCreditGrantExternalSettlementResponseWire, data);
|
|
356
|
+
}
|
|
357
|
+
return fromWire(data, schemas.updateCreditGrantExternalSettlementResponse);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
122
360
|
}
|
|
123
361
|
export function listCreditTransactions(client, req, options) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
362
|
+
return request(() => {
|
|
363
|
+
const path = `openmeter/customers/${(() => {
|
|
364
|
+
if (req.customerId === undefined) {
|
|
365
|
+
throw new Error('missing path parameter: customerId');
|
|
366
|
+
}
|
|
367
|
+
return encodeURIComponent(String(req.customerId));
|
|
368
|
+
})()}/credits/transactions`;
|
|
369
|
+
const query = toWire({
|
|
370
|
+
page: req.page,
|
|
371
|
+
filter: req.filter,
|
|
372
|
+
}, schemas.listCreditTransactionsQueryParams);
|
|
373
|
+
if (client._options.validate) {
|
|
374
|
+
assertValid(schemas.listCreditTransactionsQueryParamsWire, query);
|
|
375
|
+
}
|
|
376
|
+
const searchParams = toURLSearchParams(query);
|
|
377
|
+
return http(client)
|
|
378
|
+
.get(path, { ...options, searchParams })
|
|
379
|
+
.json()
|
|
380
|
+
.then((data) => {
|
|
381
|
+
if (client._options.validate) {
|
|
382
|
+
assertValid(schemas.listCreditTransactionsResponseWire, data);
|
|
383
|
+
}
|
|
384
|
+
return fromWire(data, schemas.listCreditTransactionsResponse);
|
|
385
|
+
});
|
|
127
386
|
});
|
|
128
|
-
const path = encodePath('openmeter/customers/{customerId}/credits/transactions', { customerId: req.customerId });
|
|
129
|
-
return request(() => http(client)
|
|
130
|
-
.get(path, { ...options, searchParams })
|
|
131
|
-
.json());
|
|
132
387
|
}
|
|
133
388
|
export function listCustomerCharges(client, req, options) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
389
|
+
return request(() => {
|
|
390
|
+
const path = `openmeter/customers/${(() => {
|
|
391
|
+
if (req.customerId === undefined) {
|
|
392
|
+
throw new Error('missing path parameter: customerId');
|
|
393
|
+
}
|
|
394
|
+
return encodeURIComponent(String(req.customerId));
|
|
395
|
+
})()}/charges`;
|
|
396
|
+
const query = toWire({
|
|
397
|
+
page: req.page,
|
|
398
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
399
|
+
filter: req.filter,
|
|
400
|
+
expand: req.expand,
|
|
401
|
+
}, schemas.listCustomerChargesQueryParams);
|
|
402
|
+
if (client._options.validate) {
|
|
403
|
+
assertValid(schemas.listCustomerChargesQueryParamsWire, query);
|
|
404
|
+
}
|
|
405
|
+
const searchParams = toURLSearchParams(query);
|
|
406
|
+
return http(client)
|
|
407
|
+
.get(path, { ...options, searchParams })
|
|
408
|
+
.json()
|
|
409
|
+
.then((data) => {
|
|
410
|
+
if (client._options.validate) {
|
|
411
|
+
assertValid(schemas.listCustomerChargesResponseWire, data);
|
|
412
|
+
}
|
|
413
|
+
return fromWire(data, schemas.listCustomerChargesResponse);
|
|
414
|
+
});
|
|
142
415
|
});
|
|
143
|
-
return request(() => http(client)
|
|
144
|
-
.get(path, { ...options, searchParams })
|
|
145
|
-
.json());
|
|
146
416
|
}
|
|
147
417
|
export function createCustomerCharges(client, req, options) {
|
|
148
|
-
|
|
149
|
-
|
|
418
|
+
return request(() => {
|
|
419
|
+
const path = `openmeter/customers/${(() => {
|
|
420
|
+
if (req.customerId === undefined) {
|
|
421
|
+
throw new Error('missing path parameter: customerId');
|
|
422
|
+
}
|
|
423
|
+
return encodeURIComponent(String(req.customerId));
|
|
424
|
+
})()}/charges`;
|
|
425
|
+
const body = toWire(req.body, schemas.createCustomerChargesBody);
|
|
426
|
+
if (client._options.validate) {
|
|
427
|
+
assertValid(schemas.createCustomerChargesBodyWire, body);
|
|
428
|
+
}
|
|
429
|
+
return http(client)
|
|
430
|
+
.post(path, { ...options, json: body })
|
|
431
|
+
.json()
|
|
432
|
+
.then((data) => {
|
|
433
|
+
if (client._options.validate) {
|
|
434
|
+
assertValid(schemas.createCustomerChargesResponseWire, data);
|
|
435
|
+
}
|
|
436
|
+
return fromWire(data, schemas.createCustomerChargesResponse);
|
|
437
|
+
});
|
|
150
438
|
});
|
|
151
|
-
return request(() => http(client)
|
|
152
|
-
.post(path, { ...options, json: req.body })
|
|
153
|
-
.json());
|
|
154
439
|
}
|
|
155
440
|
//# sourceMappingURL=customers.js.map
|
package/dist/funcs/defaults.js
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
4
|
+
import * as schemas from '../models/schemas.js';
|
|
3
5
|
export function getOrganizationDefaultTaxCodes(client, req, options) {
|
|
4
6
|
return request(() => http(client)
|
|
5
7
|
.get('openmeter/defaults/tax-codes', options)
|
|
6
|
-
.json()
|
|
8
|
+
.json()
|
|
9
|
+
.then((data) => {
|
|
10
|
+
if (client._options.validate) {
|
|
11
|
+
assertValid(schemas.getOrganizationDefaultTaxCodesResponseWire, data);
|
|
12
|
+
}
|
|
13
|
+
return fromWire(data, schemas.getOrganizationDefaultTaxCodesResponse);
|
|
14
|
+
}));
|
|
7
15
|
}
|
|
8
16
|
export function updateOrganizationDefaultTaxCodes(client, req, options) {
|
|
9
|
-
return request(() =>
|
|
10
|
-
|
|
11
|
-
.
|
|
17
|
+
return request(() => {
|
|
18
|
+
const body = toWire(req, schemas.updateOrganizationDefaultTaxCodesBody);
|
|
19
|
+
if (client._options.validate) {
|
|
20
|
+
assertValid(schemas.updateOrganizationDefaultTaxCodesBodyWire, body);
|
|
21
|
+
}
|
|
22
|
+
return http(client)
|
|
23
|
+
.put('openmeter/defaults/tax-codes', { ...options, json: body })
|
|
24
|
+
.json()
|
|
25
|
+
.then((data) => {
|
|
26
|
+
if (client._options.validate) {
|
|
27
|
+
assertValid(schemas.updateOrganizationDefaultTaxCodesResponseWire, data);
|
|
28
|
+
}
|
|
29
|
+
return fromWire(data, schemas.updateOrganizationDefaultTaxCodesResponse);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
12
32
|
}
|
|
13
33
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { fromWire, assertValid } from '../lib/wire.js';
|
|
4
|
+
import * as schemas from '../models/schemas.js';
|
|
4
5
|
export function listCustomerEntitlementAccess(client, req, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return request(() => {
|
|
7
|
+
const path = `openmeter/customers/${(() => {
|
|
8
|
+
if (req.customerId === undefined) {
|
|
9
|
+
throw new Error('missing path parameter: customerId');
|
|
10
|
+
}
|
|
11
|
+
return encodeURIComponent(String(req.customerId));
|
|
12
|
+
})()}/entitlement-access`;
|
|
13
|
+
return http(client)
|
|
14
|
+
.get(path, options)
|
|
15
|
+
.json()
|
|
16
|
+
.then((data) => {
|
|
17
|
+
if (client._options.validate) {
|
|
18
|
+
assertValid(schemas.listCustomerEntitlementAccessResponseWire, data);
|
|
19
|
+
}
|
|
20
|
+
return fromWire(data, schemas.listCustomerEntitlementAccessResponse);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
9
23
|
}
|
|
10
24
|
//# sourceMappingURL=entitlements.js.map
|
package/dist/funcs/events.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
3
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function listMeteringEvents(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
page: req.page,
|
|
10
|
+
filter: req.filter,
|
|
11
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
12
|
+
}, schemas.listMeteringEventsQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listMeteringEventsQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/events', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listMeteringEventsResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listMeteringEventsResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/events', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function ingestMeteringEvents(client, req, options) {
|
|
15
29
|
return request(async () => {
|
|
16
|
-
|
|
30
|
+
const body = toWire(req, schemas.ingestMeteringEventsBody);
|
|
31
|
+
if (client._options.validate) {
|
|
32
|
+
assertValid(schemas.ingestMeteringEventsBodyWire, body);
|
|
33
|
+
}
|
|
34
|
+
await http(client).post('openmeter/events', { ...options, json: body });
|
|
17
35
|
});
|
|
18
36
|
}
|
|
19
37
|
//# sourceMappingURL=events.js.map
|