@usehercules/sdk 1.2.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.
- package/CHANGELOG.md +117 -0
- package/README.md +14 -20
- package/client.d.mts +6 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -3
- package/client.d.ts.map +1 -1
- package/client.js +1 -1
- package/client.js.map +1 -1
- package/client.mjs +1 -1
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +4 -4
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +4 -4
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +4 -4
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +4 -4
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js +3 -3
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/pay/coupons.d.mts +156 -0
- package/resources/beta/pay/coupons.d.mts.map +1 -0
- package/resources/beta/pay/coupons.d.ts +156 -0
- package/resources/beta/pay/coupons.d.ts.map +1 -0
- package/resources/beta/pay/coupons.js +51 -0
- package/resources/beta/pay/coupons.js.map +1 -0
- package/resources/beta/pay/coupons.mjs +47 -0
- package/resources/beta/pay/coupons.mjs.map +1 -0
- package/resources/beta/pay/customers.d.mts +160 -0
- package/resources/beta/pay/customers.d.mts.map +1 -0
- package/resources/beta/pay/customers.d.ts +160 -0
- package/resources/beta/pay/customers.d.ts.map +1 -0
- package/resources/beta/pay/customers.js +60 -0
- package/resources/beta/pay/customers.js.map +1 -0
- package/resources/beta/pay/customers.mjs +56 -0
- package/resources/beta/pay/customers.mjs.map +1 -0
- package/resources/beta/pay/entitlements.d.mts +94 -0
- package/resources/beta/pay/entitlements.d.mts.map +1 -0
- package/resources/beta/pay/entitlements.d.ts +94 -0
- package/resources/beta/pay/entitlements.d.ts.map +1 -0
- package/resources/beta/pay/entitlements.js +42 -0
- package/resources/beta/pay/entitlements.js.map +1 -0
- package/resources/beta/pay/entitlements.mjs +38 -0
- package/resources/beta/pay/entitlements.mjs.map +1 -0
- package/resources/beta/{subscriptions → pay}/index.d.mts +2 -2
- package/resources/beta/pay/index.d.mts.map +1 -0
- package/resources/beta/{subscriptions → pay}/index.d.ts +2 -2
- package/resources/beta/pay/index.d.ts.map +1 -0
- package/resources/beta/{subscriptions → pay}/index.js +5 -5
- package/resources/beta/pay/index.js.map +1 -0
- package/resources/beta/{subscriptions → pay}/index.mjs +2 -2
- package/resources/beta/pay/index.mjs.map +1 -0
- package/resources/beta/{subscriptions/subscriptions.d.mts → pay/pay.d.mts} +46 -30
- package/resources/beta/pay/pay.d.mts.map +1 -0
- package/resources/beta/{subscriptions/subscriptions.d.ts → pay/pay.d.ts} +46 -30
- package/resources/beta/pay/pay.d.ts.map +1 -0
- package/resources/beta/pay/pay.js +54 -0
- package/resources/beta/pay/pay.js.map +1 -0
- package/resources/beta/pay/pay.mjs +49 -0
- package/resources/beta/pay/pay.mjs.map +1 -0
- package/resources/beta/pay/products/entitlements.d.mts +53 -0
- package/resources/beta/pay/products/entitlements.d.mts.map +1 -0
- package/resources/beta/pay/products/entitlements.d.ts +53 -0
- package/resources/beta/pay/products/entitlements.d.ts.map +1 -0
- package/resources/beta/pay/products/entitlements.js +38 -0
- package/resources/beta/pay/products/entitlements.js.map +1 -0
- package/resources/beta/pay/products/entitlements.mjs +34 -0
- package/resources/beta/pay/products/entitlements.mjs.map +1 -0
- package/resources/beta/pay/products/index.d.mts +3 -0
- package/resources/beta/pay/products/index.d.mts.map +1 -0
- package/resources/beta/pay/products/index.d.ts +3 -0
- package/resources/beta/pay/products/index.d.ts.map +1 -0
- package/resources/beta/{subscriptions/plans → pay/products}/index.js +3 -3
- package/resources/beta/pay/products/index.js.map +1 -0
- package/resources/beta/{subscriptions/plans → pay/products}/index.mjs +1 -1
- package/resources/beta/pay/products/index.mjs.map +1 -0
- package/resources/beta/pay/products/products.d.mts +152 -0
- package/resources/beta/pay/products/products.d.mts.map +1 -0
- package/resources/beta/pay/products/products.d.ts +152 -0
- package/resources/beta/pay/products/products.d.ts.map +1 -0
- package/resources/beta/pay/products/products.js +57 -0
- package/resources/beta/pay/products/products.js.map +1 -0
- package/resources/beta/pay/products/products.mjs +52 -0
- package/resources/beta/pay/products/products.mjs.map +1 -0
- package/resources/beta/pay/products.d.mts +2 -0
- package/resources/beta/pay/products.d.mts.map +1 -0
- package/resources/beta/pay/products.d.ts +2 -0
- package/resources/beta/pay/products.d.ts.map +1 -0
- package/resources/beta/{subscriptions/plans.js → pay/products.js} +2 -2
- package/resources/beta/pay/products.js.map +1 -0
- package/resources/beta/{subscriptions.mjs → pay/products.mjs} +2 -2
- package/resources/beta/pay/products.mjs.map +1 -0
- package/resources/beta/pay.d.mts +2 -0
- package/resources/beta/pay.d.mts.map +1 -0
- package/resources/beta/pay.d.ts +2 -0
- package/resources/beta/pay.d.ts.map +1 -0
- package/resources/beta/{subscriptions.js → pay.js} +2 -2
- package/resources/beta/pay.js.map +1 -0
- package/resources/beta/{subscriptions/plans.mjs → pay.mjs} +2 -2
- package/resources/beta/pay.mjs.map +1 -0
- package/src/client.ts +6 -4
- package/src/resources/beta/beta.ts +18 -18
- package/src/resources/beta/index.ts +8 -8
- package/src/resources/beta/pay/coupons.ts +218 -0
- package/src/resources/beta/pay/customers.ts +229 -0
- package/src/resources/beta/pay/entitlements.ts +135 -0
- package/src/resources/beta/{subscriptions → pay}/index.ts +15 -15
- package/src/resources/beta/{subscriptions/subscriptions.ts → pay/pay.ts} +70 -55
- package/src/resources/beta/{subscriptions/plans → pay/products}/entitlements.ts +26 -21
- package/src/resources/beta/{subscriptions/plans → pay/products}/index.ts +9 -9
- package/src/resources/beta/pay/products/products.ts +224 -0
- package/src/resources/beta/{subscriptions.ts → pay/products.ts} +1 -1
- package/src/resources/beta/{subscriptions/plans.ts → pay.ts} +1 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/beta/subscriptions/coupons.d.mts +0 -124
- package/resources/beta/subscriptions/coupons.d.mts.map +0 -1
- package/resources/beta/subscriptions/coupons.d.ts +0 -124
- package/resources/beta/subscriptions/coupons.d.ts.map +0 -1
- package/resources/beta/subscriptions/coupons.js +0 -45
- package/resources/beta/subscriptions/coupons.js.map +0 -1
- package/resources/beta/subscriptions/coupons.mjs +0 -41
- package/resources/beta/subscriptions/coupons.mjs.map +0 -1
- package/resources/beta/subscriptions/customers.d.mts +0 -93
- package/resources/beta/subscriptions/customers.d.mts.map +0 -1
- package/resources/beta/subscriptions/customers.d.ts +0 -93
- package/resources/beta/subscriptions/customers.d.ts.map +0 -1
- package/resources/beta/subscriptions/customers.js +0 -57
- package/resources/beta/subscriptions/customers.js.map +0 -1
- package/resources/beta/subscriptions/customers.mjs +0 -53
- package/resources/beta/subscriptions/customers.mjs.map +0 -1
- package/resources/beta/subscriptions/entitlements.d.mts +0 -70
- package/resources/beta/subscriptions/entitlements.d.mts.map +0 -1
- package/resources/beta/subscriptions/entitlements.d.ts +0 -70
- package/resources/beta/subscriptions/entitlements.d.ts.map +0 -1
- package/resources/beta/subscriptions/entitlements.js +0 -38
- package/resources/beta/subscriptions/entitlements.js.map +0 -1
- package/resources/beta/subscriptions/entitlements.mjs +0 -34
- package/resources/beta/subscriptions/entitlements.mjs.map +0 -1
- package/resources/beta/subscriptions/index.d.mts.map +0 -1
- package/resources/beta/subscriptions/index.d.ts.map +0 -1
- package/resources/beta/subscriptions/index.js.map +0 -1
- package/resources/beta/subscriptions/index.mjs.map +0 -1
- package/resources/beta/subscriptions/plans/entitlements.d.mts +0 -48
- package/resources/beta/subscriptions/plans/entitlements.d.mts.map +0 -1
- package/resources/beta/subscriptions/plans/entitlements.d.ts +0 -48
- package/resources/beta/subscriptions/plans/entitlements.d.ts.map +0 -1
- package/resources/beta/subscriptions/plans/entitlements.js +0 -34
- package/resources/beta/subscriptions/plans/entitlements.js.map +0 -1
- package/resources/beta/subscriptions/plans/entitlements.mjs +0 -30
- package/resources/beta/subscriptions/plans/entitlements.mjs.map +0 -1
- package/resources/beta/subscriptions/plans/index.d.mts +0 -3
- package/resources/beta/subscriptions/plans/index.d.mts.map +0 -1
- package/resources/beta/subscriptions/plans/index.d.ts +0 -3
- package/resources/beta/subscriptions/plans/index.d.ts.map +0 -1
- package/resources/beta/subscriptions/plans/index.js.map +0 -1
- package/resources/beta/subscriptions/plans/index.mjs.map +0 -1
- package/resources/beta/subscriptions/plans/plans.d.mts +0 -87
- package/resources/beta/subscriptions/plans/plans.d.mts.map +0 -1
- package/resources/beta/subscriptions/plans/plans.d.ts +0 -87
- package/resources/beta/subscriptions/plans/plans.d.ts.map +0 -1
- package/resources/beta/subscriptions/plans/plans.js +0 -49
- package/resources/beta/subscriptions/plans/plans.js.map +0 -1
- package/resources/beta/subscriptions/plans/plans.mjs +0 -44
- package/resources/beta/subscriptions/plans/plans.mjs.map +0 -1
- package/resources/beta/subscriptions/plans.d.mts +0 -2
- package/resources/beta/subscriptions/plans.d.mts.map +0 -1
- package/resources/beta/subscriptions/plans.d.ts +0 -2
- package/resources/beta/subscriptions/plans.d.ts.map +0 -1
- package/resources/beta/subscriptions/plans.js.map +0 -1
- package/resources/beta/subscriptions/plans.mjs.map +0 -1
- package/resources/beta/subscriptions/subscriptions.d.mts.map +0 -1
- package/resources/beta/subscriptions/subscriptions.d.ts.map +0 -1
- package/resources/beta/subscriptions/subscriptions.js +0 -47
- package/resources/beta/subscriptions/subscriptions.js.map +0 -1
- package/resources/beta/subscriptions/subscriptions.mjs +0 -42
- package/resources/beta/subscriptions/subscriptions.mjs.map +0 -1
- package/resources/beta/subscriptions.d.mts +0 -2
- package/resources/beta/subscriptions.d.mts.map +0 -1
- package/resources/beta/subscriptions.d.ts +0 -2
- package/resources/beta/subscriptions.d.ts.map +0 -1
- package/resources/beta/subscriptions.js.map +0 -1
- package/resources/beta/subscriptions.mjs.map +0 -1
- package/src/resources/beta/subscriptions/coupons.ts +0 -185
- package/src/resources/beta/subscriptions/customers.ts +0 -168
- package/src/resources/beta/subscriptions/entitlements.ts +0 -113
- 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
|
+
}
|
|
@@ -28,19 +28,19 @@ export {
|
|
|
28
28
|
type EntitlementsCursorIDPage,
|
|
29
29
|
} from './entitlements';
|
|
30
30
|
export {
|
|
31
|
-
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
type
|
|
37
|
-
|
|
31
|
+
Pay,
|
|
32
|
+
type PayCancelResponse,
|
|
33
|
+
type PayCheckResponse,
|
|
34
|
+
type PayCheckoutResponse,
|
|
35
|
+
type PayCancelParams,
|
|
36
|
+
type PayCheckParams,
|
|
37
|
+
type PayCheckoutParams,
|
|
38
|
+
} from './pay';
|
|
38
39
|
export {
|
|
39
|
-
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
43
|
-
type
|
|
44
|
-
type
|
|
45
|
-
|
|
46
|
-
} from './subscriptions';
|
|
40
|
+
Products,
|
|
41
|
+
type Product,
|
|
42
|
+
type ProductCreateParams,
|
|
43
|
+
type ProductUpdateParams,
|
|
44
|
+
type ProductListParams,
|
|
45
|
+
type ProductsCursorIDPage,
|
|
46
|
+
} from './products/index';
|
|
@@ -31,62 +31,66 @@ import {
|
|
|
31
31
|
Entitlements,
|
|
32
32
|
EntitlementsCursorIDPage,
|
|
33
33
|
} from './entitlements';
|
|
34
|
-
import * as
|
|
34
|
+
import * as ProductsAPI from './products/products';
|
|
35
35
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} from './
|
|
36
|
+
Product,
|
|
37
|
+
ProductCreateParams,
|
|
38
|
+
ProductListParams,
|
|
39
|
+
ProductUpdateParams,
|
|
40
|
+
Products,
|
|
41
|
+
ProductsCursorIDPage,
|
|
42
|
+
} from './products/products';
|
|
43
43
|
import { APIPromise } from '../../../core/api-promise';
|
|
44
44
|
import { RequestOptions } from '../../../internal/request-options';
|
|
45
45
|
|
|
46
|
-
export class
|
|
46
|
+
export class Pay extends APIResource {
|
|
47
47
|
customers: CustomersAPI.Customers = new CustomersAPI.Customers(this._client);
|
|
48
|
-
|
|
48
|
+
products: ProductsAPI.Products = new ProductsAPI.Products(this._client);
|
|
49
49
|
entitlements: EntitlementsAPI.Entitlements = new EntitlementsAPI.Entitlements(this._client);
|
|
50
50
|
coupons: CouponsAPI.Coupons = new CouponsAPI.Coupons(this._client);
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
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.
|
|
54
56
|
*/
|
|
55
|
-
cancel(body:
|
|
56
|
-
return this._client.post('/v1/
|
|
57
|
+
cancel(body: PayCancelParams, options?: RequestOptions): APIPromise<PayCancelResponse> {
|
|
58
|
+
return this._client.post('/v1/pay/cancel', { body, ...options });
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
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.
|
|
61
66
|
*/
|
|
62
|
-
check(body:
|
|
63
|
-
return this._client.post('/v1/
|
|
67
|
+
check(body: PayCheckParams, options?: RequestOptions): APIPromise<PayCheckResponse> {
|
|
68
|
+
return this._client.post('/v1/pay/check', { body, ...options });
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
|
-
*
|
|
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.
|
|
68
75
|
*/
|
|
69
|
-
checkout(
|
|
70
|
-
body
|
|
71
|
-
options?: RequestOptions,
|
|
72
|
-
): APIPromise<SubscriptionCheckoutResponse> {
|
|
73
|
-
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 });
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
82
|
* Cancel subscription response
|
|
79
83
|
*/
|
|
80
|
-
export interface
|
|
84
|
+
export interface PayCancelResponse {
|
|
81
85
|
/**
|
|
82
86
|
* The subscription ID
|
|
83
87
|
*/
|
|
84
88
|
id: string;
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
|
-
*
|
|
91
|
+
* When the cancellation takes effect
|
|
88
92
|
*/
|
|
89
|
-
|
|
93
|
+
cancellation_timing: 'immediate' | 'at_billing_period_end';
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
96
|
* The subscription status
|
|
@@ -102,16 +106,16 @@ export interface SubscriptionCancelResponse {
|
|
|
102
106
|
/**
|
|
103
107
|
* Check entitlement response
|
|
104
108
|
*/
|
|
105
|
-
export interface
|
|
109
|
+
export interface PayCheckResponse {
|
|
106
110
|
/**
|
|
107
111
|
* Whether the customer has the entitlement
|
|
108
112
|
*/
|
|
109
113
|
has_entitlement: boolean;
|
|
110
114
|
|
|
111
115
|
/**
|
|
112
|
-
* The entitlement
|
|
116
|
+
* The entitlement key that was checked
|
|
113
117
|
*/
|
|
114
|
-
|
|
118
|
+
key: string;
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
121
|
* The active entitlement ID if present
|
|
@@ -122,7 +126,7 @@ export interface SubscriptionCheckResponse {
|
|
|
122
126
|
/**
|
|
123
127
|
* Checkout session response
|
|
124
128
|
*/
|
|
125
|
-
export interface
|
|
129
|
+
export interface PayCheckoutResponse {
|
|
126
130
|
/**
|
|
127
131
|
* The checkout session ID
|
|
128
132
|
*/
|
|
@@ -134,7 +138,7 @@ export interface SubscriptionCheckoutResponse {
|
|
|
134
138
|
url: string;
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
export interface
|
|
141
|
+
export interface PayCancelParams {
|
|
138
142
|
/**
|
|
139
143
|
* The customer ID
|
|
140
144
|
*/
|
|
@@ -146,58 +150,69 @@ export interface SubscriptionCancelParams {
|
|
|
146
150
|
subscription_id: string;
|
|
147
151
|
|
|
148
152
|
/**
|
|
149
|
-
*
|
|
153
|
+
* When to cancel the subscription. Defaults to 'at_billing_period_end' to allow
|
|
154
|
+
* customers to use remaining time.
|
|
150
155
|
*/
|
|
151
|
-
|
|
156
|
+
cancellation_timing?: 'immediate' | 'at_billing_period_end';
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
export interface
|
|
159
|
+
export interface PayCheckParams {
|
|
155
160
|
/**
|
|
156
161
|
* The customer ID
|
|
157
162
|
*/
|
|
158
163
|
customer_id: string;
|
|
159
164
|
|
|
160
165
|
/**
|
|
161
|
-
* The entitlement
|
|
166
|
+
* The entitlement key to check for access
|
|
162
167
|
*/
|
|
163
|
-
|
|
168
|
+
entitlement_key: string;
|
|
164
169
|
}
|
|
165
170
|
|
|
166
|
-
export interface
|
|
171
|
+
export interface PayCheckoutParams {
|
|
167
172
|
/**
|
|
168
173
|
* The customer ID
|
|
169
174
|
*/
|
|
170
175
|
customer_id: string;
|
|
171
176
|
|
|
172
177
|
/**
|
|
173
|
-
* The
|
|
178
|
+
* The product ID to subscribe to
|
|
174
179
|
*/
|
|
175
|
-
|
|
180
|
+
product_id: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Optional custom ID for the subscription. If not provided, one will be generated.
|
|
184
|
+
*/
|
|
185
|
+
id?: string;
|
|
176
186
|
|
|
177
187
|
/**
|
|
178
188
|
* URL to redirect on cancel
|
|
179
189
|
*/
|
|
180
190
|
cancel_url?: string;
|
|
181
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Promotion code to apply
|
|
194
|
+
*/
|
|
195
|
+
promotion_code?: string;
|
|
196
|
+
|
|
182
197
|
/**
|
|
183
198
|
* URL to redirect on success
|
|
184
199
|
*/
|
|
185
200
|
success_url?: string;
|
|
186
201
|
}
|
|
187
202
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
203
|
+
Pay.Customers = Customers;
|
|
204
|
+
Pay.Products = Products;
|
|
205
|
+
Pay.Entitlements = Entitlements;
|
|
206
|
+
Pay.Coupons = Coupons;
|
|
192
207
|
|
|
193
|
-
export declare namespace
|
|
208
|
+
export declare namespace Pay {
|
|
194
209
|
export {
|
|
195
|
-
type
|
|
196
|
-
type
|
|
197
|
-
type
|
|
198
|
-
type
|
|
199
|
-
type
|
|
200
|
-
type
|
|
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,
|
|
201
216
|
};
|
|
202
217
|
|
|
203
218
|
export {
|
|
@@ -213,12 +228,12 @@ export declare namespace Subscriptions {
|
|
|
213
228
|
};
|
|
214
229
|
|
|
215
230
|
export {
|
|
216
|
-
|
|
217
|
-
type
|
|
218
|
-
type
|
|
219
|
-
type
|
|
220
|
-
type
|
|
221
|
-
type
|
|
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,
|
|
222
237
|
};
|
|
223
238
|
|
|
224
239
|
export {
|