@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.
- package/CHANGELOG.md +129 -0
- package/LICENSE +1 -1
- 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/{subscriptions → pay}/entitlements.d.mts +25 -19
- package/resources/beta/pay/entitlements.d.mts.map +1 -0
- package/resources/beta/{subscriptions → pay}/entitlements.d.ts +25 -19
- package/resources/beta/pay/entitlements.d.ts.map +1 -0
- package/resources/beta/pay/entitlements.js +41 -0
- package/resources/beta/pay/entitlements.js.map +1 -0
- package/resources/beta/pay/entitlements.mjs +37 -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/pay/pay.d.mts +206 -0
- package/resources/beta/pay/pay.d.mts.map +1 -0
- package/resources/beta/pay/pay.d.ts +206 -0
- 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 +4 -0
- package/resources/beta/pay/products/index.d.mts.map +1 -0
- package/resources/beta/pay/products/index.d.ts +4 -0
- package/resources/beta/pay/products/index.d.ts.map +1 -0
- package/resources/beta/pay/products/index.js +11 -0
- package/resources/beta/pay/products/index.js.map +1 -0
- package/resources/beta/{subscriptions/plans → pay/products}/index.mjs +2 -1
- package/resources/beta/pay/products/index.mjs.map +1 -0
- package/resources/beta/pay/products/products.d.mts +183 -0
- package/resources/beta/pay/products/products.d.mts.map +1 -0
- package/resources/beta/pay/products/products.d.ts +183 -0
- package/resources/beta/pay/products/products.d.ts.map +1 -0
- package/resources/beta/pay/products/products.js +61 -0
- package/resources/beta/pay/products/products.js.map +1 -0
- package/resources/beta/pay/products/products.mjs +56 -0
- package/resources/beta/pay/products/products.mjs.map +1 -0
- package/resources/beta/pay/products/variants.d.mts +206 -0
- package/resources/beta/pay/products/variants.d.mts.map +1 -0
- package/resources/beta/pay/products/variants.d.ts +206 -0
- package/resources/beta/pay/products/variants.d.ts.map +1 -0
- package/resources/beta/pay/products/variants.js +56 -0
- package/resources/beta/pay/products/variants.js.map +1 -0
- package/resources/beta/pay/products/variants.mjs +52 -0
- package/resources/beta/pay/products/variants.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/{subscriptions → pay}/entitlements.ts +29 -29
- package/src/resources/beta/{subscriptions → pay}/index.ts +15 -15
- package/src/resources/beta/pay/pay.ts +326 -0
- package/src/resources/beta/{subscriptions/plans → pay/products}/entitlements.ts +26 -21
- package/src/resources/beta/pay/products/index.ts +28 -0
- package/src/resources/beta/pay/products/products.ts +280 -0
- package/src/resources/beta/pay/products/variants.ts +279 -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.map +0 -1
- 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 +0 -9
- 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 +0 -130
- package/resources/beta/subscriptions/subscriptions.d.mts.map +0 -1
- package/resources/beta/subscriptions/subscriptions.d.ts +0 -130
- 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/plans/index.ts +0 -18
- package/src/resources/beta/subscriptions/plans/plans.ts +0 -159
- 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
|
-
*
|
|
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
|
-
|
|
17
|
+
productID: string,
|
|
17
18
|
query: EntitlementListParams | null | undefined = {},
|
|
18
19
|
options?: RequestOptions,
|
|
19
|
-
): PagePromise<
|
|
20
|
+
): PagePromise<ProductEntitlementsCursorIDPage, ProductEntitlement> {
|
|
20
21
|
return this._client.getAPIList(
|
|
21
|
-
path`/v1/
|
|
22
|
-
CursorIDPage<
|
|
22
|
+
path`/v1/pay/products/${productID}/entitlements`,
|
|
23
|
+
CursorIDPage<ProductEntitlement>,
|
|
23
24
|
{ query, ...options },
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
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
|
-
|
|
34
|
+
productID: string,
|
|
32
35
|
body: EntitlementAttachParams,
|
|
33
36
|
options?: RequestOptions,
|
|
34
|
-
): APIPromise<
|
|
35
|
-
return this._client.post(path`/v1/
|
|
37
|
+
): APIPromise<ProductEntitlement> {
|
|
38
|
+
return this._client.post(path`/v1/pay/products/${productID}/entitlements`, { body, ...options });
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
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 {
|
|
43
|
-
return this._client.delete(path`/v1/
|
|
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
|
|
54
|
+
export type ProductEntitlementsCursorIDPage = CursorIDPage<ProductEntitlement>;
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
|
-
* An entitlement attached to a
|
|
57
|
+
* An entitlement attached to a product. All customers subscribed to the product
|
|
58
|
+
* gain access to this entitlement.
|
|
54
59
|
*/
|
|
55
|
-
export interface
|
|
60
|
+
export interface ProductEntitlement {
|
|
56
61
|
/**
|
|
57
|
-
*
|
|
62
|
+
* Unique identifier for the price
|
|
58
63
|
*/
|
|
59
64
|
id: string;
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
|
-
*
|
|
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
|
-
|
|
82
|
+
product_id: string;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
export declare namespace Entitlements {
|
|
81
86
|
export {
|
|
82
|
-
type
|
|
83
|
-
type
|
|
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';
|