@usehercules/sdk 1.1.0 → 1.3.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 (199) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +14 -20
  3. package/client.d.mts +6 -3
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +6 -3
  6. package/client.d.ts.map +1 -1
  7. package/client.js +1 -1
  8. package/client.js.map +1 -1
  9. package/client.mjs +1 -1
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/beta/beta.d.mts +4 -4
  13. package/resources/beta/beta.d.mts.map +1 -1
  14. package/resources/beta/beta.d.ts +4 -4
  15. package/resources/beta/beta.d.ts.map +1 -1
  16. package/resources/beta/beta.js +4 -4
  17. package/resources/beta/beta.js.map +1 -1
  18. package/resources/beta/beta.mjs +4 -4
  19. package/resources/beta/beta.mjs.map +1 -1
  20. package/resources/beta/index.d.mts +1 -1
  21. package/resources/beta/index.d.mts.map +1 -1
  22. package/resources/beta/index.d.ts +1 -1
  23. package/resources/beta/index.d.ts.map +1 -1
  24. package/resources/beta/index.js +3 -3
  25. package/resources/beta/index.js.map +1 -1
  26. package/resources/beta/index.mjs +1 -1
  27. package/resources/beta/index.mjs.map +1 -1
  28. package/resources/beta/pay/coupons.d.mts +156 -0
  29. package/resources/beta/pay/coupons.d.mts.map +1 -0
  30. package/resources/beta/pay/coupons.d.ts +156 -0
  31. package/resources/beta/pay/coupons.d.ts.map +1 -0
  32. package/resources/beta/pay/coupons.js +51 -0
  33. package/resources/beta/pay/coupons.js.map +1 -0
  34. package/resources/beta/pay/coupons.mjs +47 -0
  35. package/resources/beta/pay/coupons.mjs.map +1 -0
  36. package/resources/beta/pay/customers.d.mts +160 -0
  37. package/resources/beta/pay/customers.d.mts.map +1 -0
  38. package/resources/beta/pay/customers.d.ts +160 -0
  39. package/resources/beta/pay/customers.d.ts.map +1 -0
  40. package/resources/beta/pay/customers.js +60 -0
  41. package/resources/beta/pay/customers.js.map +1 -0
  42. package/resources/beta/pay/customers.mjs +56 -0
  43. package/resources/beta/pay/customers.mjs.map +1 -0
  44. package/resources/beta/pay/entitlements.d.mts +94 -0
  45. package/resources/beta/pay/entitlements.d.mts.map +1 -0
  46. package/resources/beta/pay/entitlements.d.ts +94 -0
  47. package/resources/beta/pay/entitlements.d.ts.map +1 -0
  48. package/resources/beta/pay/entitlements.js +42 -0
  49. package/resources/beta/pay/entitlements.js.map +1 -0
  50. package/resources/beta/pay/entitlements.mjs +38 -0
  51. package/resources/beta/pay/entitlements.mjs.map +1 -0
  52. package/resources/beta/pay/index.d.mts +6 -0
  53. package/resources/beta/pay/index.d.mts.map +1 -0
  54. package/resources/beta/pay/index.d.ts +6 -0
  55. package/resources/beta/pay/index.d.ts.map +1 -0
  56. package/resources/beta/{subscriptions → pay}/index.js +5 -5
  57. package/resources/beta/pay/index.js.map +1 -0
  58. package/resources/beta/{subscriptions → pay}/index.mjs +2 -2
  59. package/resources/beta/pay/index.mjs.map +1 -0
  60. package/resources/beta/{subscriptions/subscriptions.d.mts → pay/pay.d.mts} +48 -32
  61. package/resources/beta/pay/pay.d.mts.map +1 -0
  62. package/resources/beta/{subscriptions/subscriptions.d.ts → pay/pay.d.ts} +48 -32
  63. package/resources/beta/pay/pay.d.ts.map +1 -0
  64. package/resources/beta/pay/pay.js +54 -0
  65. package/resources/beta/pay/pay.js.map +1 -0
  66. package/resources/beta/pay/pay.mjs +49 -0
  67. package/resources/beta/pay/pay.mjs.map +1 -0
  68. package/resources/beta/pay/products/entitlements.d.mts +53 -0
  69. package/resources/beta/pay/products/entitlements.d.mts.map +1 -0
  70. package/resources/beta/pay/products/entitlements.d.ts +53 -0
  71. package/resources/beta/pay/products/entitlements.d.ts.map +1 -0
  72. package/resources/beta/pay/products/entitlements.js +38 -0
  73. package/resources/beta/pay/products/entitlements.js.map +1 -0
  74. package/resources/beta/pay/products/entitlements.mjs +34 -0
  75. package/resources/beta/pay/products/entitlements.mjs.map +1 -0
  76. package/resources/beta/pay/products/index.d.mts +3 -0
  77. package/resources/beta/pay/products/index.d.mts.map +1 -0
  78. package/resources/beta/pay/products/index.d.ts +3 -0
  79. package/resources/beta/pay/products/index.d.ts.map +1 -0
  80. package/resources/beta/{subscriptions/plans → pay/products}/index.js +3 -3
  81. package/resources/beta/pay/products/index.js.map +1 -0
  82. package/resources/beta/{subscriptions/plans → pay/products}/index.mjs +1 -1
  83. package/resources/beta/pay/products/index.mjs.map +1 -0
  84. package/resources/beta/pay/products/products.d.mts +152 -0
  85. package/resources/beta/pay/products/products.d.mts.map +1 -0
  86. package/resources/beta/pay/products/products.d.ts +152 -0
  87. package/resources/beta/pay/products/products.d.ts.map +1 -0
  88. package/resources/beta/pay/products/products.js +57 -0
  89. package/resources/beta/pay/products/products.js.map +1 -0
  90. package/resources/beta/pay/products/products.mjs +52 -0
  91. package/resources/beta/pay/products/products.mjs.map +1 -0
  92. package/resources/beta/pay/products.d.mts +2 -0
  93. package/resources/beta/pay/products.d.mts.map +1 -0
  94. package/resources/beta/pay/products.d.ts +2 -0
  95. package/resources/beta/pay/products.d.ts.map +1 -0
  96. package/resources/beta/{subscriptions/plans.js → pay/products.js} +2 -2
  97. package/resources/beta/pay/products.js.map +1 -0
  98. package/resources/beta/{subscriptions.mjs → pay/products.mjs} +2 -2
  99. package/resources/beta/pay/products.mjs.map +1 -0
  100. package/resources/beta/pay.d.mts +2 -0
  101. package/resources/beta/pay.d.mts.map +1 -0
  102. package/resources/beta/pay.d.ts +2 -0
  103. package/resources/beta/pay.d.ts.map +1 -0
  104. package/resources/beta/{subscriptions.js → pay.js} +2 -2
  105. package/resources/beta/pay.js.map +1 -0
  106. package/resources/beta/{subscriptions/plans.mjs → pay.mjs} +2 -2
  107. package/resources/beta/pay.mjs.map +1 -0
  108. package/src/client.ts +6 -4
  109. package/src/resources/beta/beta.ts +18 -18
  110. package/src/resources/beta/index.ts +8 -8
  111. package/src/resources/beta/pay/coupons.ts +218 -0
  112. package/src/resources/beta/pay/customers.ts +229 -0
  113. package/src/resources/beta/pay/entitlements.ts +135 -0
  114. package/src/resources/beta/{subscriptions → pay}/index.ts +15 -17
  115. package/src/resources/beta/{subscriptions/subscriptions.ts → pay/pay.ts} +70 -59
  116. package/src/resources/beta/{subscriptions/plans → pay/products}/entitlements.ts +26 -21
  117. package/src/resources/beta/{subscriptions/plans → pay/products}/index.ts +9 -9
  118. package/src/resources/beta/pay/products/products.ts +224 -0
  119. package/src/resources/beta/{subscriptions.ts → pay/products.ts} +1 -1
  120. package/src/resources/beta/{subscriptions/plans.ts → pay.ts} +1 -1
  121. package/src/version.ts +1 -1
  122. package/version.d.mts +1 -1
  123. package/version.d.ts +1 -1
  124. package/version.js +1 -1
  125. package/version.mjs +1 -1
  126. package/resources/beta/subscriptions/coupons.d.mts +0 -151
  127. package/resources/beta/subscriptions/coupons.d.mts.map +0 -1
  128. package/resources/beta/subscriptions/coupons.d.ts +0 -151
  129. package/resources/beta/subscriptions/coupons.d.ts.map +0 -1
  130. package/resources/beta/subscriptions/coupons.js +0 -51
  131. package/resources/beta/subscriptions/coupons.js.map +0 -1
  132. package/resources/beta/subscriptions/coupons.mjs +0 -47
  133. package/resources/beta/subscriptions/coupons.mjs.map +0 -1
  134. package/resources/beta/subscriptions/customers.d.mts +0 -93
  135. package/resources/beta/subscriptions/customers.d.mts.map +0 -1
  136. package/resources/beta/subscriptions/customers.d.ts +0 -93
  137. package/resources/beta/subscriptions/customers.d.ts.map +0 -1
  138. package/resources/beta/subscriptions/customers.js +0 -57
  139. package/resources/beta/subscriptions/customers.js.map +0 -1
  140. package/resources/beta/subscriptions/customers.mjs +0 -53
  141. package/resources/beta/subscriptions/customers.mjs.map +0 -1
  142. package/resources/beta/subscriptions/entitlements.d.mts +0 -70
  143. package/resources/beta/subscriptions/entitlements.d.mts.map +0 -1
  144. package/resources/beta/subscriptions/entitlements.d.ts +0 -70
  145. package/resources/beta/subscriptions/entitlements.d.ts.map +0 -1
  146. package/resources/beta/subscriptions/entitlements.js +0 -38
  147. package/resources/beta/subscriptions/entitlements.js.map +0 -1
  148. package/resources/beta/subscriptions/entitlements.mjs +0 -34
  149. package/resources/beta/subscriptions/entitlements.mjs.map +0 -1
  150. package/resources/beta/subscriptions/index.d.mts +0 -6
  151. package/resources/beta/subscriptions/index.d.mts.map +0 -1
  152. package/resources/beta/subscriptions/index.d.ts +0 -6
  153. package/resources/beta/subscriptions/index.d.ts.map +0 -1
  154. package/resources/beta/subscriptions/index.js.map +0 -1
  155. package/resources/beta/subscriptions/index.mjs.map +0 -1
  156. package/resources/beta/subscriptions/plans/entitlements.d.mts +0 -48
  157. package/resources/beta/subscriptions/plans/entitlements.d.mts.map +0 -1
  158. package/resources/beta/subscriptions/plans/entitlements.d.ts +0 -48
  159. package/resources/beta/subscriptions/plans/entitlements.d.ts.map +0 -1
  160. package/resources/beta/subscriptions/plans/entitlements.js +0 -34
  161. package/resources/beta/subscriptions/plans/entitlements.js.map +0 -1
  162. package/resources/beta/subscriptions/plans/entitlements.mjs +0 -30
  163. package/resources/beta/subscriptions/plans/entitlements.mjs.map +0 -1
  164. package/resources/beta/subscriptions/plans/index.d.mts +0 -3
  165. package/resources/beta/subscriptions/plans/index.d.mts.map +0 -1
  166. package/resources/beta/subscriptions/plans/index.d.ts +0 -3
  167. package/resources/beta/subscriptions/plans/index.d.ts.map +0 -1
  168. package/resources/beta/subscriptions/plans/index.js.map +0 -1
  169. package/resources/beta/subscriptions/plans/index.mjs.map +0 -1
  170. package/resources/beta/subscriptions/plans/plans.d.mts +0 -87
  171. package/resources/beta/subscriptions/plans/plans.d.mts.map +0 -1
  172. package/resources/beta/subscriptions/plans/plans.d.ts +0 -87
  173. package/resources/beta/subscriptions/plans/plans.d.ts.map +0 -1
  174. package/resources/beta/subscriptions/plans/plans.js +0 -49
  175. package/resources/beta/subscriptions/plans/plans.js.map +0 -1
  176. package/resources/beta/subscriptions/plans/plans.mjs +0 -44
  177. package/resources/beta/subscriptions/plans/plans.mjs.map +0 -1
  178. package/resources/beta/subscriptions/plans.d.mts +0 -2
  179. package/resources/beta/subscriptions/plans.d.mts.map +0 -1
  180. package/resources/beta/subscriptions/plans.d.ts +0 -2
  181. package/resources/beta/subscriptions/plans.d.ts.map +0 -1
  182. package/resources/beta/subscriptions/plans.js.map +0 -1
  183. package/resources/beta/subscriptions/plans.mjs.map +0 -1
  184. package/resources/beta/subscriptions/subscriptions.d.mts.map +0 -1
  185. package/resources/beta/subscriptions/subscriptions.d.ts.map +0 -1
  186. package/resources/beta/subscriptions/subscriptions.js +0 -47
  187. package/resources/beta/subscriptions/subscriptions.js.map +0 -1
  188. package/resources/beta/subscriptions/subscriptions.mjs +0 -42
  189. package/resources/beta/subscriptions/subscriptions.mjs.map +0 -1
  190. package/resources/beta/subscriptions.d.mts +0 -2
  191. package/resources/beta/subscriptions.d.mts.map +0 -1
  192. package/resources/beta/subscriptions.d.ts +0 -2
  193. package/resources/beta/subscriptions.d.ts.map +0 -1
  194. package/resources/beta/subscriptions.js.map +0 -1
  195. package/resources/beta/subscriptions.mjs.map +0 -1
  196. package/src/resources/beta/subscriptions/coupons.ts +0 -221
  197. package/src/resources/beta/subscriptions/customers.ts +0 -168
  198. package/src/resources/beta/subscriptions/entitlements.ts +0 -113
  199. package/src/resources/beta/subscriptions/plans/plans.ts +0 -159
