@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/planAddons.js
CHANGED
|
@@ -1,47 +1,122 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function listPlanAddons(client, req, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const path = `openmeter/plans/${(() => {
|
|
9
|
+
if (req.planId === undefined) {
|
|
10
|
+
throw new Error('missing path parameter: planId');
|
|
11
|
+
}
|
|
12
|
+
return encodeURIComponent(String(req.planId));
|
|
13
|
+
})()}/addons`;
|
|
14
|
+
const query = toWire({
|
|
15
|
+
page: req.page,
|
|
16
|
+
}, schemas.listPlanAddonsQueryParams);
|
|
17
|
+
if (client._options.validate) {
|
|
18
|
+
assertValid(schemas.listPlanAddonsQueryParamsWire, query);
|
|
19
|
+
}
|
|
20
|
+
const searchParams = toURLSearchParams(query);
|
|
21
|
+
return http(client)
|
|
22
|
+
.get(path, { ...options, searchParams })
|
|
23
|
+
.json()
|
|
24
|
+
.then((data) => {
|
|
25
|
+
if (client._options.validate) {
|
|
26
|
+
assertValid(schemas.listPlanAddonsResponseWire, data);
|
|
27
|
+
}
|
|
28
|
+
return fromWire(data, schemas.listPlanAddonsResponse);
|
|
29
|
+
});
|
|
7
30
|
});
|
|
8
|
-
const path = encodePath('openmeter/plans/{planId}/addons', {
|
|
9
|
-
planId: req.planId,
|
|
10
|
-
});
|
|
11
|
-
return request(() => http(client)
|
|
12
|
-
.get(path, { ...options, searchParams })
|
|
13
|
-
.json());
|
|
14
31
|
}
|
|
15
32
|
export function createPlanAddon(client, req, options) {
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
return request(() => {
|
|
34
|
+
const path = `openmeter/plans/${(() => {
|
|
35
|
+
if (req.planId === undefined) {
|
|
36
|
+
throw new Error('missing path parameter: planId');
|
|
37
|
+
}
|
|
38
|
+
return encodeURIComponent(String(req.planId));
|
|
39
|
+
})()}/addons`;
|
|
40
|
+
const body = toWire(req.body, schemas.createPlanAddonBody);
|
|
41
|
+
if (client._options.validate) {
|
|
42
|
+
assertValid(schemas.createPlanAddonBodyWire, body);
|
|
43
|
+
}
|
|
44
|
+
return http(client)
|
|
45
|
+
.post(path, { ...options, json: body })
|
|
46
|
+
.json()
|
|
47
|
+
.then((data) => {
|
|
48
|
+
if (client._options.validate) {
|
|
49
|
+
assertValid(schemas.createPlanAddonResponseWire, data);
|
|
50
|
+
}
|
|
51
|
+
return fromWire(data, schemas.createPlanAddonResponse);
|
|
52
|
+
});
|
|
18
53
|
});
|
|
19
|
-
return request(() => http(client)
|
|
20
|
-
.post(path, { ...options, json: req.body })
|
|
21
|
-
.json());
|
|
22
54
|
}
|
|
23
55
|
export function getPlanAddon(client, req, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
56
|
+
return request(() => {
|
|
57
|
+
const path = `openmeter/plans/${(() => {
|
|
58
|
+
if (req.planId === undefined) {
|
|
59
|
+
throw new Error('missing path parameter: planId');
|
|
60
|
+
}
|
|
61
|
+
return encodeURIComponent(String(req.planId));
|
|
62
|
+
})()}/addons/${(() => {
|
|
63
|
+
if (req.planAddonId === undefined) {
|
|
64
|
+
throw new Error('missing path parameter: planAddonId');
|
|
65
|
+
}
|
|
66
|
+
return encodeURIComponent(String(req.planAddonId));
|
|
67
|
+
})()}`;
|
|
68
|
+
return http(client)
|
|
69
|
+
.get(path, options)
|
|
70
|
+
.json()
|
|
71
|
+
.then((data) => {
|
|
72
|
+
if (client._options.validate) {
|
|
73
|
+
assertValid(schemas.getPlanAddonResponseWire, data);
|
|
74
|
+
}
|
|
75
|
+
return fromWire(data, schemas.getPlanAddonResponse);
|
|
76
|
+
});
|
|
27
77
|
});
|
|
28
|
-
return request(() => http(client).get(path, options).json());
|
|
29
78
|
}
|
|
30
79
|
export function updatePlanAddon(client, req, options) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
80
|
+
return request(() => {
|
|
81
|
+
const path = `openmeter/plans/${(() => {
|
|
82
|
+
if (req.planId === undefined) {
|
|
83
|
+
throw new Error('missing path parameter: planId');
|
|
84
|
+
}
|
|
85
|
+
return encodeURIComponent(String(req.planId));
|
|
86
|
+
})()}/addons/${(() => {
|
|
87
|
+
if (req.planAddonId === undefined) {
|
|
88
|
+
throw new Error('missing path parameter: planAddonId');
|
|
89
|
+
}
|
|
90
|
+
return encodeURIComponent(String(req.planAddonId));
|
|
91
|
+
})()}`;
|
|
92
|
+
const body = toWire(req.body, schemas.updatePlanAddonBody);
|
|
93
|
+
if (client._options.validate) {
|
|
94
|
+
assertValid(schemas.updatePlanAddonBodyWire, body);
|
|
95
|
+
}
|
|
96
|
+
return http(client)
|
|
97
|
+
.put(path, { ...options, json: body })
|
|
98
|
+
.json()
|
|
99
|
+
.then((data) => {
|
|
100
|
+
if (client._options.validate) {
|
|
101
|
+
assertValid(schemas.updatePlanAddonResponseWire, data);
|
|
102
|
+
}
|
|
103
|
+
return fromWire(data, schemas.updatePlanAddonResponse);
|
|
104
|
+
});
|
|
34
105
|
});
|
|
35
|
-
return request(() => http(client)
|
|
36
|
-
.put(path, { ...options, json: req.body })
|
|
37
|
-
.json());
|
|
38
106
|
}
|
|
39
107
|
export function deletePlanAddon(client, req, options) {
|
|
40
|
-
const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', {
|
|
41
|
-
planId: req.planId,
|
|
42
|
-
planAddonId: req.planAddonId,
|
|
43
|
-
});
|
|
44
108
|
return request(async () => {
|
|
109
|
+
const path = `openmeter/plans/${(() => {
|
|
110
|
+
if (req.planId === undefined) {
|
|
111
|
+
throw new Error('missing path parameter: planId');
|
|
112
|
+
}
|
|
113
|
+
return encodeURIComponent(String(req.planId));
|
|
114
|
+
})()}/addons/${(() => {
|
|
115
|
+
if (req.planAddonId === undefined) {
|
|
116
|
+
throw new Error('missing path parameter: planAddonId');
|
|
117
|
+
}
|
|
118
|
+
return encodeURIComponent(String(req.planAddonId));
|
|
119
|
+
})()}`;
|
|
45
120
|
await http(client).delete(path, options);
|
|
46
121
|
});
|
|
47
122
|
}
|
package/dist/funcs/plans.js
CHANGED
|
@@ -1,47 +1,136 @@
|
|
|
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 listPlans(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
page: req.page,
|
|
10
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
11
|
+
filter: req.filter,
|
|
12
|
+
}, schemas.listPlansQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listPlansQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/plans', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listPlansResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listPlansResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/plans', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function createPlan(client, req, options) {
|
|
15
|
-
return request(() =>
|
|
16
|
-
|
|
17
|
-
.
|
|
29
|
+
return request(() => {
|
|
30
|
+
const body = toWire(req, schemas.createPlanBody);
|
|
31
|
+
if (client._options.validate) {
|
|
32
|
+
assertValid(schemas.createPlanBodyWire, body);
|
|
33
|
+
}
|
|
34
|
+
return http(client)
|
|
35
|
+
.post('openmeter/plans', { ...options, json: body })
|
|
36
|
+
.json()
|
|
37
|
+
.then((data) => {
|
|
38
|
+
if (client._options.validate) {
|
|
39
|
+
assertValid(schemas.createPlanResponseWire, data);
|
|
40
|
+
}
|
|
41
|
+
return fromWire(data, schemas.createPlanResponse);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
18
44
|
}
|
|
19
45
|
export function updatePlan(client, req, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
return request(() => {
|
|
47
|
+
const path = `openmeter/plans/${(() => {
|
|
48
|
+
if (req.planId === undefined) {
|
|
49
|
+
throw new Error('missing path parameter: planId');
|
|
50
|
+
}
|
|
51
|
+
return encodeURIComponent(String(req.planId));
|
|
52
|
+
})()}`;
|
|
53
|
+
const body = toWire(req.body, schemas.updatePlanBody);
|
|
54
|
+
if (client._options.validate) {
|
|
55
|
+
assertValid(schemas.updatePlanBodyWire, body);
|
|
56
|
+
}
|
|
57
|
+
return http(client)
|
|
58
|
+
.put(path, { ...options, json: body })
|
|
59
|
+
.json()
|
|
60
|
+
.then((data) => {
|
|
61
|
+
if (client._options.validate) {
|
|
62
|
+
assertValid(schemas.updatePlanResponseWire, data);
|
|
63
|
+
}
|
|
64
|
+
return fromWire(data, schemas.updatePlanResponse);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
24
67
|
}
|
|
25
68
|
export function getPlan(client, req, options) {
|
|
26
|
-
|
|
27
|
-
|
|
69
|
+
return request(() => {
|
|
70
|
+
const path = `openmeter/plans/${(() => {
|
|
71
|
+
if (req.planId === undefined) {
|
|
72
|
+
throw new Error('missing path parameter: planId');
|
|
73
|
+
}
|
|
74
|
+
return encodeURIComponent(String(req.planId));
|
|
75
|
+
})()}`;
|
|
76
|
+
return http(client)
|
|
77
|
+
.get(path, options)
|
|
78
|
+
.json()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.getPlanResponseWire, data);
|
|
82
|
+
}
|
|
83
|
+
return fromWire(data, schemas.getPlanResponse);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
28
86
|
}
|
|
29
87
|
export function deletePlan(client, req, options) {
|
|
30
|
-
const path = encodePath('openmeter/plans/{planId}', { planId: req.planId });
|
|
31
88
|
return request(async () => {
|
|
89
|
+
const path = `openmeter/plans/${(() => {
|
|
90
|
+
if (req.planId === undefined) {
|
|
91
|
+
throw new Error('missing path parameter: planId');
|
|
92
|
+
}
|
|
93
|
+
return encodeURIComponent(String(req.planId));
|
|
94
|
+
})()}`;
|
|
32
95
|
await http(client).delete(path, options);
|
|
33
96
|
});
|
|
34
97
|
}
|
|
35
98
|
export function archivePlan(client, req, options) {
|
|
36
|
-
|
|
37
|
-
|
|
99
|
+
return request(() => {
|
|
100
|
+
const path = `openmeter/plans/${(() => {
|
|
101
|
+
if (req.planId === undefined) {
|
|
102
|
+
throw new Error('missing path parameter: planId');
|
|
103
|
+
}
|
|
104
|
+
return encodeURIComponent(String(req.planId));
|
|
105
|
+
})()}/archive`;
|
|
106
|
+
return http(client)
|
|
107
|
+
.post(path, options)
|
|
108
|
+
.json()
|
|
109
|
+
.then((data) => {
|
|
110
|
+
if (client._options.validate) {
|
|
111
|
+
assertValid(schemas.archivePlanResponseWire, data);
|
|
112
|
+
}
|
|
113
|
+
return fromWire(data, schemas.archivePlanResponse);
|
|
114
|
+
});
|
|
38
115
|
});
|
|
39
|
-
return request(() => http(client).post(path, options).json());
|
|
40
116
|
}
|
|
41
117
|
export function publishPlan(client, req, options) {
|
|
42
|
-
|
|
43
|
-
|
|
118
|
+
return request(() => {
|
|
119
|
+
const path = `openmeter/plans/${(() => {
|
|
120
|
+
if (req.planId === undefined) {
|
|
121
|
+
throw new Error('missing path parameter: planId');
|
|
122
|
+
}
|
|
123
|
+
return encodeURIComponent(String(req.planId));
|
|
124
|
+
})()}/publish`;
|
|
125
|
+
return http(client)
|
|
126
|
+
.post(path, options)
|
|
127
|
+
.json()
|
|
128
|
+
.then((data) => {
|
|
129
|
+
if (client._options.validate) {
|
|
130
|
+
assertValid(schemas.publishPlanResponseWire, data);
|
|
131
|
+
}
|
|
132
|
+
return fromWire(data, schemas.publishPlanResponse);
|
|
133
|
+
});
|
|
44
134
|
});
|
|
45
|
-
return request(() => http(client).post(path, options).json());
|
|
46
135
|
}
|
|
47
136
|
//# sourceMappingURL=plans.js.map
|
|
@@ -1,72 +1,203 @@
|
|
|
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 createSubscription(client, req, options) {
|
|
5
|
-
return request(() =>
|
|
6
|
-
|
|
7
|
-
.
|
|
7
|
+
return request(() => {
|
|
8
|
+
const body = toWire(req, schemas.createSubscriptionBody);
|
|
9
|
+
if (client._options.validate) {
|
|
10
|
+
assertValid(schemas.createSubscriptionBodyWire, body);
|
|
11
|
+
}
|
|
12
|
+
return http(client)
|
|
13
|
+
.post('openmeter/subscriptions', { ...options, json: body })
|
|
14
|
+
.json()
|
|
15
|
+
.then((data) => {
|
|
16
|
+
if (client._options.validate) {
|
|
17
|
+
assertValid(schemas.createSubscriptionResponseWire, data);
|
|
18
|
+
}
|
|
19
|
+
return fromWire(data, schemas.createSubscriptionResponse);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
8
22
|
}
|
|
9
23
|
export function listSubscriptions(client, req = {}, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
return request(() => {
|
|
25
|
+
const query = toWire({
|
|
26
|
+
page: req.page,
|
|
27
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
28
|
+
filter: req.filter,
|
|
29
|
+
}, schemas.listSubscriptionsQueryParams);
|
|
30
|
+
if (client._options.validate) {
|
|
31
|
+
assertValid(schemas.listSubscriptionsQueryParamsWire, query);
|
|
32
|
+
}
|
|
33
|
+
const searchParams = toURLSearchParams(query);
|
|
34
|
+
return http(client)
|
|
35
|
+
.get('openmeter/subscriptions', { ...options, searchParams })
|
|
36
|
+
.json()
|
|
37
|
+
.then((data) => {
|
|
38
|
+
if (client._options.validate) {
|
|
39
|
+
assertValid(schemas.listSubscriptionsResponseWire, data);
|
|
40
|
+
}
|
|
41
|
+
return fromWire(data, schemas.listSubscriptionsResponse);
|
|
42
|
+
});
|
|
14
43
|
});
|
|
15
|
-
return request(() => http(client)
|
|
16
|
-
.get('openmeter/subscriptions', { ...options, searchParams })
|
|
17
|
-
.json());
|
|
18
44
|
}
|
|
19
45
|
export function getSubscription(client, req, options) {
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
return request(() => {
|
|
47
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
48
|
+
if (req.subscriptionId === undefined) {
|
|
49
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
50
|
+
}
|
|
51
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
52
|
+
})()}`;
|
|
53
|
+
return http(client)
|
|
54
|
+
.get(path, options)
|
|
55
|
+
.json()
|
|
56
|
+
.then((data) => {
|
|
57
|
+
if (client._options.validate) {
|
|
58
|
+
assertValid(schemas.getSubscriptionResponseWire, data);
|
|
59
|
+
}
|
|
60
|
+
return fromWire(data, schemas.getSubscriptionResponse);
|
|
61
|
+
});
|
|
22
62
|
});
|
|
23
|
-
return request(() => http(client).get(path, options).json());
|
|
24
63
|
}
|
|
25
64
|
export function cancelSubscription(client, req, options) {
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
return request(() => {
|
|
66
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
67
|
+
if (req.subscriptionId === undefined) {
|
|
68
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
69
|
+
}
|
|
70
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
71
|
+
})()}/cancel`;
|
|
72
|
+
const body = toWire(req.body, schemas.cancelSubscriptionBody);
|
|
73
|
+
if (client._options.validate) {
|
|
74
|
+
assertValid(schemas.cancelSubscriptionBodyWire, body);
|
|
75
|
+
}
|
|
76
|
+
return http(client)
|
|
77
|
+
.post(path, { ...options, json: body })
|
|
78
|
+
.json()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.cancelSubscriptionResponseWire, data);
|
|
82
|
+
}
|
|
83
|
+
return fromWire(data, schemas.cancelSubscriptionResponse);
|
|
84
|
+
});
|
|
28
85
|
});
|
|
29
|
-
return request(() => http(client)
|
|
30
|
-
.post(path, { ...options, json: req.body })
|
|
31
|
-
.json());
|
|
32
86
|
}
|
|
33
87
|
export function unscheduleCancelation(client, req, options) {
|
|
34
|
-
|
|
35
|
-
|
|
88
|
+
return request(() => {
|
|
89
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
90
|
+
if (req.subscriptionId === undefined) {
|
|
91
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
92
|
+
}
|
|
93
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
94
|
+
})()}/unschedule-cancelation`;
|
|
95
|
+
return http(client)
|
|
96
|
+
.post(path, options)
|
|
97
|
+
.json()
|
|
98
|
+
.then((data) => {
|
|
99
|
+
if (client._options.validate) {
|
|
100
|
+
assertValid(schemas.unscheduleCancelationResponseWire, data);
|
|
101
|
+
}
|
|
102
|
+
return fromWire(data, schemas.unscheduleCancelationResponse);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
36
105
|
}
|
|
37
106
|
export function changeSubscription(client, req, options) {
|
|
38
|
-
|
|
39
|
-
|
|
107
|
+
return request(() => {
|
|
108
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
109
|
+
if (req.subscriptionId === undefined) {
|
|
110
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
111
|
+
}
|
|
112
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
113
|
+
})()}/change`;
|
|
114
|
+
const body = toWire(req.body, schemas.changeSubscriptionBody);
|
|
115
|
+
if (client._options.validate) {
|
|
116
|
+
assertValid(schemas.changeSubscriptionBodyWire, body);
|
|
117
|
+
}
|
|
118
|
+
return http(client)
|
|
119
|
+
.post(path, { ...options, json: body })
|
|
120
|
+
.json()
|
|
121
|
+
.then((data) => {
|
|
122
|
+
if (client._options.validate) {
|
|
123
|
+
assertValid(schemas.changeSubscriptionResponseWire, data);
|
|
124
|
+
}
|
|
125
|
+
return fromWire(data, schemas.changeSubscriptionResponse);
|
|
126
|
+
});
|
|
40
127
|
});
|
|
41
|
-
return request(() => http(client)
|
|
42
|
-
.post(path, { ...options, json: req.body })
|
|
43
|
-
.json());
|
|
44
128
|
}
|
|
45
129
|
export function createSubscriptionAddon(client, req, options) {
|
|
46
|
-
|
|
47
|
-
|
|
130
|
+
return request(() => {
|
|
131
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
132
|
+
if (req.subscriptionId === undefined) {
|
|
133
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
134
|
+
}
|
|
135
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
136
|
+
})()}/addons`;
|
|
137
|
+
const body = toWire(req.body, schemas.createSubscriptionAddonBody);
|
|
138
|
+
if (client._options.validate) {
|
|
139
|
+
assertValid(schemas.createSubscriptionAddonBodyWire, body);
|
|
140
|
+
}
|
|
141
|
+
return http(client)
|
|
142
|
+
.post(path, { ...options, json: body })
|
|
143
|
+
.json()
|
|
144
|
+
.then((data) => {
|
|
145
|
+
if (client._options.validate) {
|
|
146
|
+
assertValid(schemas.createSubscriptionAddonResponseWire, data);
|
|
147
|
+
}
|
|
148
|
+
return fromWire(data, schemas.createSubscriptionAddonResponse);
|
|
149
|
+
});
|
|
48
150
|
});
|
|
49
|
-
return request(() => http(client)
|
|
50
|
-
.post(path, { ...options, json: req.body })
|
|
51
|
-
.json());
|
|
52
151
|
}
|
|
53
152
|
export function listSubscriptionAddons(client, req, options) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
153
|
+
return request(() => {
|
|
154
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
155
|
+
if (req.subscriptionId === undefined) {
|
|
156
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
157
|
+
}
|
|
158
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
159
|
+
})()}/addons`;
|
|
160
|
+
const query = toWire({
|
|
161
|
+
page: req.page,
|
|
162
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
163
|
+
}, schemas.listSubscriptionAddonsQueryParams);
|
|
164
|
+
if (client._options.validate) {
|
|
165
|
+
assertValid(schemas.listSubscriptionAddonsQueryParamsWire, query);
|
|
166
|
+
}
|
|
167
|
+
const searchParams = toURLSearchParams(query);
|
|
168
|
+
return http(client)
|
|
169
|
+
.get(path, { ...options, searchParams })
|
|
170
|
+
.json()
|
|
171
|
+
.then((data) => {
|
|
172
|
+
if (client._options.validate) {
|
|
173
|
+
assertValid(schemas.listSubscriptionAddonsResponseWire, data);
|
|
174
|
+
}
|
|
175
|
+
return fromWire(data, schemas.listSubscriptionAddonsResponse);
|
|
176
|
+
});
|
|
60
177
|
});
|
|
61
|
-
return request(() => http(client)
|
|
62
|
-
.get(path, { ...options, searchParams })
|
|
63
|
-
.json());
|
|
64
178
|
}
|
|
65
179
|
export function getSubscriptionAddon(client, req, options) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
180
|
+
return request(() => {
|
|
181
|
+
const path = `openmeter/subscriptions/${(() => {
|
|
182
|
+
if (req.subscriptionId === undefined) {
|
|
183
|
+
throw new Error('missing path parameter: subscriptionId');
|
|
184
|
+
}
|
|
185
|
+
return encodeURIComponent(String(req.subscriptionId));
|
|
186
|
+
})()}/addons/${(() => {
|
|
187
|
+
if (req.subscriptionAddonId === undefined) {
|
|
188
|
+
throw new Error('missing path parameter: subscriptionAddonId');
|
|
189
|
+
}
|
|
190
|
+
return encodeURIComponent(String(req.subscriptionAddonId));
|
|
191
|
+
})()}`;
|
|
192
|
+
return http(client)
|
|
193
|
+
.get(path, options)
|
|
194
|
+
.json()
|
|
195
|
+
.then((data) => {
|
|
196
|
+
if (client._options.validate) {
|
|
197
|
+
assertValid(schemas.getSubscriptionAddonResponseWire, data);
|
|
198
|
+
}
|
|
199
|
+
return fromWire(data, schemas.getSubscriptionAddonResponse);
|
|
200
|
+
});
|
|
69
201
|
});
|
|
70
|
-
return request(() => http(client).get(path, options).json());
|
|
71
202
|
}
|
|
72
203
|
//# sourceMappingURL=subscriptions.js.map
|
package/dist/funcs/tax.js
CHANGED
|
@@ -1,39 +1,96 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function createTaxCode(client, req, options) {
|
|
5
|
-
return request(() =>
|
|
6
|
-
|
|
7
|
-
.
|
|
7
|
+
return request(() => {
|
|
8
|
+
const body = toWire(req, schemas.createTaxCodeBody);
|
|
9
|
+
if (client._options.validate) {
|
|
10
|
+
assertValid(schemas.createTaxCodeBodyWire, body);
|
|
11
|
+
}
|
|
12
|
+
return http(client)
|
|
13
|
+
.post('openmeter/tax-codes', { ...options, json: body })
|
|
14
|
+
.json()
|
|
15
|
+
.then((data) => {
|
|
16
|
+
if (client._options.validate) {
|
|
17
|
+
assertValid(schemas.createTaxCodeResponseWire, data);
|
|
18
|
+
}
|
|
19
|
+
return fromWire(data, schemas.createTaxCodeResponse);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
8
22
|
}
|
|
9
23
|
export function getTaxCode(client, req, options) {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
return request(() => {
|
|
25
|
+
const path = `openmeter/tax-codes/${(() => {
|
|
26
|
+
if (req.taxCodeId === undefined) {
|
|
27
|
+
throw new Error('missing path parameter: taxCodeId');
|
|
28
|
+
}
|
|
29
|
+
return encodeURIComponent(String(req.taxCodeId));
|
|
30
|
+
})()}`;
|
|
31
|
+
return http(client)
|
|
32
|
+
.get(path, options)
|
|
33
|
+
.json()
|
|
34
|
+
.then((data) => {
|
|
35
|
+
if (client._options.validate) {
|
|
36
|
+
assertValid(schemas.getTaxCodeResponseWire, data);
|
|
37
|
+
}
|
|
38
|
+
return fromWire(data, schemas.getTaxCodeResponse);
|
|
39
|
+
});
|
|
12
40
|
});
|
|
13
|
-
return request(() => http(client).get(path, options).json());
|
|
14
41
|
}
|
|
15
42
|
export function listTaxCodes(client, req = {}, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
return request(() => {
|
|
44
|
+
const query = toWire({
|
|
45
|
+
page: req.page,
|
|
46
|
+
includeDeleted: req.includeDeleted,
|
|
47
|
+
}, schemas.listTaxCodesQueryParams);
|
|
48
|
+
if (client._options.validate) {
|
|
49
|
+
assertValid(schemas.listTaxCodesQueryParamsWire, query);
|
|
50
|
+
}
|
|
51
|
+
const searchParams = toURLSearchParams(query);
|
|
52
|
+
return http(client)
|
|
53
|
+
.get('openmeter/tax-codes', { ...options, searchParams })
|
|
54
|
+
.json()
|
|
55
|
+
.then((data) => {
|
|
56
|
+
if (client._options.validate) {
|
|
57
|
+
assertValid(schemas.listTaxCodesResponseWire, data);
|
|
58
|
+
}
|
|
59
|
+
return fromWire(data, schemas.listTaxCodesResponse);
|
|
60
|
+
});
|
|
19
61
|
});
|
|
20
|
-
return request(() => http(client)
|
|
21
|
-
.get('openmeter/tax-codes', { ...options, searchParams })
|
|
22
|
-
.json());
|
|
23
62
|
}
|
|
24
63
|
export function upsertTaxCode(client, req, options) {
|
|
25
|
-
|
|
26
|
-
|
|
64
|
+
return request(() => {
|
|
65
|
+
const path = `openmeter/tax-codes/${(() => {
|
|
66
|
+
if (req.taxCodeId === undefined) {
|
|
67
|
+
throw new Error('missing path parameter: taxCodeId');
|
|
68
|
+
}
|
|
69
|
+
return encodeURIComponent(String(req.taxCodeId));
|
|
70
|
+
})()}`;
|
|
71
|
+
const body = toWire(req.body, schemas.upsertTaxCodeBody);
|
|
72
|
+
if (client._options.validate) {
|
|
73
|
+
assertValid(schemas.upsertTaxCodeBodyWire, body);
|
|
74
|
+
}
|
|
75
|
+
return http(client)
|
|
76
|
+
.put(path, { ...options, json: body })
|
|
77
|
+
.json()
|
|
78
|
+
.then((data) => {
|
|
79
|
+
if (client._options.validate) {
|
|
80
|
+
assertValid(schemas.upsertTaxCodeResponseWire, data);
|
|
81
|
+
}
|
|
82
|
+
return fromWire(data, schemas.upsertTaxCodeResponse);
|
|
83
|
+
});
|
|
27
84
|
});
|
|
28
|
-
return request(() => http(client)
|
|
29
|
-
.put(path, { ...options, json: req.body })
|
|
30
|
-
.json());
|
|
31
85
|
}
|
|
32
86
|
export function deleteTaxCode(client, req, options) {
|
|
33
|
-
const path = encodePath('openmeter/tax-codes/{taxCodeId}', {
|
|
34
|
-
taxCodeId: req.taxCodeId,
|
|
35
|
-
});
|
|
36
87
|
return request(async () => {
|
|
88
|
+
const path = `openmeter/tax-codes/${(() => {
|
|
89
|
+
if (req.taxCodeId === undefined) {
|
|
90
|
+
throw new Error('missing path parameter: taxCodeId');
|
|
91
|
+
}
|
|
92
|
+
return encodeURIComponent(String(req.taxCodeId));
|
|
93
|
+
})()}`;
|
|
37
94
|
await http(client).delete(path, options);
|
|
38
95
|
});
|
|
39
96
|
}
|