@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.
Files changed (67) hide show
  1. package/README.md +130 -111
  2. package/dist/funcs/addons.js +115 -28
  3. package/dist/funcs/apps.js +37 -10
  4. package/dist/funcs/billing.js +79 -18
  5. package/dist/funcs/currencies.js +82 -22
  6. package/dist/funcs/customers.d.ts +3 -1
  7. package/dist/funcs/customers.js +396 -83
  8. package/dist/funcs/defaults.js +24 -4
  9. package/dist/funcs/entitlements.js +19 -5
  10. package/dist/funcs/events.js +26 -8
  11. package/dist/funcs/features.js +102 -24
  12. package/dist/funcs/governance.js +27 -5
  13. package/dist/funcs/index.d.ts +1 -0
  14. package/dist/funcs/index.js +1 -0
  15. package/dist/funcs/invoices.d.ts +8 -0
  16. package/dist/funcs/invoices.js +81 -0
  17. package/dist/funcs/llmCost.js +78 -22
  18. package/dist/funcs/meters.d.ts +2 -1
  19. package/dist/funcs/meters.js +121 -24
  20. package/dist/funcs/planAddons.js +106 -20
  21. package/dist/funcs/plans.js +115 -28
  22. package/dist/funcs/subscriptions.d.ts +2 -1
  23. package/dist/funcs/subscriptions.js +182 -38
  24. package/dist/funcs/tax.js +80 -19
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +2 -0
  27. package/dist/lib/config.d.ts +9 -0
  28. package/dist/lib/config.js +1 -7
  29. package/dist/lib/encodings.d.ts +1 -1
  30. package/dist/lib/encodings.js +5 -4
  31. package/dist/lib/wire.d.ts +18 -0
  32. package/dist/lib/wire.js +312 -0
  33. package/dist/models/operations/addons.d.ts +17 -5
  34. package/dist/models/operations/apps.d.ts +2 -1
  35. package/dist/models/operations/billing.d.ts +5 -4
  36. package/dist/models/operations/currencies.d.ts +27 -9
  37. package/dist/models/operations/customers.d.ts +84 -33
  38. package/dist/models/operations/defaults.d.ts +2 -1
  39. package/dist/models/operations/events.d.ts +20 -4
  40. package/dist/models/operations/features.d.ts +24 -8
  41. package/dist/models/operations/governance.d.ts +3 -2
  42. package/dist/models/operations/invoices.d.ts +48 -0
  43. package/dist/models/operations/invoices.js +2 -0
  44. package/dist/models/operations/llmCost.d.ts +16 -4
  45. package/dist/models/operations/meters.d.ts +29 -8
  46. package/dist/models/operations/planAddons.d.ts +7 -6
  47. package/dist/models/operations/plans.d.ts +14 -5
  48. package/dist/models/operations/subscriptions.d.ts +36 -10
  49. package/dist/models/operations/tax.d.ts +6 -5
  50. package/dist/models/schemas.d.ts +27219 -3021
  51. package/dist/models/schemas.js +7079 -1362
  52. package/dist/models/types.d.ts +4309 -1046
  53. package/dist/sdk/apps.js +1 -1
  54. package/dist/sdk/customers.d.ts +3 -1
  55. package/dist/sdk/customers.js +7 -1
  56. package/dist/sdk/entitlements.js +1 -1
  57. package/dist/sdk/events.js +1 -1
  58. package/dist/sdk/governance.js +1 -1
  59. package/dist/sdk/invoices.d.ts +12 -0
  60. package/dist/sdk/invoices.js +21 -0
  61. package/dist/sdk/meters.d.ts +2 -1
  62. package/dist/sdk/meters.js +4 -1
  63. package/dist/sdk/sdk.d.ts +3 -0
  64. package/dist/sdk/sdk.js +5 -0
  65. package/dist/sdk/subscriptions.d.ts +2 -1
  66. package/dist/sdk/subscriptions.js +4 -1
  67. package/package.json +4 -3
@@ -1,36 +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', { planId: req.planId });
9
- return request(() => http(client)
10
- .get(path, { ...options, searchParams })
11
- .json());
12
31
  }
13
32
  export function createPlanAddon(client, req, options) {
14
- const path = encodePath('openmeter/plans/{planId}/addons', { planId: req.planId });
15
- return request(() => http(client)
16
- .post(path, { ...options, json: req.body })
17
- .json());
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
+ });
53
+ });
18
54
  }
19
55
  export function getPlanAddon(client, req, options) {
20
- const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', { planId: req.planId, planAddonId: req.planAddonId });
21
- return request(() => http(client)
22
- .get(path, options)
23
- .json());
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
+ });
77
+ });
24
78
  }
