@openmeter/client 1.0.0-beta.228 → 1.0.0-beta.230
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 +130 -111
- package/dist/funcs/addons.js +115 -28
- package/dist/funcs/apps.js +37 -10
- package/dist/funcs/billing.js +79 -18
- package/dist/funcs/currencies.js +82 -22
- package/dist/funcs/customers.d.ts +3 -1
- package/dist/funcs/customers.js +396 -83
- 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 +102 -24
- package/dist/funcs/governance.js +27 -5
- package/dist/funcs/index.d.ts +1 -0
- package/dist/funcs/index.js +1 -0
- package/dist/funcs/invoices.d.ts +8 -0
- package/dist/funcs/invoices.js +81 -0
- package/dist/funcs/llmCost.js +78 -22
- package/dist/funcs/meters.d.ts +2 -1
- package/dist/funcs/meters.js +121 -24
- package/dist/funcs/planAddons.js +106 -20
- package/dist/funcs/plans.js +115 -28
- package/dist/funcs/subscriptions.d.ts +2 -1
- package/dist/funcs/subscriptions.js +182 -38
- package/dist/funcs/tax.js +80 -19
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/config.js +1 -7
- package/dist/lib/encodings.d.ts +1 -1
- package/dist/lib/encodings.js +5 -4
- package/dist/lib/wire.d.ts +18 -0
- package/dist/lib/wire.js +312 -0
- package/dist/models/operations/addons.d.ts +17 -5
- package/dist/models/operations/apps.d.ts +2 -1
- package/dist/models/operations/billing.d.ts +5 -4
- package/dist/models/operations/currencies.d.ts +27 -9
- package/dist/models/operations/customers.d.ts +84 -33
- package/dist/models/operations/defaults.d.ts +2 -1
- package/dist/models/operations/events.d.ts +20 -4
- package/dist/models/operations/features.d.ts +24 -8
- package/dist/models/operations/governance.d.ts +3 -2
- package/dist/models/operations/invoices.d.ts +48 -0
- package/dist/models/operations/invoices.js +2 -0
- package/dist/models/operations/llmCost.d.ts +16 -4
- package/dist/models/operations/meters.d.ts +29 -8
- package/dist/models/operations/planAddons.d.ts +7 -6
- package/dist/models/operations/plans.d.ts +14 -5
- package/dist/models/operations/subscriptions.d.ts +36 -10
- package/dist/models/operations/tax.d.ts +6 -5
- package/dist/models/schemas.d.ts +27219 -3021
- package/dist/models/schemas.js +7079 -1362
- package/dist/models/types.d.ts +4309 -1046
- package/dist/sdk/apps.js +1 -1
- package/dist/sdk/customers.d.ts +3 -1
- package/dist/sdk/customers.js +7 -1
- package/dist/sdk/entitlements.js +1 -1
- package/dist/sdk/events.js +1 -1
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/invoices.d.ts +12 -0
- package/dist/sdk/invoices.js +21 -0
- package/dist/sdk/meters.d.ts +2 -1
- package/dist/sdk/meters.js +4 -1
- package/dist/sdk/sdk.d.ts +3 -0
- package/dist/sdk/sdk.js +5 -0
- package/dist/sdk/subscriptions.d.ts +2 -1
- package/dist/sdk/subscriptions.js +4 -1
- package/package.json +4 -3
package/dist/funcs/customers.js
CHANGED
|
@@ -1,127 +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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
});
|
|
40
|
+
});
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
});
|
|
85
|
+
});
|
|
30
86
|
}
|
|
31
87
|
export function deleteCustomer(client, req, options) {
|
|
32
|
-
const path = encodePath('openmeter/customers/{customerId}', { customerId: req.customerId });
|
|
33
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
|
+
})()}`;
|
|
34
95
|
await http(client).delete(path, options);
|
|
35
96
|
});
|
|
36
97
|
}
|
|
37
98
|
export function getCustomerBilling(client, req, options) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
});
|
|
115
|
+
});
|
|
42
116
|
}
|
|
43
117
|
export function updateCustomerBilling(client, req, options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
});
|
|
138
|
+
});
|
|
48
139
|
}
|
|
49
140
|
export function updateCustomerBillingAppData(client, req, options) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
});
|
|
161
|
+
});
|
|
54
162
|
}
|
|
55
163
|
export function createCustomerStripeCheckoutSession(client, req, options) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
});
|
|
60
185
|
}
|
|
61
186
|
export function createCustomerStripePortalSession(client, req, options) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
});
|
|
66
208
|
}
|
|
67
209
|
export function createCreditGrant(client, req, options) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
});
|
|
230
|
+
});
|
|
72
231
|
}
|
|
73
232
|
export function getCreditGrant(client, req, options) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
});
|
|
78
255
|
}
|
|
79
256
|
export function listCreditGrants(client, req, options) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
});
|
|
83
281
|
});
|
|
84
|
-
const path = encodePath('openmeter/customers/{customerId}/credits/grants', { customerId: req.customerId });
|
|
85
|
-
return request(() => http(client)
|
|
86
|
-
.get(path, { ...options, searchParams })
|
|
87
|
-
.json());
|
|
88
282
|
}
|
|
89
283
|
export function getCustomerCreditBalance(client, req, options) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
});
|
|
93
308
|
});
|
|
94
|
-
const path = encodePath('openmeter/customers/{customerId}/credits/balance', { customerId: req.customerId });
|
|
95
|
-
return request(() => http(client)
|
|
96
|
-
.get(path, { ...options, searchParams })
|
|
97
|
-
.json());
|
|
98
309
|
}
|
|
99
310
|
export function createCreditAdjustment(client, req, options) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
});
|
|
332
|
+
}
|
|
333
|
+
export function updateCreditGrantExternalSettlement(client, req, options) {
|
|
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
|
+
});
|
|
104
360
|
}
|
|
105
361
|
export function listCreditTransactions(client, req, options) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
});
|
|
109
386
|
});
|
|
110
|
-
const path = encodePath('openmeter/customers/{customerId}/credits/transactions', { customerId: req.customerId });
|
|
111
|
-
return request(() => http(client)
|
|
112
|
-
.get(path, { ...options, searchParams })
|
|
113
|
-
.json());
|
|
114
387
|
}
|
|
115
388
|
export function listCustomerCharges(client, req, options) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
});
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export function createCustomerCharges(client, req, options) {
|
|
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
|
+
});
|
|
438
|
+
});
|
|
126
439
|
}
|
|
127
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
|