@usehercules/sdk 1.2.0 → 1.4.0

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 (209) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/LICENSE +1 -1
  3. package/README.md +14 -20
  4. package/client.d.mts +6 -3
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +6 -3
  7. package/client.d.ts.map +1 -1
  8. package/client.js +1 -1
  9. package/client.js.map +1 -1
  10. package/client.mjs +1 -1
  11. package/client.mjs.map +1 -1
  12. package/package.json +1 -1
  13. package/resources/beta/beta.d.mts +4 -4
  14. package/resources/beta/beta.d.mts.map +1 -1
  15. package/resources/beta/beta.d.ts +4 -4
  16. package/resources/beta/beta.d.ts.map +1 -1
  17. package/resources/beta/beta.js +4 -4
  18. package/resources/beta/beta.js.map +1 -1
  19. package/resources/beta/beta.mjs +4 -4
  20. package/resources/beta/beta.mjs.map +1 -1
  21. package/resources/beta/index.d.mts +1 -1
  22. package/resources/beta/index.d.mts.map +1 -1
  23. package/resources/beta/index.d.ts +1 -1
  24. package/resources/beta/index.d.ts.map +1 -1
  25. package/resources/beta/index.js +3 -3
  26. package/resources/beta/index.js.map +1 -1
  27. package/resources/beta/index.mjs +1 -1
  28. package/resources/beta/index.mjs.map +1 -1
  29. package/resources/beta/pay/coupons.d.mts +156 -0
  30. package/resources/beta/pay/coupons.d.mts.map +1 -0
  31. package/resources/beta/pay/coupons.d.ts +156 -0
  32. package/resources/beta/pay/coupons.d.ts.map +1 -0
  33. package/resources/beta/pay/coupons.js +51 -0
  34. package/resources/beta/pay/coupons.js.map +1 -0
  35. package/resources/beta/pay/coupons.mjs +47 -0
  36. package/resources/beta/pay/coupons.mjs.map +1 -0
  37. package/resources/beta/pay/customers.d.mts +160 -0
  38. package/resources/beta/pay/customers.d.mts.map +1 -0
  39. package/resources/beta/pay/customers.d.ts +160 -0
  40. package/resources/beta/pay/customers.d.ts.map +1 -0
  41. package/resources/beta/pay/customers.js +60 -0
  42. package/resources/beta/pay/customers.js.map +1 -0
  43. package/resources/beta/pay/customers.mjs +56 -0
  44. package/resources/beta/pay/customers.mjs.map +1 -0
  45. package/resources/beta/{subscriptions → pay}/entitlements.d.mts +25 -19
  46. package/resources/beta/pay/entitlements.d.mts.map +1 -0
  47. package/resources/beta/{subscriptions → pay}/entitlements.d.ts +25 -19
  48. package/resources/beta/pay/entitlements.d.ts.map +1 -0
  49. package/resources/beta/pay/entitlements.js +41 -0
  50. package/resources/beta/pay/entitlements.js.map +1 -0
  51. package/resources/beta/pay/entitlements.mjs +37 -0
  52. package/resources/beta/pay/entitlements.mjs.map +1 -0
  53. package/resources/beta/{subscriptions → pay}/index.d.mts +2 -2
  54. package/resources/beta/pay/index.d.mts.map +1 -0
  55. package/resources/beta/{subscriptions → pay}/index.d.ts +2 -2
  56. package/resources/beta/pay/index.d.ts.map +1 -0
  57. package/resources/beta/{subscriptions → pay}/index.js +5 -5
  58. package/resources/beta/pay/index.js.map +1 -0
  59. package/resources/beta/{subscriptions → pay}/index.mjs +2 -2
  60. package/resources/beta/pay/index.mjs.map +1 -0
  61. package/resources/beta/pay/pay.d.mts +206 -0
  62. package/resources/beta/pay/pay.d.mts.map +1 -0
  63. package/resources/beta/pay/pay.d.ts +206 -0
  64. package/resources/beta/pay/pay.d.ts.map +1 -0
  65. package/resources/beta/pay/pay.js +54 -0
  66. package/resources/beta/pay/pay.js.map +1 -0
  67. package/resources/beta/pay/pay.mjs +49 -0
  68. package/resources/beta/pay/pay.mjs.map +1 -0
  69. package/resources/beta/pay/products/entitlements.d.mts +53 -0
  70. package/resources/beta/pay/products/entitlements.d.mts.map +1 -0
  71. package/resources/beta/pay/products/entitlements.d.ts +53 -0
  72. package/resources/beta/pay/products/entitlements.d.ts.map +1 -0
  73. package/resources/beta/pay/products/entitlements.js +38 -0
  74. package/resources/beta/pay/products/entitlements.js.map +1 -0
  75. package/resources/beta/pay/products/entitlements.mjs +34 -0
  76. package/resources/beta/pay/products/entitlements.mjs.map +1 -0
  77. package/resources/beta/pay/products/index.d.mts +4 -0
  78. package/resources/beta/pay/products/index.d.mts.map +1 -0
  79. package/resources/beta/pay/products/index.d.ts +4 -0
  80. package/resources/beta/pay/products/index.d.ts.map +1 -0
  81. package/resources/beta/pay/products/index.js +11 -0
  82. package/resources/beta/pay/products/index.js.map +1 -0
  83. package/resources/beta/{subscriptions/plans → pay/products}/index.mjs +2 -1
  84. package/resources/beta/pay/products/index.mjs.map +1 -0
  85. package/resources/beta/pay/products/products.d.mts +183 -0
  86. package/resources/beta/pay/products/products.d.mts.map +1 -0
  87. package/resources/beta/pay/products/products.d.ts +183 -0
  88. package/resources/beta/pay/products/products.d.ts.map +1 -0
  89. package/resources/beta/pay/products/products.js +61 -0
  90. package/resources/beta/pay/products/products.js.map +1 -0
  91. package/resources/beta/pay/products/products.mjs +56 -0
  92. package/resources/beta/pay/products/products.mjs.map +1 -0
  93. package/resources/beta/pay/products/variants.d.mts +206 -0
  94. package/resources/beta/pay/products/variants.d.mts.map +1 -0
  95. package/resources/beta/pay/products/variants.d.ts +206 -0
  96. package/resources/beta/pay/products/variants.d.ts.map +1 -0
  97. package/resources/beta/pay/products/variants.js +56 -0
  98. package/resources/beta/pay/products/variants.js.map +1 -0
  99. package/resources/beta/pay/products/variants.mjs +52 -0
  100. package/resources/beta/pay/products/variants.mjs.map +1 -0
  101. package/resources/beta/pay/products.d.mts +2 -0
  102. package/resources/beta/pay/products.d.mts.map +1 -0
  103. package/resources/beta/pay/products.d.ts +2 -0
  104. package/resources/beta/pay/products.d.ts.map +1 -0
  105. package/resources/beta/{subscriptions/plans.js → pay/products.js} +2 -2
  106. package/resources/beta/pay/products.js.map +1 -0
  107. package/resources/beta/{subscriptions.mjs → pay/products.mjs} +2 -2
  108. package/resources/beta/pay/products.mjs.map +1 -0
  109. package/resources/beta/pay.d.mts +2 -0
  110. package/resources/beta/pay.d.mts.map +1 -0
  111. package/resources/beta/pay.d.ts +2 -0
  112. package/resources/beta/pay.d.ts.map +1 -0
  113. package/resources/beta/{subscriptions.js → pay.js} +2 -2
  114. package/resources/beta/pay.js.map +1 -0
  115. package/resources/beta/{subscriptions/plans.mjs → pay.mjs} +2 -2
  116. package/resources/beta/pay.mjs.map +1 -0
  117. package/src/client.ts +6 -4
  118. package/src/resources/beta/beta.ts +18 -18
  119. package/src/resources/beta/index.ts +8 -8
  120. package/src/resources/beta/pay/coupons.ts +218 -0
  121. package/src/resources/beta/pay/customers.ts +229 -0
  122. package/src/resources/beta/{subscriptions → pay}/entitlements.ts +29 -29
  123. package/src/resources/beta/{subscriptions → pay}/index.ts +15 -15
  124. package/src/resources/beta/pay/pay.ts +326 -0
  125. package/src/resources/beta/{subscriptions/plans → pay/products}/entitlements.ts +26 -21
  126. package/src/resources/beta/pay/products/index.ts +28 -0
  127. package/src/resources/beta/pay/products/products.ts +280 -0
  128. package/src/resources/beta/pay/products/variants.ts +279 -0
  129. package/src/resources/beta/{subscriptions.ts → pay/products.ts} +1 -1
  130. package/src/resources/beta/{subscriptions/plans.ts → pay.ts} +1 -1
  131. package/src/version.ts +1 -1
  132. package/version.d.mts +1 -1
  133. package/version.d.ts +1 -1
  134. package/version.js +1 -1
  135. package/version.mjs +1 -1
  136. package/resources/beta/subscriptions/coupons.d.mts +0 -124
  137. package/resources/beta/subscriptions/coupons.d.mts.map +0 -1
  138. package/resources/beta/subscriptions/coupons.d.ts +0 -124
  139. package/resources/beta/subscriptions/coupons.d.ts.map +0 -1
  140. package/resources/beta/subscriptions/coupons.js +0 -45
  141. package/resources/beta/subscriptions/coupons.js.map +0 -1
  142. package/resources/beta/subscriptions/coupons.mjs +0 -41
  143. package/resources/beta/subscriptions/coupons.mjs.map +0 -1
  144. package/resources/beta/subscriptions/customers.d.mts +0 -93
  145. package/resources/beta/subscriptions/customers.d.mts.map +0 -1
  146. package/resources/beta/subscriptions/customers.d.ts +0 -93
  147. package/resources/beta/subscriptions/customers.d.ts.map +0 -1
  148. package/resources/beta/subscriptions/customers.js +0 -57
  149. package/resources/beta/subscriptions/customers.js.map +0 -1
  150. package/resources/beta/subscriptions/customers.mjs +0 -53
  151. package/resources/beta/subscriptions/customers.mjs.map +0 -1
  152. package/resources/beta/subscriptions/entitlements.d.mts.map +0 -1
  153. package/resources/beta/subscriptions/entitlements.d.ts.map +0 -1
  154. package/resources/beta/subscriptions/entitlements.js +0 -38
  155. package/resources/beta/subscriptions/entitlements.js.map +0 -1
  156. package/resources/beta/subscriptions/entitlements.mjs +0 -34
  157. package/resources/beta/subscriptions/entitlements.mjs.map +0 -1
  158. package/resources/beta/subscriptions/index.d.mts.map +0 -1
  159. package/resources/beta/subscriptions/index.d.ts.map +0 -1
  160. package/resources/beta/subscriptions/index.js.map +0 -1
  161. package/resources/beta/subscriptions/index.mjs.map +0 -1
  162. package/resources/beta/subscriptions/plans/entitlements.d.mts +0 -48
  163. package/resources/beta/subscriptions/plans/entitlements.d.mts.map +0 -1
  164. package/resources/beta/subscriptions/plans/entitlements.d.ts +0 -48
  165. package/resources/beta/subscriptions/plans/entitlements.d.ts.map +0 -1
  166. package/resources/beta/subscriptions/plans/entitlements.js +0 -34
  167. package/resources/beta/subscriptions/plans/entitlements.js.map +0 -1
  168. package/resources/beta/subscriptions/plans/entitlements.mjs +0 -30
  169. package/resources/beta/subscriptions/plans/entitlements.mjs.map +0 -1
  170. package/resources/beta/subscriptions/plans/index.d.mts +0 -3
  171. package/resources/beta/subscriptions/plans/index.d.mts.map +0 -1
  172. package/resources/beta/subscriptions/plans/index.d.ts +0 -3
  173. package/resources/beta/subscriptions/plans/index.d.ts.map +0 -1
  174. package/resources/beta/subscriptions/plans/index.js +0 -9
  175. package/resources/beta/subscriptions/plans/index.js.map +0 -1
  176. package/resources/beta/subscriptions/plans/index.mjs.map +0 -1
  177. package/resources/beta/subscriptions/plans/plans.d.mts +0 -87
  178. package/resources/beta/subscriptions/plans/plans.d.mts.map +0 -1
  179. package/resources/beta/subscriptions/plans/plans.d.ts +0 -87
  180. package/resources/beta/subscriptions/plans/plans.d.ts.map +0 -1
  181. package/resources/beta/subscriptions/plans/plans.js +0 -49
  182. package/resources/beta/subscriptions/plans/plans.js.map +0 -1
  183. package/resources/beta/subscriptions/plans/plans.mjs +0 -44
  184. package/resources/beta/subscriptions/plans/plans.mjs.map +0 -1
  185. package/resources/beta/subscriptions/plans.d.mts +0 -2
  186. package/resources/beta/subscriptions/plans.d.mts.map +0 -1
  187. package/resources/beta/subscriptions/plans.d.ts +0 -2
  188. package/resources/beta/subscriptions/plans.d.ts.map +0 -1
  189. package/resources/beta/subscriptions/plans.js.map +0 -1
  190. package/resources/beta/subscriptions/plans.mjs.map +0 -1
  191. package/resources/beta/subscriptions/subscriptions.d.mts +0 -130
  192. package/resources/beta/subscriptions/subscriptions.d.mts.map +0 -1
  193. package/resources/beta/subscriptions/subscriptions.d.ts +0 -130
  194. package/resources/beta/subscriptions/subscriptions.d.ts.map +0 -1
  195. package/resources/beta/subscriptions/subscriptions.js +0 -47
  196. package/resources/beta/subscriptions/subscriptions.js.map +0 -1
  197. package/resources/beta/subscriptions/subscriptions.mjs +0 -42
  198. package/resources/beta/subscriptions/subscriptions.mjs.map +0 -1
  199. package/resources/beta/subscriptions.d.mts +0 -2
  200. package/resources/beta/subscriptions.d.mts.map +0 -1
  201. package/resources/beta/subscriptions.d.ts +0 -2
  202. package/resources/beta/subscriptions.d.ts.map +0 -1
  203. package/resources/beta/subscriptions.js.map +0 -1
  204. package/resources/beta/subscriptions.mjs.map +0 -1
  205. package/src/resources/beta/subscriptions/coupons.ts +0 -185
  206. package/src/resources/beta/subscriptions/customers.ts +0 -168
  207. package/src/resources/beta/subscriptions/plans/index.ts +0 -18
  208. package/src/resources/beta/subscriptions/plans/plans.ts +0 -159
  209. package/src/resources/beta/subscriptions/subscriptions.ts +0 -241