@@ -0,0 +1,229 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../core/pagination';
6
+ import { buildHeaders } from '../../../internal/headers';
7
+ import { RequestOptions } from '../../../internal/request-options';
8
+ import { path } from '../../../internal/utils/path';
9
+
10
+ export class Customers extends APIResource {
11
+ /**
12
+ * Creates a new billable customer. A customer represents the entity in your app
13
+ * that will be charged—typically a user, organization, or project. Hercules
14
+ * recommends creating a customer immediately after creating the corresponding
15
+ * entity in your app.
16
+ */
17
+ create(body: CustomerCreateParams | null | undefined = {}, options?: RequestOptions): APIPromise<Customer> {
18
+ return this._client.post('/v1/pay/customers', { body, ...options });
19
+ }
20
+
21
+ /**
22
+ * Updates an existing customer. Use this to modify contact information or billing
23
+ * address. Only provided fields are updated; omitted fields remain unchanged.
24
+ */
25
+ update(
26
+ customerID: string,
27
+ body: CustomerUpdateParams | null | undefined = {},
28
+ options?: RequestOptions,
29
+ ): APIPromise<Customer> {
30
+ return this._client.patch(path`/v1/pay/customers/${customerID}`, { body, ...options });
31
+ }
32
+
33
+ /**
34
+ * Retrieves a paginated list of all customers. Customers are the billable entities
35
+ * in your app—typically users, organizations, or projects.
36
+ */
37
+ list(
38
+ query: CustomerListParams | null | undefined = {},
39
+ options?: RequestOptions,
40
+ ): PagePromise<CustomersCursorIDPage, Customer> {
41
+ return this._client.getAPIList('/v1/pay/customers', CursorIDPage<Customer>, { query, ...options });
42
+ }
43
+
44
+ /**
45
+ * Permanently deletes a customer. This also cancels any active subscriptions. This
46
+ * action cannot be undone.
47
+ */
48
+ delete(customerID: string, options?: RequestOptions): APIPromise<void> {
49
+ return this._client.delete(path`/v1/pay/customers/${customerID}`, {
50
+ ...options,
51
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
52
+ });
53
+ }
54
+
55
+ /**
56
+ * Generates a URL to a hosted billing portal where the customer can view invoices,
57
+ * update payment methods, and manage billing details. Redirect the customer to the
58
+ * returned URL.
59
+ */
60
+ billingPortal(
61
+ customerID: string,
62
+ body: CustomerBillingPortalParams | null | undefined = {},
63
+ options?: RequestOptions,
64
+ ): APIPromise<CustomerBillingPortalResponse> {
65
+ return this._client.post(path`/v1/pay/customers/${customerID}/billing_portal`, { body, ...options });
66
+ }
67
+
68
+ /**
69
+ * Retrieves a customer by ID. Returns the customer object including contact
70
+ * information and billing address.
71
+ */
72
+ get(customerID: string, options?: RequestOptions): APIPromise<Customer> {
73
+ return this._client.get(path`/v1/pay/customers/${customerID}`, options);
74
+ }
75
+ }
76
+
77
+ export type CustomersCursorIDPage = CursorIDPage<Customer>;
78
+
79
+ /**
80
+ * A billable customer. Represents the entity in your app that will be
81
+ * charged—typically a user, organization, or project.
82
+ */
83
+ export interface Customer {
84
+ /**
85
+ * Unique identifier for the entitlement
86
+ */
87
+ id: string;
88
+
89
+ /**
90
+ * Timestamp when the customer was created
91
+ */
92
+ created: string;
93
+
94
+ /**
95
+ * The customer's billing address
96
+ */
97
+ address?: CustomerAddress | null;
98
+
99
+ /**
100
+ * The customer's email address for receipts and notifications
101
+ */
102
+ email?: string | null;
103
+
104
+ /**
105
+ * The customer's full name
106
+ */
107
+ name?: string | null;
108
+
109
+ /**
110
+ * The customer's phone number
111
+ */
112
+ phone?: string | null;
113
+ }
114
+
115
+ /**
116
+ * The customer's billing address
117
+ */
118
+ export interface CustomerAddress {
119
+ /**
120
+ * City name
121
+ */
122
+ city?: string | null;
123
+
124
+ /**
125
+ * Two-letter ISO country code
126
+ */
127
+ country?: string | null;
128
+
129
+ /**
130
+ * Street address line 1
131
+ */
132
+ line1?: string | null;
133
+
134
+ /**
135
+ * Street address line 2 (apartment, suite, etc.)
136
+ */
137
+ line2?: string | null;
138
+
139
+ /**
140
+ * Postal or ZIP code
141
+ */
142
+ postal_code?: string | null;
143
+
144
+ /**
145
+ * State, province, or region
146
+ */
147
+ state?: string | null;
148
+ }
149
+
150
+ /**
151
+ * Response containing the billing portal URL
152
+ */
153
+ export interface CustomerBillingPortalResponse {
154
+ /**
155
+ * URL to redirect the customer to for the billing portal
156
+ */
157
+ url: string;
158
+ }
159
+
160
+ export interface CustomerCreateParams {
161
+ /**
162
+ * Optional custom ID for the customer. If not provided, one will be generated.
163
+ */
164
+ id?: string;
165
+
166
+ /**
167
+ * The customer's billing address
168
+ */
169
+ address?: CustomerAddress;
170
+
171
+ /**
172
+ * The customer's email address for receipts and notifications
173
+ */
174
+ email?: string;
175
+
176
+ /**
177
+ * The customer's full name
178
+ */
179
+ name?: string;
180
+
181
+ /**
182
+ * The customer's phone number
183
+ */
184
+ phone?: string;
185
+ }
186
+
187
+ export interface CustomerUpdateParams {
188
+ /**
189
+ * The customer's billing address
190
+ */
191
+ address?: CustomerAddress;
192
+
193
+ /**
194
+ * The customer's email address for receipts and notifications
195
+ */
196
+ email?: string;
197
+
198
+ /**
199
+ * The customer's full name
200
+ */
201
+ name?: string;
202
+
203
+ /**
204
+ * The customer's phone number
205
+ */
206
+ phone?: string;
207
+ }
208
+
209
+ export interface CustomerListParams extends CursorIDPageParams {}
210
+
211
+ export interface CustomerBillingPortalParams {
212
+ /**
213
+ * URL to redirect the customer to after they exit the billing portal
214
+ */
215
+ return_url?: string;
216
+ }
217
+
218
+ export declare namespace Customers {
219
+ export {
220
+ type Customer as Customer,
221
+ type CustomerAddress as CustomerAddress,
222
+ type CustomerBillingPortalResponse as CustomerBillingPortalResponse,
223
+ type CustomersCursorIDPage as CustomersCursorIDPage,
224
+ type CustomerCreateParams as CustomerCreateParams,
225
+ type CustomerUpdateParams as CustomerUpdateParams,
226
+ type CustomerListParams as CustomerListParams,
227
+ type CustomerBillingPortalParams as CustomerBillingPortalParams,
228
+ };
229
+ }
@@ -0,0 +1,135 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../core/pagination';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+ import { path } from '../../../internal/utils/path';
8
+
9
+ export class Entitlements extends APIResource {
10
+ /**
11
+ * Creates a new feature entitlement. Entitlements represent features or
12
+ * capabilities in your app that can be gated by subscription. After creating an
13
+ * entitlement, attach it to one or more plans to grant access to customers on
14
+ * those plans.
15
+ */
16
+ create(body: EntitlementCreateParams, options?: RequestOptions): APIPromise<Entitlement> {
17
+ return this._client.post('/v1/pay/entitlements', { body, ...options });
18
+ }
19
+
20
+ /**
21
+ * Updates an existing entitlement. Use this to modify the name or deactivate the
22
+ * entitlement. The key cannot be changed after creation.
23
+ */
24
+ update(
25
+ entitlementID: string,
26
+ body: EntitlementUpdateParams | null | undefined = {},
27
+ options?: RequestOptions,
28
+ ): APIPromise<Entitlement> {
29
+ return this._client.patch(path`/v1/pay/entitlements/${entitlementID}`, { body, ...options });
30
+ }
31
+
32
+ /**
33
+ * Retrieves a paginated list of all entitlements. Entitlements represent features
34
+ * or capabilities in your app that can be gated by subscription. Use the key
35
+ * filter to find a specific entitlement by its key.
36
+ */
37
+ list(
38
+ query: EntitlementListParams | null | undefined = {},
39
+ options?: RequestOptions,
40
+ ): PagePromise<EntitlementsCursorIDPage, Entitlement> {
41
+ return this._client.getAPIList('/v1/pay/entitlements', CursorIDPage<Entitlement>, { query, ...options });
42
+ }
43
+
44
+ /**
45
+ * Retrieves an entitlement by ID. Returns the entitlement object including its
46
+ * lookup key and active status.
47
+ */
48
+ get(entitlementID: string, options?: RequestOptions): APIPromise<Entitlement> {
49
+ return this._client.get(path`/v1/pay/entitlements/${entitlementID}`, options);
50
+ }
51
+ }
52
+
53
+ export type EntitlementsCursorIDPage = CursorIDPage<Entitlement>;
54
+
55
+ /**
56
+ * The entitlement attached to the product
57
+ */
58
+ export interface Entitlement {
59
+ /**
60
+ * Unique identifier for the entitlement
61
+ */
62
+ id: string;
63
+
64
+ /**
65
+ * Whether the entitlement is active and can be attached to products
66
+ */
67
+ active: boolean;
68
+
69
+ /**
70
+ * Unique key to identify the entitlement when checking access in your app
71
+ */
72
+ key: string;
73
+
74
+ /**
75
+ * Whether this is a live mode entitlement (vs test mode)
76
+ */
77
+ livemode: boolean;
78
+
79
+ /**
80
+ * Display name for the entitlement (e.g., API Access, Premium Support)
81
+ */
82
+ name: string;
83
+ }
84
+
85
+ export interface EntitlementCreateParams {
86
+ /**
87
+ * Unique key to identify the entitlement when checking access. Use a descriptive,
88
+ * stable key (e.g., api_access, premium_support).
89
+ */
90
+ key: string;
91
+
92
+ /**
93
+ * Display name for the entitlement (e.g., API Access, Premium Support)
94
+ */
95
+ name: string;
96
+
97
+ /**
98
+ * Optional custom ID for the entitlement. If not provided, one will be generated.
99
+ */
100
+ id?: string;
101
+ }
102
+
103
+ export interface EntitlementUpdateParams {
104
+ /**
105
+ * Whether the entitlement is active. Deactivating removes it from access checks.
106
+ */
107
+ active?: boolean;
108
+
109
+ /**
110
+ * Display name for the entitlement
111
+ */
112
+ name?: string;
113
+ }
114
+
115
+ export interface EntitlementListParams extends CursorIDPageParams {
116
+ /**
117
+ * Filter by archived status
118
+ */
119
+ archived?: 'true' | 'false';
120
+
121
+ /**
122
+ * Filter by exact key match
123
+ */
124
+ key?: string;
125
+ }
126
+
127
+ export declare namespace Entitlements {
128
+ export {
129
+ type Entitlement as Entitlement,
130
+ type EntitlementsCursorIDPage as EntitlementsCursorIDPage,
131
+ type EntitlementCreateParams as EntitlementCreateParams,
132
+ type EntitlementUpdateParams as EntitlementUpdateParams,
133
+ type EntitlementListParams as EntitlementListParams,
134
+ };
135
+ }
@@ -3,11 +3,9 @@
3
3
  export {
4
4
  Coupons,
5
5
  type Coupon,
6
- type CouponValidateResponse,
7
6
  type CouponCreateParams,
8
7
  type CouponUpdateParams,
9
8
  type CouponListParams,
10
- type CouponValidateParams,
11
9
  type CouponsCursorIDPage,
12
10
  } from './coupons';
