@paygentic/sdk 0.9.4 → 0.9.5

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 (188) hide show
  1. package/README.md +12 -5
  2. package/dist/commonjs/funcs/pricesUpdate.d.ts +1 -1
  3. package/dist/commonjs/funcs/pricesUpdate.d.ts.map +1 -1
  4. package/dist/commonjs/funcs/pricesUpdate.js +2 -2
  5. package/dist/commonjs/funcs/pricesUpdate.js.map +1 -1
  6. package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts +19 -0
  7. package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.js +127 -0
  9. package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.js.map +1 -0
  10. package/dist/commonjs/funcs/subscriptionsDeleteSubscriptionAdjustment.d.ts +18 -0
  11. package/dist/commonjs/funcs/subscriptionsDeleteSubscriptionAdjustment.d.ts.map +1 -0
  12. package/dist/commonjs/funcs/subscriptionsDeleteSubscriptionAdjustment.js +128 -0
  13. package/dist/commonjs/funcs/subscriptionsDeleteSubscriptionAdjustment.js.map +1 -0
  14. package/dist/commonjs/funcs/subscriptionsListSubscriptionAdjustments.d.ts +19 -0
  15. package/dist/commonjs/funcs/subscriptionsListSubscriptionAdjustments.d.ts.map +1 -0
  16. package/dist/commonjs/funcs/subscriptionsListSubscriptionAdjustments.js +129 -0
  17. package/dist/commonjs/funcs/subscriptionsListSubscriptionAdjustments.js.map +1 -0
  18. package/dist/commonjs/lib/config.d.ts +2 -2
  19. package/dist/commonjs/lib/config.js +2 -2
  20. package/dist/commonjs/models/createsubscriptionadjustmentrequest.d.ts +53 -0
  21. package/dist/commonjs/models/createsubscriptionadjustmentrequest.d.ts.map +1 -0
  22. package/dist/commonjs/models/createsubscriptionadjustmentrequest.js +63 -0
  23. package/dist/commonjs/models/createsubscriptionadjustmentrequest.js.map +1 -0
  24. package/dist/commonjs/models/errors/index.d.ts +1 -0
  25. package/dist/commonjs/models/errors/index.d.ts.map +1 -1
  26. package/dist/commonjs/models/errors/index.js +1 -0
  27. package/dist/commonjs/models/errors/index.js.map +1 -1
  28. package/dist/commonjs/models/errors/updateprice.d.ts +36 -0
  29. package/dist/commonjs/models/errors/updateprice.d.ts.map +1 -0
  30. package/dist/commonjs/models/errors/updateprice.js +77 -0
  31. package/dist/commonjs/models/errors/updateprice.js.map +1 -0
  32. package/dist/commonjs/models/index.d.ts +4 -1
  33. package/dist/commonjs/models/index.d.ts.map +1 -1
  34. package/dist/commonjs/models/index.js +4 -1
  35. package/dist/commonjs/models/index.js.map +1 -1
  36. package/dist/commonjs/models/operations/createprice.d.ts +2 -2
  37. package/dist/commonjs/models/operations/createprice.d.ts.map +1 -1
  38. package/dist/commonjs/models/operations/createprice.js +1 -1
  39. package/dist/commonjs/models/operations/createprice.js.map +1 -1
  40. package/dist/commonjs/models/operations/createsubscriptionadjustment.d.ts +18 -0
  41. package/dist/commonjs/models/operations/createsubscriptionadjustment.d.ts.map +1 -0
  42. package/dist/commonjs/models/operations/createsubscriptionadjustment.js +56 -0
  43. package/dist/commonjs/models/operations/createsubscriptionadjustment.js.map +1 -0
  44. package/dist/commonjs/models/operations/deletesubscriptionadjustment.d.ts +20 -0
  45. package/dist/commonjs/models/operations/deletesubscriptionadjustment.d.ts.map +1 -0
  46. package/dist/commonjs/models/operations/deletesubscriptionadjustment.js +50 -0
  47. package/dist/commonjs/models/operations/deletesubscriptionadjustment.js.map +1 -0
  48. package/dist/commonjs/models/operations/index.d.ts +3 -0
  49. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  50. package/dist/commonjs/models/operations/index.js +3 -0
  51. package/dist/commonjs/models/operations/index.js.map +1 -1
  52. package/dist/commonjs/models/operations/listsubscriptionadjustments.d.ts +25 -0
  53. package/dist/commonjs/models/operations/listsubscriptionadjustments.d.ts.map +1 -0
  54. package/dist/commonjs/models/operations/listsubscriptionadjustments.js +51 -0
  55. package/dist/commonjs/models/operations/listsubscriptionadjustments.js.map +1 -0
  56. package/dist/commonjs/models/operations/updateprice.d.ts +12 -2
  57. package/dist/commonjs/models/operations/updateprice.d.ts.map +1 -1
  58. package/dist/commonjs/models/operations/updateprice.js +13 -2
  59. package/dist/commonjs/models/operations/updateprice.js.map +1 -1
  60. package/dist/commonjs/models/priceproperties.d.ts +125 -0
  61. package/dist/commonjs/models/priceproperties.d.ts.map +1 -0
  62. package/dist/commonjs/models/priceproperties.js +152 -0
  63. package/dist/commonjs/models/priceproperties.js.map +1 -0
  64. package/dist/commonjs/models/schemasprice.d.ts +2 -2
  65. package/dist/commonjs/models/schemasprice.d.ts.map +1 -1
  66. package/dist/commonjs/models/schemasprice.js +2 -2
  67. package/dist/commonjs/models/schemasprice.js.map +1 -1
  68. package/dist/commonjs/models/subscriptionadjustment.d.ts +49 -0
  69. package/dist/commonjs/models/subscriptionadjustment.d.ts.map +1 -0
  70. package/dist/commonjs/models/subscriptionadjustment.js +68 -0
  71. package/dist/commonjs/models/subscriptionadjustment.js.map +1 -0
  72. package/dist/commonjs/models/subscriptionadjustmentsresponse.d.ts +16 -0
  73. package/dist/commonjs/models/subscriptionadjustmentsresponse.d.ts.map +1 -0
  74. package/dist/commonjs/models/subscriptionadjustmentsresponse.js +53 -0
  75. package/dist/commonjs/models/subscriptionadjustmentsresponse.js.map +1 -0
  76. package/dist/commonjs/sdk/subscriptions.d.ts +21 -0
  77. package/dist/commonjs/sdk/subscriptions.d.ts.map +1 -1
  78. package/dist/commonjs/sdk/subscriptions.js +30 -0
  79. package/dist/commonjs/sdk/subscriptions.js.map +1 -1
  80. package/dist/esm/funcs/pricesUpdate.d.ts +1 -1
  81. package/dist/esm/funcs/pricesUpdate.d.ts.map +1 -1
  82. package/dist/esm/funcs/pricesUpdate.js +2 -2
  83. package/dist/esm/funcs/pricesUpdate.js.map +1 -1
  84. package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts +19 -0
  85. package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts.map +1 -0
  86. package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.js +91 -0
  87. package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.js.map +1 -0
  88. package/dist/esm/funcs/subscriptionsDeleteSubscriptionAdjustment.d.ts +18 -0
  89. package/dist/esm/funcs/subscriptionsDeleteSubscriptionAdjustment.d.ts.map +1 -0
  90. package/dist/esm/funcs/subscriptionsDeleteSubscriptionAdjustment.js +92 -0
  91. package/dist/esm/funcs/subscriptionsDeleteSubscriptionAdjustment.js.map +1 -0
  92. package/dist/esm/funcs/subscriptionsListSubscriptionAdjustments.d.ts +19 -0
  93. package/dist/esm/funcs/subscriptionsListSubscriptionAdjustments.d.ts.map +1 -0
  94. package/dist/esm/funcs/subscriptionsListSubscriptionAdjustments.js +93 -0
  95. package/dist/esm/funcs/subscriptionsListSubscriptionAdjustments.js.map +1 -0
  96. package/dist/esm/lib/config.d.ts +2 -2
  97. package/dist/esm/lib/config.js +2 -2
  98. package/dist/esm/models/createsubscriptionadjustmentrequest.d.ts +53 -0
  99. package/dist/esm/models/createsubscriptionadjustmentrequest.d.ts.map +1 -0
  100. package/dist/esm/models/createsubscriptionadjustmentrequest.js +26 -0
  101. package/dist/esm/models/createsubscriptionadjustmentrequest.js.map +1 -0
  102. package/dist/esm/models/errors/index.d.ts +1 -0
  103. package/dist/esm/models/errors/index.d.ts.map +1 -1
  104. package/dist/esm/models/errors/index.js +1 -0
  105. package/dist/esm/models/errors/index.js.map +1 -1
  106. package/dist/esm/models/errors/updateprice.d.ts +36 -0
  107. package/dist/esm/models/errors/updateprice.d.ts.map +1 -0
  108. package/dist/esm/models/errors/updateprice.js +40 -0
  109. package/dist/esm/models/errors/updateprice.js.map +1 -0
  110. package/dist/esm/models/index.d.ts +4 -1
  111. package/dist/esm/models/index.d.ts.map +1 -1
  112. package/dist/esm/models/index.js +4 -1
  113. package/dist/esm/models/index.js.map +1 -1
  114. package/dist/esm/models/operations/createprice.d.ts +2 -2
  115. package/dist/esm/models/operations/createprice.d.ts.map +1 -1
  116. package/dist/esm/models/operations/createprice.js +1 -1
  117. package/dist/esm/models/operations/createprice.js.map +1 -1
  118. package/dist/esm/models/operations/createsubscriptionadjustment.d.ts +18 -0
  119. package/dist/esm/models/operations/createsubscriptionadjustment.d.ts.map +1 -0
  120. package/dist/esm/models/operations/createsubscriptionadjustment.js +19 -0
  121. package/dist/esm/models/operations/createsubscriptionadjustment.js.map +1 -0
  122. package/dist/esm/models/operations/deletesubscriptionadjustment.d.ts +20 -0
  123. package/dist/esm/models/operations/deletesubscriptionadjustment.d.ts.map +1 -0
  124. package/dist/esm/models/operations/deletesubscriptionadjustment.js +13 -0
  125. package/dist/esm/models/operations/deletesubscriptionadjustment.js.map +1 -0
  126. package/dist/esm/models/operations/index.d.ts +3 -0
  127. package/dist/esm/models/operations/index.d.ts.map +1 -1
  128. package/dist/esm/models/operations/index.js +3 -0
  129. package/dist/esm/models/operations/index.js.map +1 -1
  130. package/dist/esm/models/operations/listsubscriptionadjustments.d.ts +25 -0
  131. package/dist/esm/models/operations/listsubscriptionadjustments.d.ts.map +1 -0
  132. package/dist/esm/models/operations/listsubscriptionadjustments.js +14 -0
  133. package/dist/esm/models/operations/listsubscriptionadjustments.js.map +1 -0
  134. package/dist/esm/models/operations/updateprice.d.ts +12 -2
  135. package/dist/esm/models/operations/updateprice.d.ts.map +1 -1
  136. package/dist/esm/models/operations/updateprice.js +11 -1
  137. package/dist/esm/models/operations/updateprice.js.map +1 -1
  138. package/dist/esm/models/priceproperties.d.ts +125 -0
  139. package/dist/esm/models/priceproperties.d.ts.map +1 -0
  140. package/dist/esm/models/priceproperties.js +104 -0
  141. package/dist/esm/models/priceproperties.js.map +1 -0
  142. package/dist/esm/models/schemasprice.d.ts +2 -2
  143. package/dist/esm/models/schemasprice.d.ts.map +1 -1
  144. package/dist/esm/models/schemasprice.js +2 -2
  145. package/dist/esm/models/schemasprice.js.map +1 -1
  146. package/dist/esm/models/subscriptionadjustment.d.ts +49 -0
  147. package/dist/esm/models/subscriptionadjustment.d.ts.map +1 -0
  148. package/dist/esm/models/subscriptionadjustment.js +31 -0
  149. package/dist/esm/models/subscriptionadjustment.js.map +1 -0
  150. package/dist/esm/models/subscriptionadjustmentsresponse.d.ts +16 -0
  151. package/dist/esm/models/subscriptionadjustmentsresponse.d.ts.map +1 -0
  152. package/dist/esm/models/subscriptionadjustmentsresponse.js +16 -0
  153. package/dist/esm/models/subscriptionadjustmentsresponse.js.map +1 -0
  154. package/dist/esm/sdk/subscriptions.d.ts +21 -0
  155. package/dist/esm/sdk/subscriptions.d.ts.map +1 -1
  156. package/dist/esm/sdk/subscriptions.js +30 -0
  157. package/dist/esm/sdk/subscriptions.js.map +1 -1
  158. package/jsr.json +1 -1
  159. package/package.json +1 -1
  160. package/src/funcs/pricesUpdate.ts +5 -1
  161. package/src/funcs/subscriptionsCreateSubscriptionAdjustment.ts +186 -0
  162. package/src/funcs/subscriptionsDeleteSubscriptionAdjustment.ts +185 -0
  163. package/src/funcs/subscriptionsListSubscriptionAdjustments.ts +183 -0
  164. package/src/lib/config.ts +2 -2
  165. package/src/models/createsubscriptionadjustmentrequest.ts +85 -0
  166. package/src/models/errors/index.ts +1 -0
  167. package/src/models/errors/updateprice.ts +71 -0
  168. package/src/models/index.ts +4 -1
  169. package/src/models/operations/createprice.ts +3 -3
  170. package/src/models/operations/createsubscriptionadjustment.ts +48 -0
  171. package/src/models/operations/deletesubscriptionadjustment.ts +42 -0
  172. package/src/models/operations/index.ts +3 -0
  173. package/src/models/operations/listsubscriptionadjustments.ts +48 -0
  174. package/src/models/operations/updateprice.ts +33 -3
  175. package/src/models/priceproperties.ts +325 -0
  176. package/src/models/schemasprice.ts +5 -5
  177. package/src/models/subscriptionadjustment.ts +94 -0
  178. package/src/models/subscriptionadjustmentsresponse.ts +44 -0
  179. package/src/sdk/subscriptions.ts +54 -0
  180. package/dist/commonjs/models/pricepropertiesunion.d.ts +0 -152
  181. package/dist/commonjs/models/pricepropertiesunion.d.ts.map +0 -1
  182. package/dist/commonjs/models/pricepropertiesunion.js +0 -169
  183. package/dist/commonjs/models/pricepropertiesunion.js.map +0 -1
  184. package/dist/esm/models/pricepropertiesunion.d.ts +0 -152
  185. package/dist/esm/models/pricepropertiesunion.d.ts.map +0 -1
  186. package/dist/esm/models/pricepropertiesunion.js +0 -121
  187. package/dist/esm/models/pricepropertiesunion.js.map +0 -1
  188. package/src/models/pricepropertiesunion.ts +0 -364
