@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.
@@ -1,47 +1,122 @@
1
1
  import { http } from '../core.js';
2
2
  import { request } from '../lib/request.js';
3
- import { encodePath, toURLSearchParams } from '../lib/encodings.js';
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
- const searchParams = toURLSearchParams({
6
- page: req.page,
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
- const path = encodePath('openmeter/plans/{planId}/addons', {
17
- planId: req.planId,
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
- const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', {
25
- planId: req.planId,
26
- planAddonId: req.planAddonId,
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
- const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', {
32
- planId: req.planId,
33
- planAddonId: req.planAddonId,
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
  }
@@ -1,47 +1,136 @@
1
1
  import { http } from '../core.js';
2
2
  import { request } from '../lib/request.js';
3
- import { encodePath, toURLSearchParams, encodeSort } from '../lib/encodings.js';
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
- const searchParams = toURLSearchParams({
6
- page: req.page,
7
- sort: encodeSort(req.sort),
8
- filter: req.filter,
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(() => http(client)
16
- .post('openmeter/plans', { ...options, json: req })
17
- .json());
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
- const path = encodePath('openmeter/plans/{planId}', { planId: req.planId });
21
- return request(() => http(client)
22
- .put(path, { ...options, json: req.body })
23
- .json());
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
- const path = encodePath('openmeter/plans/{planId}', { planId: req.planId });
27
- return request(() => http(client).get(path, options).json());
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
- const path = encodePath('openmeter/plans/{planId}/archive', {
37
- planId: req.planId,
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
- const path = encodePath('openmeter/plans/{planId}/publish', {
43
- planId: req.planId,
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 { encodePath, toURLSearchParams, encodeSort } from '../lib/encodings.js';
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(() => http(client)
6
- .post('openmeter/subscriptions', { ...options, json: req })
7
- .json());
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
- const searchParams = toURLSearchParams({
11
- page: req.page,
12
- sort: encodeSort(req.sort),
13
- filter: req.filter,
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}', {
21
- subscriptionId: req.subscriptionId,
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/cancel', {
27
- subscriptionId: req.subscriptionId,
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/unschedule-cancelation', { subscriptionId: req.subscriptionId });
35
- return request(() => http(client).post(path, options).json());
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/change', {
39
- subscriptionId: req.subscriptionId,
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons', {
47
- subscriptionId: req.subscriptionId,
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
- const searchParams = toURLSearchParams({
55
- page: req.page,
56
- sort: encodeSort(req.sort),
57
- });
58
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons', {
59
- subscriptionId: req.subscriptionId,
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
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}', {
67
- subscriptionId: req.subscriptionId,
68
- subscriptionAddonId: req.subscriptionAddonId,
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 { encodePath, toURLSearchParams } from '../lib/encodings.js';
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(() => http(client)
6
- .post('openmeter/tax-codes', { ...options, json: req })
7
- .json());
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
- const path = encodePath('openmeter/tax-codes/{taxCodeId}', {
11
- taxCodeId: req.taxCodeId,
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
- const searchParams = toURLSearchParams({
17
- page: req.page,
18
- include_deleted: req.include_deleted,
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
- const path = encodePath('openmeter/tax-codes/{taxCodeId}', {
26
- taxCodeId: req.taxCodeId,
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
  }