13
11
  export {
@@ -30,19 +28,19 @@ export {
30
28
  type EntitlementsCursorIDPage,
31
29
  } from './entitlements';
32
30
  export {
33
- Plans,
34
- type Plan,
35
- type PlanCreateParams,
36
- type PlanUpdateParams,
37
- type PlanListParams,
38
- type PlansCursorIDPage,
39
- } from './plans/index';
31
+ Pay,
32
+ type PayCancelResponse,
33
+ type PayCheckResponse,
34
+ type PayCheckoutResponse,
35
+ type PayCancelParams,
36
+ type PayCheckParams,
37
+ type PayCheckoutParams,
38
+ } from './pay';
40
39
  export {
41
- Subscriptions,
42
- type SubscriptionCancelResponse,
43
- type SubscriptionCheckResponse,
44
- type SubscriptionCheckoutResponse,
45
- type SubscriptionCancelParams,
46
- type SubscriptionCheckParams,
47
- type SubscriptionCheckoutParams,
48
- } from './subscriptions';
40
+ Products,
41
+ type Product,
42
+ type ProductCreateParams,
43
+ type ProductUpdateParams,
44
+ type ProductListParams,
45
+ type ProductsCursorIDPage,
46
+ } from './products/index';
@@ -7,8 +7,6 @@ import {
7
7
  CouponCreateParams,
8
8
  CouponListParams,
9
9
  CouponUpdateParams,
10
- CouponValidateParams,
11
- CouponValidateResponse,
12
10
  Coupons,
13
11
  CouponsCursorIDPage,
14
12
  } from './coupons';