25
79
  export function updatePlanAddon(client, req, options) {
26
- const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', { planId: req.planId, planAddonId: req.planAddonId });
27
- return request(() => http(client)
28
- .put(path, { ...options, json: req.body })
29
- .json());
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
+ });
105
+ });
30
106
  }
31
107
  export function deletePlanAddon(client, req, options) {
32
- const path = encodePath('openmeter/plans/{planId}/addons/{planAddonId}', { planId: req.planId, planAddonId: req.planAddonId });
33
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
+ })()}`;
34
120
  await http(client).delete(path, options);
35
121
  });
36
122
  }
@@ -1,49 +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)
28
- .get(path, options)
29
- .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
+ });
30
86
  }
31
87
  export function deletePlan(client, req, options) {
32
- const path = encodePath('openmeter/plans/{planId}', { planId: req.planId });
33
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
+ })()}`;
34
95
  await http(client).delete(path, options);
35
96
  });
36
97
  }
37
98
  export function archivePlan(client, req, options) {
38
- const path = encodePath('openmeter/plans/{planId}/archive', { planId: req.planId });
39
- return request(() => http(client)
40
- .post(path, options)
41
- .json());
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
+ });
115
+ });
42
116
  }
43
117
  export function publishPlan(client, req, options) {
44
- const path = encodePath('openmeter/plans/{planId}/publish', { planId: req.planId });
45
- return request(() => http(client)
46
- .post(path, options)
47
- .json());
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
+ });
134
+ });
48
135
  }
49
136
  //# sourceMappingURL=plans.js.map
@@ -1,12 +1,13 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
- import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
3
+ import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
4
4
  export declare function createSubscription(client: Client, req: CreateSubscriptionRequest, options?: RequestOptions): Promise<Result<CreateSubscriptionResponse>>;
5
5
  export declare function listSubscriptions(client: Client, req?: ListSubscriptionsRequest, options?: RequestOptions): Promise<Result<ListSubscriptionsResponse>>;
6
6
  export declare function getSubscription(client: Client, req: GetSubscriptionRequest, options?: RequestOptions): Promise<Result<GetSubscriptionResponse>>;
7
7
  export declare function cancelSubscription(client: Client, req: CancelSubscriptionRequest, options?: RequestOptions): Promise<Result<CancelSubscriptionResponse>>;
8
8
  export declare function unscheduleCancelation(client: Client, req: UnscheduleCancelationRequest, options?: RequestOptions): Promise<Result<UnscheduleCancelationResponse>>;
9
9
  export declare function changeSubscription(client: Client, req: ChangeSubscriptionRequest, options?: RequestOptions): Promise<Result<ChangeSubscriptionResponse>>;
10
+ export declare function createSubscriptionAddon(client: Client, req: CreateSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<CreateSubscriptionAddonResponse>>;
10
11
  export declare function listSubscriptionAddons(client: Client, req: ListSubscriptionAddonsRequest, options?: RequestOptions): Promise<Result<ListSubscriptionAddonsResponse>>;
11
12
  export declare function getSubscriptionAddon(client: Client, req: GetSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<GetSubscriptionAddonResponse>>;
12
13
  //# sourceMappingURL=subscriptions.d.ts.map
@@ -1,59 +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}', { subscriptionId: req.subscriptionId });
21
- return request(() => http(client)
22
- .get(path, options)
23
- .json());
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
+ });
62
+ });
24
63
  }
25
64
  export function cancelSubscription(client, req, options) {
26
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/cancel', { subscriptionId: req.subscriptionId });
27
- return request(() => http(client)
28
- .post(path, { ...options, json: req.body })
29
- .json());
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
+ });
85
+ });
30
86
  }
31
87
  export function unscheduleCancelation(client, req, options) {
32
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/unschedule-cancelation', { subscriptionId: req.subscriptionId });
33
- return request(() => http(client)
34
- .post(path, options)
35
- .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', { subscriptionId: req.subscriptionId });
39
- return request(() => http(client)
40
- .post(path, { ...options, json: req.body })
41
- .json());
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
+ });
127
+ });
128
+ }
129
+ export function createSubscriptionAddon(client, req, options) {
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
+ });
150
+ });
42
151
  }
43
152
  export function listSubscriptionAddons(client, req, options) {
44
- const searchParams = toURLSearchParams({
45
- page: req.page,
46
- sort: encodeSort(req.sort),
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
+ });
47
177
  });
48
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons', { subscriptionId: req.subscriptionId });
49
- return request(() => http(client)
50
- .get(path, { ...options, searchParams })
51
- .json());
52
178
  }
53
179
  export function getSubscriptionAddon(client, req, options) {
54
- const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}', { subscriptionId: req.subscriptionId, subscriptionAddonId: req.subscriptionAddonId });
55
- return request(() => http(client)
56
- .get(path, options)
57
- .json());
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
+ });
201
+ });
58
202
  }
59
203
  //# sourceMappingURL=subscriptions.js.map