@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,218 @@
|
|
|
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 Coupons extends APIResource {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a discount coupon with a promo code. Coupons can offer percentage or
|
|
13
|
+
* fixed-amount discounts and can be limited by redemption count or expiration
|
|
14
|
+
* date. Customers can apply coupons during checkout.
|
|
15
|
+
*/
|
|
16
|
+
create(body: CouponCreateParams, options?: RequestOptions): APIPromise<Coupon> {
|
|
17
|
+
return this._client.post('/v1/pay/coupons', { body, ...options });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Updates an existing coupon. Use this to modify the display name or deactivate
|
|
22
|
+
* the coupon. Discount amounts and codes cannot be changed after creation.
|
|
23
|
+
*/
|
|
24
|
+
update(
|
|
25
|
+
couponID: string,
|
|
26
|
+
body: CouponUpdateParams | null | undefined = {},
|
|
27
|
+
options?: RequestOptions,
|
|
28
|
+
): APIPromise<Coupon> {
|
|
29
|
+
return this._client.patch(path`/v1/pay/coupons/${couponID}`, { body, ...options });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves a paginated list of all coupons. Coupons provide discounts that
|
|
34
|
+
* customers can apply during checkout using a promo code.
|
|
35
|
+
*/
|
|
36
|
+
list(
|
|
37
|
+
query: CouponListParams | null | undefined = {},
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): PagePromise<CouponsCursorIDPage, Coupon> {
|
|
40
|
+
return this._client.getAPIList('/v1/pay/coupons', CursorIDPage<Coupon>, { query, ...options });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Permanently deletes a coupon. The promo code can no longer be used. Existing
|
|
45
|
+
* discounts applied to active subscriptions are not affected.
|
|
46
|
+
*/
|
|
47
|
+
delete(couponID: string, options?: RequestOptions): APIPromise<void> {
|
|
48
|
+
return this._client.delete(path`/v1/pay/coupons/${couponID}`, {
|
|
49
|
+
...options,
|
|
50
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves a coupon by ID. Returns the coupon object including discount details
|
|
56
|
+
* and redemption statistics.
|
|
57
|
+
*/
|
|
58
|
+
get(couponID: string, options?: RequestOptions): APIPromise<Coupon> {
|
|
59
|
+
return this._client.get(path`/v1/pay/coupons/${couponID}`, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type CouponsCursorIDPage = CursorIDPage<Coupon>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A discount coupon that customers can apply during checkout using a promo code
|
|
67
|
+
*/
|
|
68
|
+
export interface Coupon {
|
|
69
|
+
/**
|
|
70
|
+
* Unique identifier for the price
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Whether the coupon is currently active and can be redeemed
|
|
76
|
+
*/
|
|
77
|
+
active: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The promo code customers enter to apply the discount
|
|
81
|
+
*/
|
|
82
|
+
code: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Timestamp when the coupon was created
|
|
86
|
+
*/
|
|
87
|
+
created: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* How long the discount applies: once (first payment only), repeating (for
|
|
91
|
+
* duration_in_months), or forever
|
|
92
|
+
*/
|
|
93
|
+
duration: 'once' | 'repeating' | 'forever';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Number of times this coupon has been successfully redeemed
|
|
97
|
+
*/
|
|
98
|
+
times_redeemed: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Fixed discount amount in the smallest currency unit (e.g., cents). Mutually
|
|
102
|
+
* exclusive with percent_off.
|
|
103
|
+
*/
|
|
104
|
+
amount_off?: number | null;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Three-letter ISO currency code for amount_off discounts
|
|
108
|
+
*/
|
|
109
|
+
currency?: string | null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Number of months the discount applies when duration is 'repeating'
|
|
113
|
+
*/
|
|
114
|
+
duration_in_months?: number | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Maximum number of times this coupon can be redeemed across all customers
|
|
118
|
+
*/
|
|
119
|
+
max_redemptions?: number | null;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Display name for the coupon (shown to customers)
|
|
123
|
+
*/
|
|
124
|
+
name?: string | null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Percentage discount (1-100). Mutually exclusive with amount_off.
|
|
128
|
+
*/
|
|
129
|
+
percent_off?: number | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Expiration date after which the coupon can no longer be redeemed
|
|
133
|
+
*/
|
|
134
|
+
redeem_by?: string | null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface CouponCreateParams {
|
|
138
|
+
/**
|
|
139
|
+
* The promo code customers will enter to apply the discount
|
|
140
|
+
*/
|
|
141
|
+
code: string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Optional custom ID for the coupon. If not provided, one will be generated.
|
|
145
|
+
*/
|
|
146
|
+
id?: string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Fixed discount in the smallest currency unit (e.g., cents). Mutually exclusive
|
|
150
|
+
* with percent_off.
|
|
151
|
+
*/
|
|
152
|
+
amount_off?: number;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Three-letter ISO currency code for amount_off discounts
|
|
156
|
+
*/
|
|
157
|
+
currency?: string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* How long the discount applies: once (first payment only), repeating (for
|
|
161
|
+
* duration_in_months), or forever
|
|
162
|
+
*/
|
|
163
|
+
duration?: 'once' | 'repeating' | 'forever';
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Number of months the discount applies when duration is 'repeating'
|
|
167
|
+
*/
|
|
168
|
+
duration_in_months?: number;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Maximum number of times this coupon can be redeemed
|
|
172
|
+
*/
|
|
173
|
+
max_redemptions?: number;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Display name for the coupon (shown to customers)
|
|
177
|
+
*/
|
|
178
|
+
name?: string;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Percentage discount (1-100). Mutually exclusive with amount_off.
|
|
182
|
+
*/
|
|
183
|
+
percent_off?: number;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Expiration date after which the coupon can no longer be redeemed
|
|
187
|
+
*/
|
|
188
|
+
redeem_by?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface CouponUpdateParams {
|
|
192
|
+
/**
|
|
193
|
+
* Whether the coupon is active and can be redeemed
|
|
194
|
+
*/
|
|
195
|
+
active?: boolean;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Display name for the coupon
|
|
199
|
+
*/
|
|
200
|
+
name?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface CouponListParams extends CursorIDPageParams {
|
|
204
|
+
/**
|
|
205
|
+
* Filter by active status
|
|
206
|
+
*/
|
|
207
|
+
active?: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export declare namespace Coupons {
|
|
211
|
+
export {
|
|
212
|
+
type Coupon as Coupon,
|
|
213
|
+
type CouponsCursorIDPage as CouponsCursorIDPage,
|
|
214
|
+
type CouponCreateParams as CouponCreateParams,
|
|
215
|
+
type CouponUpdateParams as CouponUpdateParams,
|
|
216
|
+
type CouponListParams as CouponListParams,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
@@ -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 price
|
|
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
|
+
}
|
|
@@ -8,84 +8,89 @@ import { path } from '../../../internal/utils/path';
|
|
|
8
8
|
|
|
9
9
|
export class Entitlements extends APIResource {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
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.
|
|
12
15
|
*/
|
|
13
16
|
create(body: EntitlementCreateParams, options?: RequestOptions): APIPromise<Entitlement> {
|
|
14
|
-
return this._client.post('/v1/
|
|
17
|
+
return this._client.post('/v1/pay/entitlements', { body, ...options });
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* Updates an existing entitlement. Use this to modify the name or deactivate the
|
|
22
|
+
* entitlement.
|
|
19
23
|
*/
|
|
20
24
|
update(
|
|
21
25
|
entitlementID: string,
|
|
22
26
|
body: EntitlementUpdateParams | null | undefined = {},
|
|
23
27
|
options?: RequestOptions,
|
|
24
28
|
): APIPromise<Entitlement> {
|
|
25
|
-
return this._client.patch(path`/v1/
|
|
29
|
+
return this._client.patch(path`/v1/pay/entitlements/${entitlementID}`, { body, ...options });
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
|
-
*
|
|
33
|
+
* Retrieves a paginated list of all entitlements. Entitlements represent features
|
|
34
|
+
* or capabilities in your app that can be gated by subscription.
|
|
30
35
|
*/
|
|
31
36
|
list(
|
|
32
37
|
query: EntitlementListParams | null | undefined = {},
|
|
33
38
|
options?: RequestOptions,
|
|
34
39
|
): PagePromise<EntitlementsCursorIDPage, Entitlement> {
|
|
35
|
-
return this._client.getAPIList('/v1/
|
|
36
|
-
query,
|
|
37
|
-
...options,
|
|
38
|
-
});
|
|
40
|
+
return this._client.getAPIList('/v1/pay/entitlements', CursorIDPage<Entitlement>, { query, ...options });
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
|
-
*
|
|
44
|
+
* Retrieves an entitlement by ID. Returns the entitlement object including its
|
|
45
|
+
* active status.
|
|
43
46
|
*/
|
|
44
47
|
get(entitlementID: string, options?: RequestOptions): APIPromise<Entitlement> {
|
|
45
|
-
return this._client.get(path`/v1/
|
|
48
|
+
return this._client.get(path`/v1/pay/entitlements/${entitlementID}`, options);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export type EntitlementsCursorIDPage = CursorIDPage<Entitlement>;
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* The entitlement attached to the product
|
|
53
56
|
*/
|
|
54
57
|
export interface Entitlement {
|
|
55
58
|
/**
|
|
56
|
-
*
|
|
59
|
+
* Unique identifier for the price
|
|
57
60
|
*/
|
|
58
61
|
id: string;
|
|
59
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Whether the entitlement is active and can be attached to products
|
|
65
|
+
*/
|
|
60
66
|
active: boolean;
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Display name for the entitlement (e.g., API Access, Premium Support)
|
|
70
|
+
*/
|
|
66
71
|
name: string;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
export interface EntitlementCreateParams {
|
|
70
75
|
/**
|
|
71
|
-
*
|
|
76
|
+
* Display name for the entitlement (e.g., API Access, Premium Support)
|
|
72
77
|
*/
|
|
73
|
-
|
|
78
|
+
name: string;
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
|
-
*
|
|
81
|
+
* Optional custom ID for the entitlement. If not provided, one will be generated.
|
|
77
82
|
*/
|
|
78
|
-
|
|
83
|
+
id?: string;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
export interface EntitlementUpdateParams {
|
|
82
87
|
/**
|
|
83
|
-
* Whether the entitlement is active
|
|
88
|
+
* Whether the entitlement is active. Deactivating removes it from access checks.
|
|
84
89
|
*/
|
|
85
90
|
active?: boolean;
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
|
-
*
|
|
93
|
+
* Display name for the entitlement
|
|
89
94
|
*/
|
|
90
95
|
name?: string;
|
|
91
96
|
}
|
|
@@ -94,12 +99,7 @@ export interface EntitlementListParams extends CursorIDPageParams {
|
|
|
94
99
|
/**
|
|
95
100
|
* Filter by archived status
|
|
96
101
|
*/
|
|
97
|
-
archived?:
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Filter by lookup key
|
|
101
|
-
*/
|
|
102
|
-
lookup_key?: string;
|
|
102
|
+
archived?: 'true' | 'false';
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export declare namespace Entitlements {
|
|
@@ -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';
|