@@ -33,62 +31,66 @@ import {
33
31
  Entitlements,
34
32
  EntitlementsCursorIDPage,
35
33
  } from './entitlements';
36
- import * as PlansAPI from './plans/plans';
34
+ import * as ProductsAPI from './products/products';
37
35
  import {
38
- Plan,
39
- PlanCreateParams,
40
- PlanListParams,
41
- PlanUpdateParams,
42
- Plans,
43
- PlansCursorIDPage,
44
- } from './plans/plans';
36
+ Product,
37
+ ProductCreateParams,
38
+ ProductListParams,
39
+ ProductUpdateParams,
40
+ Products,
41
+ ProductsCursorIDPage,
42
+ } from './products/products';
45
43
  import { APIPromise } from '../../../core/api-promise';
46
44
  import { RequestOptions } from '../../../internal/request-options';
47
45
 
48
- export class Subscriptions extends APIResource {
46
+ export class Pay extends APIResource {
49
47
  customers: CustomersAPI.Customers = new CustomersAPI.Customers(this._client);
50
- plans: PlansAPI.Plans = new PlansAPI.Plans(this._client);
48
+ products: ProductsAPI.Products = new ProductsAPI.Products(this._client);
51
49
  entitlements: EntitlementsAPI.Entitlements = new EntitlementsAPI.Entitlements(this._client);
52
50
  coupons: CouponsAPI.Coupons = new CouponsAPI.Coupons(this._client);
53
51
 
54
52
  /**
55
- * Cancel Subscription
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
56
  */
57
- cancel(body: SubscriptionCancelParams, options?: RequestOptions): APIPromise<SubscriptionCancelResponse> {
58
- return this._client.post('/v1/subscriptions/cancel', { body, ...options });
57
+ cancel(body: PayCancelParams, options?: RequestOptions): APIPromise<PayCancelResponse> {
58
+ return this._client.post('/v1/pay/cancel', { body, ...options });
59
59
  }
60
60
 
61
61
  /**
62
- * Check Entitlement
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.
63
66
  */
64
- check(body: SubscriptionCheckParams, options?: RequestOptions): APIPromise<SubscriptionCheckResponse> {
65
- return this._client.post('/v1/subscriptions/check', { body, ...options });
67
+ check(body: PayCheckParams, options?: RequestOptions): APIPromise<PayCheckResponse> {
68
+ return this._client.post('/v1/pay/check', { body, ...options });
66
69
  }
67
70
 
68
71
  /**
69
- * Create Checkout Session
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.
70
75
  */
71
- checkout(
72
- body: SubscriptionCheckoutParams,
73
- options?: RequestOptions,
74
- ): APIPromise<SubscriptionCheckoutResponse> {
75
- return this._client.post('/v1/subscriptions/checkout', { body, ...options });
76
+ checkout(body: PayCheckoutParams, options?: RequestOptions): APIPromise<PayCheckoutResponse> {
77
+ return this._client.post('/v1/pay/checkout', { body, ...options });
76
78
  }
77
79
  }
78
80
 
79
81
  /**
80
82
  * Cancel subscription response
81
83
  */
82
- export interface SubscriptionCancelResponse {
84
+ export interface PayCancelResponse {
83
85
  /**
84
86
  * The subscription ID
85
87
  */
86
88
  id: string;
87
89
 
88
90
  /**
89
- * Whether the subscription will cancel at period end
91
+ * When the cancellation takes effect
90
92
  */
91
- cancel_at_period_end: boolean;
93
+ cancellation_timing: 'immediate' | 'at_billing_period_end';
92
94
 
93
95
  /**
94
96
  * The subscription status
@@ -104,16 +106,16 @@ export interface SubscriptionCancelResponse {
104
106
  /**
105
107
  * Check entitlement response
106
108
  */
107
- export interface SubscriptionCheckResponse {
109
+ export interface PayCheckResponse {
108
110
  /**
109
111
  * Whether the customer has the entitlement
110
112
  */
111
113
  has_entitlement: boolean;
112
114
 
113
115
  /**
114
- * The entitlement lookup key that was checked
116
+ * The entitlement key that was checked
115
117
  */
116
- lookup_key: string;
118
+ key: string;
117
119
 
118
120
  /**
119
121
  * The active entitlement ID if present
@@ -124,7 +126,7 @@ export interface SubscriptionCheckResponse {
124
126
  /**
125
127
  * Checkout session response
126
128
  */
127
- export interface SubscriptionCheckoutResponse {
129
+ export interface PayCheckoutResponse {
128
130
  /**
129
131
  * The checkout session ID
130
132
  */
@@ -136,7 +138,7 @@ export interface SubscriptionCheckoutResponse {
136
138
  url: string;
137
139
  }
138
140
 
139
- export interface SubscriptionCancelParams {
141
+ export interface PayCancelParams {
140
142
  /**
141
143
  * The customer ID
142
144
  */
@@ -148,58 +150,69 @@ export interface SubscriptionCancelParams {
148
150
  subscription_id: string;
149
151
 
150
152
  /**
151
- * Whether to cancel at period end or immediately
153
+ * When to cancel the subscription. Defaults to 'at_billing_period_end' to allow
154
+ * customers to use remaining time.
152
155
  */
153
- cancel_at_period_end?: boolean;
156
+ cancellation_timing?: 'immediate' | 'at_billing_period_end';
154
157
  }
155
158
 
156
- export interface SubscriptionCheckParams {
159
+ export interface PayCheckParams {
157
160
  /**
158
161
  * The customer ID
159
162
  */
160
163
  customer_id: string;
161
164
 
162
165
  /**
163
- * The entitlement feature lookup key to check
166
+ * The entitlement key to check for access
164
167
  */
165
- entitlement_lookup_key: string;
168
+ entitlement_key: string;
166
169
  }
167
170
 
168
- export interface SubscriptionCheckoutParams {
171
+ export interface PayCheckoutParams {
169
172
  /**
170
173
  * The customer ID
171
174
  */
172
175
  customer_id: string;
173
176
 
174
177
  /**
175
- * The plan ID to subscribe to
178
+ * The product ID to subscribe to
176
179
  */
177
- plan_id: string;
180
+ product_id: string;
181
+
182
+ /**
183
+ * Optional custom ID for the subscription. If not provided, one will be generated.
184
+ */
185
+ id?: string;
178
186
 
179
187
  /**
180
188
  * URL to redirect on cancel
181
189
  */
182
190
  cancel_url?: string;
183
191
 
192
+ /**
193
+ * Promotion code to apply
194
+ */
195
+ promotion_code?: string;
196
+
184
197
  /**
185
198
  * URL to redirect on success
186
199
  */
187
200
  success_url?: string;
188
201
  }
189
202
 
190
- Subscriptions.Customers = Customers;
191
- Subscriptions.Plans = Plans;
192
- Subscriptions.Entitlements = Entitlements;
193
- Subscriptions.Coupons = Coupons;
203
+ Pay.Customers = Customers;
204
+ Pay.Products = Products;
205
+ Pay.Entitlements = Entitlements;
206
+ Pay.Coupons = Coupons;
194
207
 
195
- export declare namespace Subscriptions {
208
+ export declare namespace Pay {
196
209
  export {
197
- type SubscriptionCancelResponse as SubscriptionCancelResponse,
198
- type SubscriptionCheckResponse as SubscriptionCheckResponse,
199
- type SubscriptionCheckoutResponse as SubscriptionCheckoutResponse,
200
- type SubscriptionCancelParams as SubscriptionCancelParams,
201
- type SubscriptionCheckParams as SubscriptionCheckParams,
202
- type SubscriptionCheckoutParams as SubscriptionCheckoutParams,
210
+ type PayCancelResponse as PayCancelResponse,
211
+ type PayCheckResponse as PayCheckResponse,
212
+ type PayCheckoutResponse as PayCheckoutResponse,
213
+ type PayCancelParams as PayCancelParams,
214
+ type PayCheckParams as PayCheckParams,
215
+ type PayCheckoutParams as PayCheckoutParams,
203
216
  };
204
217
 
205
218
  export {
@@ -215,12 +228,12 @@ export declare namespace Subscriptions {
215
228
  };
216
229
 
217
230
  export {
218
- Plans as Plans,
219
- type Plan as Plan,
220
- type PlansCursorIDPage as PlansCursorIDPage,
221
- type PlanCreateParams as PlanCreateParams,
222
- type PlanUpdateParams as PlanUpdateParams,
223
- type PlanListParams as PlanListParams,
231
+ Products as Products,
232
+ type Product as Product,
233
+ type ProductsCursorIDPage as ProductsCursorIDPage,
234
+ type ProductCreateParams as ProductCreateParams,
235
+ type ProductUpdateParams as ProductUpdateParams,
236
+ type ProductListParams as ProductListParams,
224
237
  };
225
238
 
226
239
  export {
@@ -235,11 +248,9 @@ export declare namespace Subscriptions {
235
248
  export {
236
249
  Coupons as Coupons,
237
250
  type Coupon as Coupon,
238
- type CouponValidateResponse as CouponValidateResponse,
239
251
  type CouponsCursorIDPage as CouponsCursorIDPage,
240
252
  type CouponCreateParams as CouponCreateParams,
241
253
  type CouponUpdateParams as CouponUpdateParams,
242
254
  type CouponListParams as CouponListParams,
243
- type CouponValidateParams as CouponValidateParams,
244
255
  };
245
256
  }