@@ -0,0 +1,325 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ /**
11
+ * Percentage pricing model
12
+ */
13
+ export type PercentagePriceProperties = {
14
+ /**
15
+ * Ceiling amount limiting total charge regardless of percentage calculation. Sample values: '500.00' caps fees at $500 maximum, '2000.00' limits charges to $2000 per period
16
+ */
17
+ maxCharge: string;
18
+ /**
19
+ * Floor amount charged regardless of percentage calculation. Sample values: '5.00' ensures minimum $5 fee, '25.00' guarantees at least $25 per billing event
20
+ */
21
+ minCharge: string;
22
+ /**
23
+ * Rate expressed as decimal between 0 and 10, supporting up to 4 decimal precision. Sample values: '0.03' represents 3%, '0.075' represents 7.5%, '1.10' represents 110%
24
+ */
25
+ percentage: string;
26
+ };
27
+
28
+ export type VolumeTier = {
29
+ /**
30
+ * Inclusive upper bound of the band, as a decimal string. Null on the last band only, which carries the remainder. Sample values: '100' bounds the band at 100 units, null leaves the top open.
31
+ */
32
+ upTo: string | null;
33
+ /**
34
+ * Per-unit cost inside this band, as a decimal string, capped at 6 decimal places. Sample values: '5' represents $5 per unit, '0.004' represents $0.004 per unit.
35
+ */
36
+ unitPrice: string;
37
+ };
38
+
39
+ /**
40
+ * Volume pricing model
41
+ */
42
+ export type VolumePriceProperties = {
43
+ /**
44
+ * Ordered ladder of bands. The band is selected by the period's total metered usage, and its rate applies to every billed unit. A band matches when the quantity is less than or equal to its `upTo`, and the first matching band wins; the previous band's `upTo` is the exclusive lower bound, and the first band's floor is 0.
45
+ */
46
+ tiers: Array<VolumeTier>;
47
+ };
48
+
49
+ /**
50
+ * Dynamic pricing model
51
+ */
52
+ export type DynamicPriceProperties = {
53
+ /**
54
+ * Upper limit of the price range for dynamic pricing. Sample values: '0.10' means $0.10 per token for large volumes at peak times
55
+ */
56
+ maxPrice: string;
57
+ /**
58
+ * Lower limit of the price range for dynamic pricing. Sample values: '0.01' means $0.01 per token for low volumes during off-peak hours
59
+ */
60
+ minPrice: string;
61
+ };
62
+
63
+ /**
64
+ * Standard pricing model
65
+ */
66
+ export type StandardPriceProperties = {
67
+ /**
68
+ * Per-unit cost in decimal format for fixed-rate pricing. Sample values: '0.00002' represents $0.00002 per token, '0.15' represents $0.15 per gigabyte stored, '0.05' represents $0.05 per API call. Per unit. Total per period = quantity × unitPrice; see the `quantity` field. A negative value defines a usage-scaled rebate: the line's subtotal is negative and reduces the invoice. A rebate never drives an invoice total below zero, so set rebate rates below the charges they offset. A negative unitPrice is only valid on a metered price (a billableMetricId is required — there is no usage to scale on a fee price) and cannot be combined with grantDiscountEnabled, a hard-limit feature, or a pricingUnitId. When a rebate and a charge price share a billable metric but attach to different features, they compute against different quantity bases: a price attached to a feature bills the overage against its allowance, while a featureless price bills the raw metered usage. That is a permitted configuration, not an error. Attach both to the same feature to bill them against one basis.
69
+ */
70
+ unitPrice: string;
71
+ };
72
+
73
+ export type PriceProperties =
74
+ | PercentagePriceProperties
75
+ | DynamicPriceProperties
76
+ | StandardPriceProperties
77
+ | VolumePriceProperties;
78
+
79
+ /** @internal */
80
+ export const PercentagePriceProperties$inboundSchema: z.ZodType<
81
+ PercentagePriceProperties,
82
+ z.ZodTypeDef,
83
+ unknown
84
+ > = z.object({
85
+ maxCharge: z.string(),
86
+ minCharge: z.string(),
87
+ percentage: z.string(),
88
+ });
89
+ /** @internal */
90
+ export type PercentagePriceProperties$Outbound = {
91
+ maxCharge: string;
92
+ minCharge: string;
93
+ percentage: string;
94
+ };
95
+
96
+ /** @internal */
97
+ export const PercentagePriceProperties$outboundSchema: z.ZodType<
98
+ PercentagePriceProperties$Outbound,
99
+ z.ZodTypeDef,
100
+ PercentagePriceProperties
101
+ > = z.object({
102
+ maxCharge: z.string(),
103
+ minCharge: z.string(),
104
+ percentage: z.string(),
105
+ });
106
+
107
+ export function percentagePricePropertiesToJSON(
108
+ percentagePriceProperties: PercentagePriceProperties,
109
+ ): string {
110
+ return JSON.stringify(
111
+ PercentagePriceProperties$outboundSchema.parse(percentagePriceProperties),
112
+ );
113
+ }
114
+ export function percentagePricePropertiesFromJSON(
115
+ jsonString: string,
116
+ ): SafeParseResult<PercentagePriceProperties, SDKValidationError> {
117
+ return safeParse(
118
+ jsonString,
119
+ (x) => PercentagePriceProperties$inboundSchema.parse(JSON.parse(x)),
120
+ `Failed to parse 'PercentagePriceProperties' from JSON`,
121
+ );
122
+ }
123
+
124
+ /** @internal */
125
+ export const VolumeTier$inboundSchema: z.ZodType<
126
+ VolumeTier,
127
+ z.ZodTypeDef,
128
+ unknown
129
+ > = z.object({
130
+ upTo: z.nullable(z.string()),
131
+ unitPrice: z.string(),
132
+ });
133
+ /** @internal */
134
+ export type VolumeTier$Outbound = {
135
+ upTo: string | null;
136
+ unitPrice: string;
137
+ };
138
+
139
+ /** @internal */
140
+ export const VolumeTier$outboundSchema: z.ZodType<
141
+ VolumeTier$Outbound,
142
+ z.ZodTypeDef,
143
+ VolumeTier
144
+ > = z.object({
145
+ upTo: z.nullable(z.string()),
146
+ unitPrice: z.string(),
147
+ });
148
+
149
+ export function volumeTierToJSON(volumeTier: VolumeTier): string {
150
+ return JSON.stringify(VolumeTier$outboundSchema.parse(volumeTier));
151
+ }
152
+ export function volumeTierFromJSON(
153
+ jsonString: string,
154
+ ): SafeParseResult<VolumeTier, SDKValidationError> {
155
+ return safeParse(
156
+ jsonString,
157
+ (x) => VolumeTier$inboundSchema.parse(JSON.parse(x)),
158
+ `Failed to parse 'VolumeTier' from JSON`,
159
+ );
160
+ }
161
+
162
+ /** @internal */
163
+ export const VolumePriceProperties$inboundSchema: z.ZodType<
164
+ VolumePriceProperties,
165
+ z.ZodTypeDef,
166
+ unknown
167
+ > = z.object({
168
+ tiers: z.array(z.lazy(() => VolumeTier$inboundSchema)),
169
+ });
170
+ /** @internal */
171
+ export type VolumePriceProperties$Outbound = {
172
+ tiers: Array<VolumeTier$Outbound>;
173
+ };
174
+
175
+ /** @internal */
176
+ export const VolumePriceProperties$outboundSchema: z.ZodType<
177
+ VolumePriceProperties$Outbound,
178
+ z.ZodTypeDef,
179
+ VolumePriceProperties
180
+ > = z.object({
181
+ tiers: z.array(z.lazy(() => VolumeTier$outboundSchema)),
182
+ });
183
+
184
+ export function volumePricePropertiesToJSON(
185
+ volumePriceProperties: VolumePriceProperties,
186
+ ): string {
187
+ return JSON.stringify(
188
+ VolumePriceProperties$outboundSchema.parse(volumePriceProperties),
189
+ );
190
+ }
191
+ export function volumePricePropertiesFromJSON(
192
+ jsonString: string,
193
+ ): SafeParseResult<VolumePriceProperties, SDKValidationError> {
194
+ return safeParse(
195
+ jsonString,
196
+ (x) => VolumePriceProperties$inboundSchema.parse(JSON.parse(x)),
197
+ `Failed to parse 'VolumePriceProperties' from JSON`,
198
+ );
199
+ }
200
+
201
+ /** @internal */
202
+ export const DynamicPriceProperties$inboundSchema: z.ZodType<
203
+ DynamicPriceProperties,
204
+ z.ZodTypeDef,
205
+ unknown
206
+ > = z.object({
207
+ maxPrice: z.string(),
208
+ minPrice: z.string(),
209
+ });
210
+ /** @internal */
211
+ export type DynamicPriceProperties$Outbound = {
212
+ maxPrice: string;
213
+ minPrice: string;
214
+ };
215
+
216
+ /** @internal */
217
+ export const DynamicPriceProperties$outboundSchema: z.ZodType<
218
+ DynamicPriceProperties$Outbound,
219
+ z.ZodTypeDef,
220
+ DynamicPriceProperties
221
+ > = z.object({
222
+ maxPrice: z.string(),
223
+ minPrice: z.string(),
224
+ });
225
+
226
+ export function dynamicPricePropertiesToJSON(
227
+ dynamicPriceProperties: DynamicPriceProperties,
228
+ ): string {
229
+ return JSON.stringify(
230
+ DynamicPriceProperties$outboundSchema.parse(dynamicPriceProperties),
231
+ );
232
+ }
233
+ export function dynamicPricePropertiesFromJSON(
234
+ jsonString: string,
235
+ ): SafeParseResult<DynamicPriceProperties, SDKValidationError> {
236
+ return safeParse(
237
+ jsonString,
238
+ (x) => DynamicPriceProperties$inboundSchema.parse(JSON.parse(x)),
239
+ `Failed to parse 'DynamicPriceProperties' from JSON`,
240
+ );
241
+ }
242
+
243
+ /** @internal */
244
+ export const StandardPriceProperties$inboundSchema: z.ZodType<
245
+ StandardPriceProperties,
246
+ z.ZodTypeDef,
247
+ unknown
248
+ > = z.object({
249
+ unitPrice: z.string(),
250
+ });
251
+ /** @internal */
252
+ export type StandardPriceProperties$Outbound = {
253
+ unitPrice: string;
254
+ };
255
+
256
+ /** @internal */
257
+ export const StandardPriceProperties$outboundSchema: z.ZodType<
258
+ StandardPriceProperties$Outbound,
259
+ z.ZodTypeDef,
260
+ StandardPriceProperties
261
+ > = z.object({
262
+ unitPrice: z.string(),
263
+ });
264
+
265
+ export function standardPricePropertiesToJSON(
266
+ standardPriceProperties: StandardPriceProperties,
267
+ ): string {
268
+ return JSON.stringify(
269
+ StandardPriceProperties$outboundSchema.parse(standardPriceProperties),
270
+ );
271
+ }
272
+ export function standardPricePropertiesFromJSON(
273
+ jsonString: string,
274
+ ): SafeParseResult<StandardPriceProperties, SDKValidationError> {
275
+ return safeParse(
276
+ jsonString,
277
+ (x) => StandardPriceProperties$inboundSchema.parse(JSON.parse(x)),
278
+ `Failed to parse 'StandardPriceProperties' from JSON`,
279
+ );
280
+ }
281
+
282
+ /** @internal */
283
+ export const PriceProperties$inboundSchema: z.ZodType<
284
+ PriceProperties,
285
+ z.ZodTypeDef,
286
+ unknown
287
+ > = z.union([
288
+ z.lazy(() => PercentagePriceProperties$inboundSchema),
289
+ z.lazy(() => DynamicPriceProperties$inboundSchema),
290
+ z.lazy(() => StandardPriceProperties$inboundSchema),
291
+ z.lazy(() => VolumePriceProperties$inboundSchema),
292
+ ]);
293
+ /** @internal */
294
+ export type PriceProperties$Outbound =
295
+ | PercentagePriceProperties$Outbound
296
+ | DynamicPriceProperties$Outbound
297
+ | StandardPriceProperties$Outbound
298
+ | VolumePriceProperties$Outbound;
299
+
300
+ /** @internal */
301
+ export const PriceProperties$outboundSchema: z.ZodType<
302
+ PriceProperties$Outbound,
303
+ z.ZodTypeDef,
304
+ PriceProperties
305
+ > = z.union([
306
+ z.lazy(() => PercentagePriceProperties$outboundSchema),
307
+ z.lazy(() => DynamicPriceProperties$outboundSchema),
308
+ z.lazy(() => StandardPriceProperties$outboundSchema),
309
+ z.lazy(() => VolumePriceProperties$outboundSchema),
310
+ ]);
311
+
312
+ export function pricePropertiesToJSON(
313
+ priceProperties: PriceProperties,
314
+ ): string {
315
+ return JSON.stringify(PriceProperties$outboundSchema.parse(priceProperties));
316
+ }
317
+ export function pricePropertiesFromJSON(
318
+ jsonString: string,
319
+ ): SafeParseResult<PriceProperties, SDKValidationError> {
320
+ return safeParse(
321
+ jsonString,
322
+ (x) => PriceProperties$inboundSchema.parse(JSON.parse(x)),
323
+ `Failed to parse 'PriceProperties' from JSON`,
324
+ );
325
+ }
@@ -10,9 +10,9 @@ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
10
  import { PriceFeature, PriceFeature$inboundSchema } from "./pricefeature.js";