@@ -0,0 +1,326 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as CouponsAPI from './coupons';
5
+ import {
6
+ Coupon,
7
+ CouponCreateParams,
8
+ CouponListParams,
9
+ CouponUpdateParams,
10
+ Coupons,
11
+ CouponsCursorIDPage,
12
+ } from './coupons';
13
+ import * as CustomersAPI from './customers';
14
+ import {
15
+ Customer,
16
+ CustomerAddress,
17
+ CustomerBillingPortalParams,
18
+ CustomerBillingPortalResponse,
19
+ CustomerCreateParams,
20
+ CustomerListParams,
21
+ CustomerUpdateParams,
22
+ Customers,
23
+ CustomersCursorIDPage,
24
+ } from './customers';
25
+ import * as EntitlementsAPI from './entitlements';
26
+ import {
27
+ Entitlement,
28
+ EntitlementCreateParams,
29
+ EntitlementListParams,
30
+ EntitlementUpdateParams,
31
+ Entitlements,
32
+ EntitlementsCursorIDPage,
33
+ } from './entitlements';
34
+ import * as ProductsAPI from './products/products';
35
+ import {
36
+ Product,
37
+ ProductCreateParams,
38
+ ProductListParams,
39
+ ProductUpdateParams,
40
+ Products,
41
+ ProductsCursorIDPage,
42
+ } from './products/products';
43
+ import { APIPromise } from '../../../core/api-promise';
44
+ import { RequestOptions } from '../../../internal/request-options';
45
+
46
+ export class Pay extends APIResource {
47
+ customers: CustomersAPI.Customers = new CustomersAPI.Customers(this._client);
48
+ products: ProductsAPI.Products = new ProductsAPI.Products(this._client);
49
+ entitlements: EntitlementsAPI.Entitlements = new EntitlementsAPI.Entitlements(this._client);
50
+ coupons: CouponsAPI.Coupons = new CouponsAPI.Coupons(this._client);
51
+
52
+ /**
53
+ * Cancels a customer's subscription. By default, the subscription remains active
54
+ * until the end of the current billing period. Set cancellation_timing to
55
+ * 'immediate' to cancel immediately.
56
+ */
57
+ cancel(body: PayCancelParams, options?: RequestOptions): APIPromise<PayCancelResponse> {
58
+ return this._client.post('/v1/pay/cancel', { body, ...options });
59
+ }
60
+
61
+ /**
62
+ * Verifies if a customer has access to a specific feature. Use this to gate
63
+ * features in your app based on the customer's active subscription and the
64
+ * entitlements attached to their product. Hercules recommends calling this before
65
+ * allowing access to premium features.
66
+ */
67
+ check(body: PayCheckParams, options?: RequestOptions): APIPromise<PayCheckResponse> {
68
+ return this._client.post('/v1/pay/check', { body, ...options });
69
+ }
70
+
71
+ /**
72
+ * Creates a checkout session for a customer to subscribe to a product. Returns a
73
+ * URL to redirect the customer to for payment. After successful payment, the
74
+ * customer is subscribed to the product and gains access to its entitlements.
75
+ */
76
+ checkout(body: PayCheckoutParams, options?: RequestOptions): APIPromise<PayCheckoutResponse> {
77
+ return this._client.post('/v1/pay/checkout', { body, ...options });
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Cancel subscription response
83
+ */
84
+ export interface PayCancelResponse {
85
+ /**
86
+ * The subscription ID
87
+ */
88
+ id: string;
89
+
90
+ /**
91
+ * When the cancellation takes effect
92
+ */
93
+ cancellation_timing: 'immediate' | 'at_billing_period_end';
94
+
95
+ /**
96
+ * The subscription status
97
+ */
98
+ status: string;
99
+
100
+ /**
101
+ * When the subscription was canceled
102
+ */
103
+ canceled_at?: string | null;
104
+ }
105
+
106
+ /**
107
+ * Check entitlement response
108
+ */
109
+ export interface PayCheckResponse {
110
+ /**
111
+ * The entitlement ID that was checked
112
+ */
113
+ entitlement_id: string;
114
+
115
+ /**
116
+ * Whether the customer has the entitlement
117
+ */
118
+ has_entitlement: boolean;
119
+ }
120
+
121
+ /**
122
+ * Checkout response. For new customers, returns a checkout URL. For existing
123
+ * subscribers, returns the updated subscription.
124
+ */
125
+ export interface PayCheckoutResponse {
126
+ /**
127
+ * The checkout session ID (for checkout action) or subscription ID (for update
128
+ * action)
129
+ */
130
+ id: string;
131
+
132
+ /**
133
+ * The action taken: 'checkout' for new subscriptions (redirect to URL), 'update'
134
+ * for subscription changes (already applied)
135
+ */
136
+ action: 'checkout' | 'update';
137
+
138
+ /**
139
+ * The checkout mode: subscription for recurring prices, payment for one-time
140
+ * prices. Only present for 'checkout' action.
141
+ */
142
+ mode?: 'subscription' | 'payment' | null;
143
+
144
+ /**
145
+ * The updated subscription details. Only present for 'update' action.
146
+ */
147
+ subscription?: PayCheckoutResponse.Subscription | null;
148
+
149
+ /**
150
+ * The checkout URL to redirect the customer to. Only present for 'checkout'
151
+ * action.
152
+ */
153
+ url?: string | null;
154
+ }
155
+
156
+ export namespace PayCheckoutResponse {
157
+ /**
158
+ * The updated subscription details. Only present for 'update' action.
159
+ */
160
+ export interface Subscription {
161
+ /**
162
+ * The subscription ID
163
+ */
164
+ id: string;
165
+
166
+ /**
167
+ * The product ID
168
+ */
169
+ product_id: string;
170
+
171
+ /**
172
+ * The subscription status
173
+ */
174
+ status: string;
175
+
176
+ /**
177
+ * The variant ID if applicable
178
+ */
179
+ variant_id?: string | null;
180
+ }
181
+ }
182
+
183
+ export interface PayCancelParams {
184
+ /**
185
+ * The customer ID
186
+ */
187
+ customer_id: string;
188
+
189
+ /**
190
+ * The subscription ID to cancel
191
+ */
192
+ subscription_id: string;
193
+
194
+ /**
195
+ * When to cancel the subscription. Defaults to 'at_billing_period_end' to allow
196
+ * customers to use remaining time.
197
+ */
198
+ cancellation_timing?: 'immediate' | 'at_billing_period_end';
199
+ }
200
+
201
+ export interface PayCheckParams {
202
+ /**
203
+ * The customer ID
204
+ */
205
+ customer_id: string;
206
+
207
+ /**
208
+ * The entitlement ID to check for access
209
+ */
210
+ entitlement_id: string;
211
+ }
212
+
213
+ export interface PayCheckoutParams {
214
+ /**
215
+ * The customer ID
216
+ */
217
+ customer_id: string;
218
+
219
+ /**
220
+ * The product ID to purchase
221
+ */
222
+ product_id: string;
223
+
224
+ /**
225
+ * Optional custom ID for the subscription or payment. If not provided, one will be
226
+ * generated.
227
+ */
228
+ id?: string;
229
+
230
+ /**
231
+ * Override billing cycle anchor behavior for subscription updates. 'now' resets to
232
+ * current time, 'unchanged' keeps original anchor. If not provided, uses the
233
+ * price's configured default.
234
+ */
235
+ billing_cycle_anchor?: 'now' | 'unchanged';
236
+
237
+ /**
238
+ * URL to redirect on cancel
239
+ */
240
+ cancel_url?: string;
241
+
242
+ /**
243
+ * Promotion code to apply
244
+ */
245
+ promotion_code?: string;
246
+
247
+ /**
248
+ * Override proration behavior for subscription updates. 'default' creates
249
+ * prorations, 'none' disables them. If not provided, uses the price's configured
250
+ * default.
251
+ */
252
+ proration_behavior?: 'default' | 'none';
253
+
254
+ /**
255
+ * Override proration date calculation for subscription updates. 'now' uses current
256
+ * time, 'start_of_period' uses billing period start. If not provided, uses the
257
+ * price's configured default.
258
+ */
259
+ proration_date?: 'now' | 'start_of_period';
260
+
261
+ /**
262
+ * URL to redirect on success
263
+ */
264
+ success_url?: string;
265
+
266
+ /**
267
+ * Optional variant ID to specify a particular pricing tier. If not provided, the
268
+ * product's default price is used.
269
+ */
270
+ variant_id?: string;
271
+ }
272
+
273
+ Pay.Customers = Customers;
274
+ Pay.Products = Products;
275
+ Pay.Entitlements = Entitlements;
276
+ Pay.Coupons = Coupons;
277
+
278
+ export declare namespace Pay {
279
+ export {
280
+ type PayCancelResponse as PayCancelResponse,
281
+ type PayCheckResponse as PayCheckResponse,
282
+ type PayCheckoutResponse as PayCheckoutResponse,
283
+ type PayCancelParams as PayCancelParams,
284
+ type PayCheckParams as PayCheckParams,
285
+ type PayCheckoutParams as PayCheckoutParams,
286
+ };
287
+
288
+ export {
289
+ Customers as Customers,
290
+ type Customer as Customer,
291
+ type CustomerAddress as CustomerAddress,
292
+ type CustomerBillingPortalResponse as CustomerBillingPortalResponse,
293
+ type CustomersCursorIDPage as CustomersCursorIDPage,
294
+ type CustomerCreateParams as CustomerCreateParams,
295
+ type CustomerUpdateParams as CustomerUpdateParams,
296
+ type CustomerListParams as CustomerListParams,
297
+ type CustomerBillingPortalParams as CustomerBillingPortalParams,
298
+ };
299
+
300
+ export {
301
+ Products as Products,
302
+ type Product as Product,
303
+ type ProductsCursorIDPage as ProductsCursorIDPage,
304
+ type ProductCreateParams as ProductCreateParams,
305
+ type ProductUpdateParams as ProductUpdateParams,
306
+ type ProductListParams as ProductListParams,
307
+ };
308
+
309
+ export {
310
+ Entitlements as Entitlements,
311
+ type Entitlement as Entitlement,
312
+ type EntitlementsCursorIDPage as EntitlementsCursorIDPage,
313
+ type EntitlementCreateParams as EntitlementCreateParams,
314
+ type EntitlementUpdateParams as EntitlementUpdateParams,
315
+ type EntitlementListParams as EntitlementListParams,
316
+ };
317
+
318
+ export {
319
+ Coupons as Coupons,
320
+ type Coupon as Coupon,
321
+ type CouponsCursorIDPage as CouponsCursorIDPage,
322
+ type CouponCreateParams as CouponCreateParams,
323
+ type CouponUpdateParams as CouponUpdateParams,
324
+ type CouponListParams as CouponListParams,
325
+ };
326
+ }
@@ -10,56 +10,61 @@ import { path } from '../../../../internal/utils/path';
10
10
 
11
11
  export class Entitlements extends APIResource {
12
12
  /**
13
- * List Plan Entitlements
13
+ * Retrieves all entitlements attached to a product. These entitlements define the
14
+ * features that customers subscribed to this product can access.
14
15
  */
15
16
  list(
16
- planID: string,
17
+ productID: string,
17
18
  query: EntitlementListParams | null | undefined = {},
18
19
  options?: RequestOptions,
19
- ): PagePromise<PlanEntitlementsCursorIDPage, PlanEntitlement> {
20
+ ): PagePromise<ProductEntitlementsCursorIDPage, ProductEntitlement> {
20
21
  return this._client.getAPIList(
21
- path`/v1/subscriptions/plans/${planID}/entitlements`,
22
- CursorIDPage<PlanEntitlement>,
22
+ path`/v1/pay/products/${productID}/entitlements`,
23
+ CursorIDPage<ProductEntitlement>,
23
24
  { query, ...options },
24
25
  );
25
26
  }
26
27
 
27
28
  /**
28
- * Attach Entitlement to Plan
29
+ * Attaches an entitlement to a product. All customers subscribed to this product
30
+ * will gain access to the attached feature. Hercules recommends attaching
31
+ * entitlements when creating or updating products to keep feature access in sync.
29
32
  */
30
33
  attach(
31
- planID: string,
34
+ productID: string,
32
35
  body: EntitlementAttachParams,
33
36
  options?: RequestOptions,
34
- ): APIPromise<PlanEntitlement> {
35
- return this._client.post(path`/v1/subscriptions/plans/${planID}/entitlements`, { body, ...options });
37
+ ): APIPromise<ProductEntitlement> {
38
+ return this._client.post(path`/v1/pay/products/${productID}/entitlements`, { body, ...options });
36
39
  }
37
40
 
38
41
  /**
39
- * Remove Entitlement from Plan
42
+ * Removes an entitlement from a product. Customers subscribed to this product will
43
+ * lose access to the feature. Existing subscriptions are affected immediately.
40
44
  */
41
45
  remove(featureID: string, params: EntitlementRemoveParams, options?: RequestOptions): APIPromise<void> {
42
- const { plan_id } = params;
43
- return this._client.delete(path`/v1/subscriptions/plans/${plan_id}/entitlements/${featureID}`, {
46
+ const { product_id } = params;
47
+ return this._client.delete(path`/v1/pay/products/${product_id}/entitlements/${featureID}`, {
44
48
  ...options,
45
49
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
46
50
  });
47
51
  }
48
52
  }
49
53
 
50
- export type PlanEntitlementsCursorIDPage = CursorIDPage<PlanEntitlement>;
54
+ export type ProductEntitlementsCursorIDPage = CursorIDPage<ProductEntitlement>;
51
55
 
52
56
  /**
53
- * An entitlement attached to a plan
57
+ * An entitlement attached to a product. All customers subscribed to the product
58
+ * gain access to this entitlement.
54
59
  */
55
- export interface PlanEntitlement {
60
+ export interface ProductEntitlement {
56
61
  /**
57
- * An id for a data item
62
+ * Unique identifier for the price
58
63
  */
59
64
  id: string;
60
65
 
61
66
  /**
62
- * An entitlement that can be attached to products
67
+ * The entitlement attached to the product
63
68
  */
64
69
  entitlement: EntitlementsAPI.Entitlement;
65
70
  }
@@ -68,19 +73,19 @@ export interface EntitlementListParams extends CursorIDPageParams {}
68
73
 
69
74
  export interface EntitlementAttachParams {
70
75
  /**
71
- * The ID of the entitlement to attach
76
+ * The ID of the entitlement to attach to the product
72
77
  */
73
78
  entitlement: string;
74
79
  }
75
80
 
76
81
  export interface EntitlementRemoveParams {
77
- plan_id: string;
82
+ product_id: string;
78
83
  }
79
84
 
80
85
  export declare namespace Entitlements {
81
86
  export {
82
- type PlanEntitlement as PlanEntitlement,
83
- type PlanEntitlementsCursorIDPage as PlanEntitlementsCursorIDPage,
87
+ type ProductEntitlement as ProductEntitlement,
88
+ type ProductEntitlementsCursorIDPage as ProductEntitlementsCursorIDPage,
84
89
  type EntitlementListParams as EntitlementListParams,
85
90
  type EntitlementAttachParams as EntitlementAttachParams,
86
91
  type EntitlementRemoveParams as EntitlementRemoveParams,
@@ -0,0 +1,28 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Entitlements,
5
+ type ProductEntitlement,
6
+ type EntitlementListParams,
7
+ type EntitlementAttachParams,
8
+ type EntitlementRemoveParams,
9
+ type ProductEntitlementsCursorIDPage,
10
+ } from './entitlements';
11
+ export {
12
+ Products,
13
+ type Product,
14
+ type ProductCreateParams,
15
+ type ProductUpdateParams,
16
+ type ProductListParams,
17
+ type ProductsCursorIDPage,
18
+ } from './products';
19
+ export {
20
+ Variants,
21
+ type Variant,
22
+ type VariantCreateParams,
23
+ type VariantUpdateParams,
24
+ type VariantListParams,
25
+ type VariantArchiveParams,
26
+ type VariantGetParams,
27
+ type VariantsCursorIDPage,
28
+ } from './variants';