@openmeter/client 1.0.0-beta.231 → 1.0.0-beta.233
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 +95 -54
- package/dist/core.js +7 -4
- package/dist/funcs/addons.js +59 -11
- package/dist/funcs/apps.d.ts +41 -1
- package/dist/funcs/apps.js +170 -4
- package/dist/funcs/billing.js +40 -8
- package/dist/funcs/charges.d.ts +14 -0
- package/dist/funcs/charges.js +42 -0
- package/dist/funcs/currencies.d.ts +9 -1
- package/dist/funcs/currencies.js +62 -5
- package/dist/funcs/customers.js +214 -43
- package/dist/funcs/{governance.d.ts → entitlementAccess.d.ts} +4 -4
- package/dist/funcs/{governance.js → entitlementAccess.js} +10 -10
- package/dist/funcs/entitlements.d.ts +9 -1
- package/dist/funcs/entitlements.js +61 -3
- package/dist/funcs/events.js +3 -0
- package/dist/funcs/features.js +48 -9
- package/dist/funcs/index.d.ts +2 -1
- package/dist/funcs/index.js +2 -1
- package/dist/funcs/invoices.d.ts +58 -1
- package/dist/funcs/invoices.js +202 -7
- package/dist/funcs/llmCost.js +26 -5
- package/dist/funcs/meters.js +59 -11
- package/dist/funcs/planAddons.js +71 -18
- package/dist/funcs/plans.js +59 -11
- package/dist/funcs/subscriptions.d.ts +60 -1
- package/dist/funcs/subscriptions.js +291 -17
- package/dist/funcs/tax.js +34 -7
- package/dist/index.d.ts +3 -2
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/paginate.d.ts +1 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/wire.d.ts +1 -0
- package/dist/lib/wire.js +88 -10
- package/dist/models/operations/apps.d.ts +41 -1
- package/dist/models/operations/billing.d.ts +19 -1
- package/dist/models/operations/charges.d.ts +54 -0
- package/dist/models/operations/currencies.d.ts +10 -0
- package/dist/models/operations/customers.d.ts +21 -6
- package/dist/models/operations/entitlementAccess.d.ts +9 -0
- package/dist/models/operations/entitlementAccess.js +2 -0
- package/dist/models/operations/entitlements.d.ts +18 -1
- package/dist/models/operations/invoices.d.ts +16 -0
- package/dist/models/operations/planAddons.d.ts +14 -1
- package/dist/models/operations/subscriptions.d.ts +27 -3
- package/dist/models/schemas.d.ts +52291 -22631
- package/dist/models/schemas.js +3981 -1823
- package/dist/models/types.d.ts +4481 -2018
- package/dist/sdk/apps.d.ts +1 -20
- package/dist/sdk/apps.js +1 -24
- package/dist/sdk/customers.d.ts +2 -56
- package/dist/sdk/customers.js +1 -67
- package/dist/sdk/entitlements.d.ts +9 -1
- package/dist/sdk/entitlements.js +11 -1
- package/dist/sdk/internal.d.ts +324 -15
- package/dist/sdk/internal.js +402 -17
- package/dist/sdk/invoices.d.ts +127 -0
- package/dist/sdk/invoices.js +147 -0
- package/dist/sdk/planAddons.d.ts +1 -20
- package/dist/sdk/planAddons.js +1 -24
- package/dist/sdk/subscriptions.d.ts +20 -1
- package/dist/sdk/subscriptions.js +24 -1
- package/package.json +3 -3
- package/dist/models/operations/governance.d.ts +0 -9
- /package/dist/models/operations/{governance.js → charges.js} +0 -0
package/dist/funcs/apps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
|
-
import { toURLSearchParams } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
4
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List apps
|
|
@@ -13,8 +13,13 @@ import * as schemas from '../models/schemas.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export function listApps(client, req = {}, options) {
|
|
15
15
|
return request(() => {
|
|
16
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
17
|
+
assertValid(schemas.listAppsQueryParams.shape.sort, req.sort);
|
|
18
|
+
}
|
|
16
19
|
const query = toWire({
|
|
17
20
|
page: req.page,
|
|
21
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
22
|
+
filter: req.filter,
|
|
18
23
|
}, schemas.listAppsQueryParams);
|
|
19
24
|
if (client._options.validate) {
|
|
20
25
|
assertValid(schemas.listAppsQueryParamsWire, query);
|
|
@@ -40,11 +45,20 @@ export function listApps(client, req = {}, options) {
|
|
|
40
45
|
*/
|
|
41
46
|
export function getApp(client, req, options) {
|
|
42
47
|
return request(() => {
|
|
48
|
+
const pathParamsInput = {
|
|
49
|
+
appId: req.appId,
|
|
50
|
+
};
|
|
51
|
+
const pathParams = client._options.validate
|
|
52
|
+
? toPathWire(pathParamsInput, schemas.getAppPathParams)
|
|
53
|
+
: pathParamsInput;
|
|
54
|
+
if (client._options.validate) {
|
|
55
|
+
assertValid(schemas.getAppPathParamsWire, pathParams);
|
|
56
|
+
}
|
|
43
57
|
const path = `openmeter/apps/${(() => {
|
|
44
|
-
if (
|
|
58
|
+
if (pathParams.appId === undefined) {
|
|
45
59
|
throw new Error('missing path parameter: appId');
|
|
46
60
|
}
|
|
47
|
-
return encodeURIComponent(String(
|
|
61
|
+
return encodeURIComponent(String(pathParams.appId));
|
|
48
62
|
})()}`;
|
|
49
63
|
return http(client)
|
|
50
64
|
.get(path, options)
|
|
@@ -57,3 +71,155 @@ export function getApp(client, req, options) {
|
|
|
57
71
|
});
|
|
58
72
|
});
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Uninstall app
|
|
76
|
+
*
|
|
77
|
+
* Uninstall an app by ID.
|
|
78
|
+
*
|
|
79
|
+
* DELETE /openmeter/apps/{appId}
|
|
80
|
+
*/
|
|
81
|
+
export function uninstallApp(client, req, options) {
|
|
82
|
+
return request(async () => {
|
|
83
|
+
const pathParamsInput = {
|
|
84
|
+
appId: req.appId,
|
|
85
|
+
};
|
|
86
|
+
const pathParams = client._options.validate
|
|
87
|
+
? toPathWire(pathParamsInput, schemas.uninstallAppPathParams)
|
|
88
|
+
: pathParamsInput;
|
|
89
|
+
if (client._options.validate) {
|
|
90
|
+
assertValid(schemas.uninstallAppPathParamsWire, pathParams);
|
|
91
|
+
}
|
|
92
|
+
const path = `openmeter/apps/${(() => {
|
|
93
|
+
if (pathParams.appId === undefined) {
|
|
94
|
+
throw new Error('missing path parameter: appId');
|
|
95
|
+
}
|
|
96
|
+
return encodeURIComponent(String(pathParams.appId));
|
|
97
|
+
})()}`;
|
|
98
|
+
await http(client).delete(path, options);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update app
|
|
103
|
+
*
|
|
104
|
+
* Update an installed app.
|
|
105
|
+
*
|
|
106
|
+
* PUT /openmeter/apps/{appId}
|
|
107
|
+
*/
|
|
108
|
+
export function updateApp(client, req, options) {
|
|
109
|
+
return request(() => {
|
|
110
|
+
const pathParamsInput = {
|
|
111
|
+
appId: req.appId,
|
|
112
|
+
};
|
|
113
|
+
const pathParams = client._options.validate
|
|
114
|
+
? toPathWire(pathParamsInput, schemas.updateAppPathParams)
|
|
115
|
+
: pathParamsInput;
|
|
116
|
+
if (client._options.validate) {
|
|
117
|
+
assertValid(schemas.updateAppPathParamsWire, pathParams);
|
|
118
|
+
}
|
|
119
|
+
const path = `openmeter/apps/${(() => {
|
|
120
|
+
if (pathParams.appId === undefined) {
|
|
121
|
+
throw new Error('missing path parameter: appId');
|
|
122
|
+
}
|
|
123
|
+
return encodeURIComponent(String(pathParams.appId));
|
|
124
|
+
})()}`;
|
|
125
|
+
const body = toWire(req.body, schemas.updateAppBody);
|
|
126
|
+
if (client._options.validate) {
|
|
127
|
+
assertValid(schemas.updateAppBodyWire, 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.updateAppResponseWire, data);
|
|
135
|
+
}
|
|
136
|
+
return fromWire(data, schemas.updateAppResponse);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* List app catalog
|
|
142
|
+
*
|
|
143
|
+
* List available apps.
|
|
144
|
+
*
|
|
145
|
+
* GET /openmeter/app-catalog
|
|
146
|
+
*/
|
|
147
|
+
export function listAppCatalog(client, req = {}, options) {
|
|
148
|
+
return request(() => {
|
|
149
|
+
const query = toWire({
|
|
150
|
+
page: req.page,
|
|
151
|
+
}, schemas.listAppCatalogQueryParams);
|
|
152
|
+
if (client._options.validate) {
|
|
153
|
+
assertValid(schemas.listAppCatalogQueryParamsWire, query);
|
|
154
|
+
}
|
|
155
|
+
const searchParams = toURLSearchParams(query);
|
|
156
|
+
return http(client)
|
|
157
|
+
.get('openmeter/app-catalog', { ...options, searchParams })
|
|
158
|
+
.json()
|
|
159
|
+
.then((data) => {
|
|
160
|
+
if (client._options.validate) {
|
|
161
|
+
assertValid(schemas.listAppCatalogResponseWire, data);
|
|
162
|
+
}
|
|
163
|
+
return fromWire(data, schemas.listAppCatalogResponse);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get app catalog item by type
|
|
169
|
+
*
|
|
170
|
+
* Get an app catalog item by type.
|
|
171
|
+
*
|
|
172
|
+
* GET /openmeter/app-catalog/{appType}
|
|
173
|
+
*/
|
|
174
|
+
export function getAppCatalogItem(client, req, options) {
|
|
175
|
+
return request(() => {
|
|
176
|
+
const pathParamsInput = {
|
|
177
|
+
appType: req.appType,
|
|
178
|
+
};
|
|
179
|
+
const pathParams = client._options.validate
|
|
180
|
+
? toPathWire(pathParamsInput, schemas.getAppCatalogItemPathParams)
|
|
181
|
+
: pathParamsInput;
|
|
182
|
+
if (client._options.validate) {
|
|
183
|
+
assertValid(schemas.getAppCatalogItemPathParamsWire, pathParams);
|
|
184
|
+
}
|
|
185
|
+
const path = `openmeter/app-catalog/${(() => {
|
|
186
|
+
if (pathParams.appType === undefined) {
|
|
187
|
+
throw new Error('missing path parameter: appType');
|
|
188
|
+
}
|
|
189
|
+
return encodeURIComponent(String(pathParams.appType));
|
|
190
|
+
})()}`;
|
|
191
|
+
return http(client)
|
|
192
|
+
.get(path, options)
|
|
193
|
+
.json()
|
|
194
|
+
.then((data) => {
|
|
195
|
+
if (client._options.validate) {
|
|
196
|
+
assertValid(schemas.getAppCatalogItemResponseWire, data);
|
|
197
|
+
}
|
|
198
|
+
return fromWire(data, schemas.getAppCatalogItemResponse);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Install app from the catalog
|
|
204
|
+
*
|
|
205
|
+
* Install an app from the catalog.
|
|
206
|
+
*
|
|
207
|
+
* POST /openmeter/app-catalog/install
|
|
208
|
+
*/
|
|
209
|
+
export function installApp(client, req, options) {
|
|
210
|
+
return request(() => {
|
|
211
|
+
const body = toWire(req, schemas.installAppBody);
|
|
212
|
+
if (client._options.validate) {
|
|
213
|
+
assertValid(schemas.installAppBodyWire, body);
|
|
214
|
+
}
|
|
215
|
+
return http(client)
|
|
216
|
+
.post('openmeter/app-catalog/install', { ...options, json: body })
|
|
217
|
+
.json()
|
|
218
|
+
.then((data) => {
|
|
219
|
+
if (client._options.validate) {
|
|
220
|
+
assertValid(schemas.installAppResponseWire, data);
|
|
221
|
+
}
|
|
222
|
+
return fromWire(data, schemas.installAppResponse);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
package/dist/funcs/billing.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
|
-
import { toURLSearchParams } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
4
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List billing profiles
|
|
@@ -13,8 +13,13 @@ import * as schemas from '../models/schemas.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export function listBillingProfiles(client, req = {}, options) {
|
|
15
15
|
return request(() => {
|
|
16
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
17
|
+
assertValid(schemas.listBillingProfilesQueryParams.shape.sort, req.sort);
|
|
18
|
+
}
|
|
16
19
|
const query = toWire({
|
|
17
20
|
page: req.page,
|
|
21
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
22
|
+
filter: req.filter,
|
|
18
23
|
}, schemas.listBillingProfilesQueryParams);
|
|
19
24
|
if (client._options.validate) {
|
|
20
25
|
assertValid(schemas.listBillingProfilesQueryParamsWire, query);
|
|
@@ -69,11 +74,20 @@ export function createBillingProfile(client, req, options) {
|
|
|
69
74
|
*/
|
|
70
75
|
export function getBillingProfile(client, req, options) {
|
|
71
76
|
return request(() => {
|
|
77
|
+
const pathParamsInput = {
|
|
78
|
+
id: req.id,
|
|
79
|
+
};
|
|
80
|
+
const pathParams = client._options.validate
|
|
81
|
+
? toPathWire(pathParamsInput, schemas.getBillingProfilePathParams)
|
|
82
|
+
: pathParamsInput;
|
|
83
|
+
if (client._options.validate) {
|
|
84
|
+
assertValid(schemas.getBillingProfilePathParamsWire, pathParams);
|
|
85
|
+
}
|
|
72
86
|
const path = `openmeter/profiles/${(() => {
|
|
73
|
-
if (
|
|
87
|
+
if (pathParams.id === undefined) {
|
|
74
88
|
throw new Error('missing path parameter: id');
|
|
75
89
|
}
|
|
76
|
-
return encodeURIComponent(String(
|
|
90
|
+
return encodeURIComponent(String(pathParams.id));
|
|
77
91
|
})()}`;
|
|
78
92
|
return http(client)
|
|
79
93
|
.get(path, options)
|
|
@@ -95,11 +109,20 @@ export function getBillingProfile(client, req, options) {
|
|
|
95
109
|
*/
|
|
96
110
|
export function updateBillingProfile(client, req, options) {
|
|
97
111
|
return request(() => {
|
|
112
|
+
const pathParamsInput = {
|
|
113
|
+
id: req.id,
|
|
114
|
+
};
|
|
115
|
+
const pathParams = client._options.validate
|
|
116
|
+
? toPathWire(pathParamsInput, schemas.updateBillingProfilePathParams)
|
|
117
|
+
: pathParamsInput;
|
|
118
|
+
if (client._options.validate) {
|
|
119
|
+
assertValid(schemas.updateBillingProfilePathParamsWire, pathParams);
|
|
120
|
+
}
|
|
98
121
|
const path = `openmeter/profiles/${(() => {
|
|
99
|
-
if (
|
|
122
|
+
if (pathParams.id === undefined) {
|
|
100
123
|
throw new Error('missing path parameter: id');
|
|
101
124
|
}
|
|
102
|
-
return encodeURIComponent(String(
|
|
125
|
+
return encodeURIComponent(String(pathParams.id));
|
|
103
126
|
})()}`;
|
|
104
127
|
const body = toWire(req.body, schemas.updateBillingProfileBody);
|
|
105
128
|
if (client._options.validate) {
|
|
@@ -131,11 +154,20 @@ export function updateBillingProfile(client, req, options) {
|
|
|
131
154
|
*/
|
|
132
155
|
export function deleteBillingProfile(client, req, options) {
|
|
133
156
|
return request(async () => {
|
|
157
|
+
const pathParamsInput = {
|
|
158
|
+
id: req.id,
|
|
159
|
+
};
|
|
160
|
+
const pathParams = client._options.validate
|
|
161
|
+
? toPathWire(pathParamsInput, schemas.deleteBillingProfilePathParams)
|
|
162
|
+
: pathParamsInput;
|
|
163
|
+
if (client._options.validate) {
|
|
164
|
+
assertValid(schemas.deleteBillingProfilePathParamsWire, pathParams);
|
|
165
|
+
}
|
|
134
166
|
const path = `openmeter/profiles/${(() => {
|
|
135
|
-
if (
|
|
167
|
+
if (pathParams.id === undefined) {
|
|
136
168
|
throw new Error('missing path parameter: id');
|
|
137
169
|
}
|
|
138
|
-
return encodeURIComponent(String(
|
|
170
|
+
return encodeURIComponent(String(pathParams.id));
|
|
139
171
|
})()}`;
|
|
140
172
|
await http(client).delete(path, options);
|
|
141
173
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Client } from '../core.js';
|
|
2
|
+
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
|
+
import type { ListChargesRequest, ListChargesResponse } from '../models/operations/charges.js';
|
|
4
|
+
/**
|
|
5
|
+
* List charges
|
|
6
|
+
*
|
|
7
|
+
* List charges.
|
|
8
|
+
*
|
|
9
|
+
* Returns the charges of every customer that are represented as either flat fee or
|
|
10
|
+
* usage-based charges.
|
|
11
|
+
*
|
|
12
|
+
* GET /openmeter/charges
|
|
13
|
+
*/
|
|
14
|
+
export declare function listCharges(client: Client, req?: ListChargesRequest, options?: RequestOptions): Promise<Result<ListChargesResponse>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
|
+
import { http } from '../core.js';
|
|
3
|
+
import { request } from '../lib/request.js';
|
|
4
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
6
|
+
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* List charges
|
|
9
|
+
*
|
|
10
|
+
* List charges.
|
|
11
|
+
*
|
|
12
|
+
* Returns the charges of every customer that are represented as either flat fee or
|
|
13
|
+
* usage-based charges.
|
|
14
|
+
*
|
|
15
|
+
* GET /openmeter/charges
|
|
16
|
+
*/
|
|
17
|
+
export function listCharges(client, req = {}, options) {
|
|
18
|
+
return request(() => {
|
|
19
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
20
|
+
assertValid(schemas.listChargesQueryParams.shape.sort, req.sort);
|
|
21
|
+
}
|
|
22
|
+
const query = toWire({
|
|
23
|
+
page: req.page,
|
|
24
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
25
|
+
filter: req.filter,
|
|
26
|
+
expand: req.expand,
|
|
27
|
+
}, schemas.listChargesQueryParams);
|
|
28
|
+
if (client._options.validate) {
|
|
29
|
+
assertValid(schemas.listChargesQueryParamsWire, query);
|
|
30
|
+
}
|
|
31
|
+
const searchParams = toURLSearchParams(query);
|
|
32
|
+
return http(client)
|
|
33
|
+
.get('openmeter/charges', { ...options, searchParams })
|
|
34
|
+
.json()
|
|
35
|
+
.then((data) => {
|
|
36
|
+
if (client._options.validate) {
|
|
37
|
+
assertValid(schemas.listChargesResponseWire, data);
|
|
38
|
+
}
|
|
39
|
+
return fromWire(data, schemas.listChargesResponse);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
|
-
import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse } from '../models/operations/currencies.js';
|
|
3
|
+
import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, GetCustomCurrencyRequest, GetCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse } from '../models/operations/currencies.js';
|
|
4
4
|
/**
|
|
5
5
|
* List currencies
|
|
6
6
|
*
|
|
@@ -18,6 +18,14 @@ export declare function listCurrencies(client: Client, req?: ListCurrenciesReque
|
|
|
18
18
|
* POST /openmeter/currencies/custom
|
|
19
19
|
*/
|
|
20
20
|
export declare function createCustomCurrency(client: Client, req: CreateCustomCurrencyRequest, options?: RequestOptions): Promise<Result<CreateCustomCurrencyResponse>>;
|
|
21
|
+
/**
|
|
22
|
+
* Get custom currency
|
|
23
|
+
*
|
|
24
|
+
* Get a custom currency.
|
|
25
|
+
*
|
|
26
|
+
* GET /openmeter/currencies/custom/{currencyId}
|
|
27
|
+
*/
|
|
28
|
+
export declare function getCustomCurrency(client: Client, req: GetCustomCurrencyRequest, options?: RequestOptions): Promise<Result<GetCustomCurrencyResponse>>;
|
|
21
29
|
/**
|
|
22
30
|
* List cost bases
|
|
23
31
|
*
|
package/dist/funcs/currencies.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
7
|
/**
|
|
8
8
|
* List currencies
|
|
@@ -13,10 +13,14 @@ import * as schemas from '../models/schemas.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export function listCurrencies(client, req = {}, options) {
|
|
15
15
|
return request(() => {
|
|
16
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
17
|
+
assertValid(schemas.listCurrenciesQueryParams.shape.sort, req.sort);
|
|
18
|
+
}
|
|
16
19
|
const query = toWire({
|
|
17
20
|
page: req.page,
|
|
18
21
|
sort: encodeSort(req.sort, toSnakeCase),
|
|
19
22
|
filter: req.filter,
|
|
23
|
+
expand: req.expand,
|
|
20
24
|
}, schemas.listCurrenciesQueryParams);
|
|
21
25
|
if (client._options.validate) {
|
|
22
26
|
assertValid(schemas.listCurrenciesQueryParamsWire, query);
|
|
@@ -58,6 +62,41 @@ export function createCustomCurrency(client, req, options) {
|
|
|
58
62
|
});
|
|
59
63
|
});
|
|
60
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Get custom currency
|
|
67
|
+
*
|
|
68
|
+
* Get a custom currency.
|
|
69
|
+
*
|
|
70
|
+
* GET /openmeter/currencies/custom/{currencyId}
|
|
71
|
+
*/
|
|
72
|
+
export function getCustomCurrency(client, req, options) {
|
|
73
|
+
return request(() => {
|
|
74
|
+
const pathParamsInput = {
|
|
75
|
+
currencyId: req.currencyId,
|
|
76
|
+
};
|
|
77
|
+
const pathParams = client._options.validate
|
|
78
|
+
? toPathWire(pathParamsInput, schemas.getCustomCurrencyPathParams)
|
|
79
|
+
: pathParamsInput;
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.getCustomCurrencyPathParamsWire, pathParams);
|
|
82
|
+
}
|
|
83
|
+
const path = `openmeter/currencies/custom/${(() => {
|
|
84
|
+
if (pathParams.currencyId === undefined) {
|
|
85
|
+
throw new Error('missing path parameter: currencyId');
|
|
86
|
+
}
|
|
87
|
+
return encodeURIComponent(String(pathParams.currencyId));
|
|
88
|
+
})()}`;
|
|
89
|
+
return http(client)
|
|
90
|
+
.get(path, options)
|
|
91
|
+
.json()
|
|
92
|
+
.then((data) => {
|
|
93
|
+
if (client._options.validate) {
|
|
94
|
+
assertValid(schemas.getCustomCurrencyResponseWire, data);
|
|
95
|
+
}
|
|
96
|
+
return fromWire(data, schemas.getCustomCurrencyResponse);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
61
100
|
/**
|
|
62
101
|
* List cost bases
|
|
63
102
|
*
|
|
@@ -68,11 +107,20 @@ export function createCustomCurrency(client, req, options) {
|
|
|
68
107
|
*/
|
|
69
108
|
export function listCostBases(client, req, options) {
|
|
70
109
|
return request(() => {
|
|
110
|
+
const pathParamsInput = {
|
|
111
|
+
currencyId: req.currencyId,
|
|
112
|
+
};
|
|
113
|
+
const pathParams = client._options.validate
|
|
114
|
+
? toPathWire(pathParamsInput, schemas.listCostBasesPathParams)
|
|
115
|
+
: pathParamsInput;
|
|
116
|
+
if (client._options.validate) {
|
|
117
|
+
assertValid(schemas.listCostBasesPathParamsWire, pathParams);
|
|
118
|
+
}
|
|
71
119
|
const path = `openmeter/currencies/custom/${(() => {
|
|
72
|
-
if (
|
|
120
|
+
if (pathParams.currencyId === undefined) {
|
|
73
121
|
throw new Error('missing path parameter: currencyId');
|
|
74
122
|
}
|
|
75
|
-
return encodeURIComponent(String(
|
|
123
|
+
return encodeURIComponent(String(pathParams.currencyId));
|
|
76
124
|
})()}/cost-bases`;
|
|
77
125
|
const query = toWire({
|
|
78
126
|
filter: req.filter,
|
|
@@ -102,11 +150,20 @@ export function listCostBases(client, req, options) {
|
|
|
102
150
|
*/
|
|
103
151
|
export function createCostBasis(client, req, options) {
|
|
104
152
|
return request(() => {
|
|
153
|
+
const pathParamsInput = {
|
|
154
|
+
currencyId: req.currencyId,
|
|
155
|
+
};
|
|
156
|
+
const pathParams = client._options.validate
|
|
157
|
+
? toPathWire(pathParamsInput, schemas.createCostBasisPathParams)
|
|
158
|
+
: pathParamsInput;
|
|
159
|
+
if (client._options.validate) {
|
|
160
|
+
assertValid(schemas.createCostBasisPathParamsWire, pathParams);
|
|
161
|
+
}
|
|
105
162
|
const path = `openmeter/currencies/custom/${(() => {
|
|
106
|
-
if (
|
|
163
|
+
if (pathParams.currencyId === undefined) {
|
|
107
164
|
throw new Error('missing path parameter: currencyId');
|
|
108
165
|
}
|
|
109
|
-
return encodeURIComponent(String(
|
|
166
|
+
return encodeURIComponent(String(pathParams.currencyId));
|
|
110
167
|
})()}/cost-bases`;
|
|
111
168
|
const body = toWire(req.body, schemas.createCostBasisBody);
|
|
112
169
|
if (client._options.validate) {
|