11
11
  import { PriceModel, PriceModel$inboundSchema } from "./pricemodel.js";
12
12
  import {
13
- PricePropertiesUnion,
14
- PricePropertiesUnion$inboundSchema,
15
- } from "./pricepropertiesunion.js";
13
+ PriceProperties,
14
+ PriceProperties$inboundSchema,
15
+ } from "./priceproperties.js";
16
16
 
17
17
  export const SchemasPriceObject = {
18
18
  Price: "price",
@@ -60,7 +60,7 @@ export type SchemasPrice = {
60
60
  */
61
61
  model?: PriceModel | undefined;
62
62
  paymentTerm: SchemasPricePaymentTerm;
63
- properties: PricePropertiesUnion;
63
+ properties: PriceProperties;
64
64
  updatedAt: Date;
65
65
  /**
66
66
  * Features associated with this price
@@ -103,7 +103,7 @@ export const SchemasPrice$inboundSchema: z.ZodType<
103
103
  invoiceDisplayName: z.string(),
104
104
  model: PriceModel$inboundSchema.optional(),
105
105
  paymentTerm: SchemasPricePaymentTerm$inboundSchema,
106
- properties: PricePropertiesUnion$inboundSchema,
106
+ properties: PriceProperties$inboundSchema,
107
107
  updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
108
108
  features: z.array(PriceFeature$inboundSchema).optional(),
109
109
  grantDiscountEnabled: z.boolean().default(false),
@@ -0,0 +1,94 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { ClosedEnum } from "../types/enums.js";
8
+ import { Result as SafeParseResult } from "../types/fp.js";
9
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+
11
+ export const SubscriptionAdjustmentObject = {
12
+ SubscriptionAdjustment: "subscriptionAdjustment",
13
+ } as const;
14
+ export type SubscriptionAdjustmentObject = ClosedEnum<
15
+ typeof SubscriptionAdjustmentObject
16
+ >;
17
+
18
+ export const SubscriptionAdjustmentType = {
19
+ PercentageDiscount: "percentageDiscount",
20
+ } as const;
21
+ export type SubscriptionAdjustmentType = ClosedEnum<
22
+ typeof SubscriptionAdjustmentType
23
+ >;
24
+
25
+ export type SubscriptionAdjustment = {
26
+ object: SubscriptionAdjustmentObject;
27
+ /**
28
+ * The adjustment ID
29
+ */
30
+ id: string;
31
+ /**
32
+ * Unique identifier for a subscription
33
+ */
34
+ subscriptionId: string;
35
+ type: SubscriptionAdjustmentType;
36
+ /**
37
+ * The discount rate as a decimal fraction between 0 and 1. "0.35" means 35 percent.
38
+ */
39
+ percentageDiscount: string;
40
+ /**
41
+ * The first instant the discount applies. Inclusive.
42
+ */
43
+ effectiveFrom: Date;
44
+ /**
45
+ * The instant the discount stops applying. Exclusive. Null means the discount never stops.
46
+ */
47
+ effectiveTo: Date | null;
48
+ /**
49
+ * The deal's own name, shown on each discount line of the invoice.
50
+ */
51
+ description: string | null;
52
+ createdAt: Date;
53
+ };
54
+
55
+ /** @internal */
56
+ export const SubscriptionAdjustmentObject$inboundSchema: z.ZodNativeEnum<
57
+ typeof SubscriptionAdjustmentObject
58
+ > = z.nativeEnum(SubscriptionAdjustmentObject);
59
+
60
+ /** @internal */
61
+ export const SubscriptionAdjustmentType$inboundSchema: z.ZodNativeEnum<
62
+ typeof SubscriptionAdjustmentType
63
+ > = z.nativeEnum(SubscriptionAdjustmentType);
64
+
65
+ /** @internal */
66
+ export const SubscriptionAdjustment$inboundSchema: z.ZodType<
67
+ SubscriptionAdjustment,
68
+ z.ZodTypeDef,
69
+ unknown
70
+ > = z.object({
71
+ object: SubscriptionAdjustmentObject$inboundSchema,
72
+ id: z.string(),
73
+ subscriptionId: z.string(),
74
+ type: SubscriptionAdjustmentType$inboundSchema,
75
+ percentageDiscount: z.string(),
76
+ effectiveFrom: z.string().datetime({ offset: true }).transform(v =>
77
+ new Date(v)
78
+ ),
79
+ effectiveTo: z.nullable(
80
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
81
+ ),
82
+ description: z.nullable(z.string()),
83
+ createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
84
+ });
85
+
86
+ export function subscriptionAdjustmentFromJSON(
87
+ jsonString: string,
88
+ ): SafeParseResult<SubscriptionAdjustment, SDKValidationError> {
89
+ return safeParse(
90
+ jsonString,
91
+ (x) => SubscriptionAdjustment$inboundSchema.parse(JSON.parse(x)),
92
+ `Failed to parse 'SubscriptionAdjustment' from JSON`,
93
+ );
94
+ }
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+ import {
10
+ OffsetPagination,
11
+ OffsetPagination$inboundSchema,
12
+ } from "./offsetpagination.js";
13
+ import {
14
+ SubscriptionAdjustment,
15
+ SubscriptionAdjustment$inboundSchema,
16
+ } from "./subscriptionadjustment.js";
17
+
18
+ export type SubscriptionAdjustmentsResponse = {
19
+ data: Array<SubscriptionAdjustment>;
20
+ /**
21
+ * Offset-based pagination response.
22
+ */
23
+ pagination: OffsetPagination;
24
+ };
25
+
26
+ /** @internal */
27
+ export const SubscriptionAdjustmentsResponse$inboundSchema: z.ZodType<
28
+ SubscriptionAdjustmentsResponse,
29
+ z.ZodTypeDef,
30
+ unknown
31
+ > = z.object({
32
+ data: z.array(SubscriptionAdjustment$inboundSchema),
33
+ pagination: OffsetPagination$inboundSchema,
34
+ });
35
+
36
+ export function subscriptionAdjustmentsResponseFromJSON(
37
+ jsonString: string,
38
+ ): SafeParseResult<SubscriptionAdjustmentsResponse, SDKValidationError> {
39
+ return safeParse(
40
+ jsonString,
41
+ (x) => SubscriptionAdjustmentsResponse$inboundSchema.parse(JSON.parse(x)),
42
+ `Failed to parse 'SubscriptionAdjustmentsResponse' from JSON`,
43
+ );
44
+ }
@@ -3,9 +3,12 @@
3
3
  */
4
4
 
5
5
  import { subscriptionsCreate } from "../funcs/subscriptionsCreate.js";
6
+ import { subscriptionsCreateSubscriptionAdjustment } from "../funcs/subscriptionsCreateSubscriptionAdjustment.js";
7
+ import { subscriptionsDeleteSubscriptionAdjustment } from "../funcs/subscriptionsDeleteSubscriptionAdjustment.js";
6
8
  import { subscriptionsGeneratePortalLink } from "../funcs/subscriptionsGeneratePortalLink.js";
7
9
  import { subscriptionsGet } from "../funcs/subscriptionsGet.js";
8
10
  import { subscriptionsList } from "../funcs/subscriptionsList.js";
11
+ import { subscriptionsListSubscriptionAdjustments } from "../funcs/subscriptionsListSubscriptionAdjustments.js";
9
12
  import { subscriptionsReconcileSubscriptionFeatures } from "../funcs/subscriptionsReconcileSubscriptionFeatures.js";
10
13
  import { subscriptionsTerminate } from "../funcs/subscriptionsTerminate.js";
11
14
  import { subscriptionsUpdateSubscription } from "../funcs/subscriptionsUpdateSubscription.js";
@@ -124,4 +127,55 @@ export class Subscriptions extends ClientSDK {
124
127
  options,
125
128
  ));
126
129
  }
130
+
131
+ /**
132
+ * List Adjustments
133
+ *
134
+ * @remarks
135
+ * Reads the adjustments on the subscription, oldest window first. A subscription with no adjustment returns an empty array. Paginated, because a long-running subscription accumulates one adjustment per rate change of every deal it has carried.
136
+ */
137
+ async listSubscriptionAdjustments(
138
+ request: operations.ListSubscriptionAdjustmentsRequest,
139
+ options?: RequestOptions,
140
+ ): Promise<models.SubscriptionAdjustmentsResponse> {
141
+ return unwrapAsync(subscriptionsListSubscriptionAdjustments(
142
+ this,
143
+ request,
144
+ options,
145
+ ));
146
+ }
147
+
148
+ /**
149
+ * Create Adjustment
150
+ *
151
+ * @remarks
152
+ * Attaches a percentage discount to the subscription for a dated window. Every invoice calculated while the window is open carries one discount line for each discounted charge, and tax is assessed on the reduced amount. An invoice that already exists is not changed, including one still in draft — the discount reaches the periods that close after it is created. There is no update operation, and a window cannot be changed after it is created. To change a rate before any invoice has issued under the discount, delete the adjustment and create a replacement. Once an invoice has issued the adjustment is permanent, so set effectiveTo at creation time whenever the deal has a known end date.
153
+ */
154
+ async createSubscriptionAdjustment(
155
+ request: operations.CreateSubscriptionAdjustmentRequest,
156
+ options?: RequestOptions,
157
+ ): Promise<models.SubscriptionAdjustment> {
158
+ return unwrapAsync(subscriptionsCreateSubscriptionAdjustment(
159
+ this,
160
+ request,
161
+ options,
162
+ ));
163
+ }
164
+
165
+ /**
166
+ * Delete Adjustment
167
+ *
168
+ * @remarks
169
+ * Deletes an adjustment that has not yet reached an issued invoice. No invoice changes: an invoice still in draft keeps its numbers, and loses the discount only when its period is calculated again. An adjustment that has already discounted an issued invoice cannot be deleted, because the invoice records why the customer was charged that amount. Its window cannot be shortened afterwards either, so set effectiveTo at creation time whenever the deal has a known end date.
170
+ */
171
+ async deleteSubscriptionAdjustment(
172
+ request: operations.DeleteSubscriptionAdjustmentRequest,
173
+ options?: RequestOptions,
174
+ ): Promise<void> {
175
+ return unwrapAsync(subscriptionsDeleteSubscriptionAdjustment(
176
+ this,
177
+ request,
178
+ options,
179
+ ));
180
+ }
127
181
  }