@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,52 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../../../core/resource.mjs";
|
|
3
|
+
import * as EntitlementsAPI from "./entitlements.mjs";
|
|
4
|
+
import { Entitlements, } from "./entitlements.mjs";
|
|
5
|
+
import { CursorIDPage } from "../../../../core/pagination.mjs";
|
|
6
|
+
import { path } from "../../../../internal/utils/path.mjs";
|
|
7
|
+
export class Products extends APIResource {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.entitlements = new EntitlementsAPI.Entitlements(this._client);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new subscription product with a recurring price. Common examples
|
|
14
|
+
* include Free, Pro, Business, or Teams tiers. After creating a product, attach
|
|
15
|
+
* entitlements to define which features customers on this product can access.
|
|
16
|
+
*/
|
|
17
|
+
create(body, options) {
|
|
18
|
+
return this._client.post('/v1/pay/products', { body, ...options });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Updates an existing product. Use this to modify the product name, description,
|
|
22
|
+
* or active status. Pricing cannot be changed after creation—create a new product
|
|
23
|
+
* instead.
|
|
24
|
+
*/
|
|
25
|
+
update(productID, body = {}, options) {
|
|
26
|
+
return this._client.patch(path `/v1/pay/products/${productID}`, { body, ...options });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves a paginated list of subscription products. Products define the pricing
|
|
30
|
+
* and billing intervals for subscriptions. Each product can have entitlements
|
|
31
|
+
* attached that grant features to subscribed customers.
|
|
32
|
+
*/
|
|
33
|
+
list(query = {}, options) {
|
|
34
|
+
return this._client.getAPIList('/v1/pay/products', (CursorIDPage), { query, ...options });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Archives a product, preventing new subscriptions. Existing subscriptions remain
|
|
38
|
+
* active. Use this instead of deletion to preserve subscription history.
|
|
39
|
+
*/
|
|
40
|
+
archive(productID, options) {
|
|
41
|
+
return this._client.delete(path `/v1/pay/products/${productID}`, options);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves a product by ID. Returns the product object including pricing details
|
|
45
|
+
* and status.
|
|
46
|
+
*/
|
|
47
|
+
get(productID, options) {
|
|
48
|
+
return this._client.get(path `/v1/pay/products/${productID}`, options);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
Products.Entitlements = Entitlements;
|
|
52
|
+
//# sourceMappingURL=products.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.mjs","sourceRoot":"","sources":["../../../../src/resources/beta/pay/products/products.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,eAAe;OACpB,EAIL,YAAY,GAGb;OAEM,EAAE,YAAY,EAAwC;OAEtD,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,iBAAY,GAAiC,IAAI,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAmD9F,CAAC;IAjDC;;;;OAIG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,SAAiB,EACjB,OAA+C,EAAE,EACjD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA,oBAAoB,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAA,YAAqB,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnG,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,SAAiB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,oBAAoB,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,SAAiB,EAAE,OAAwB;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,oBAAoB,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;CACF;AAuID,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/pay/products.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/pay/products.ts"],"names":[],"mappings":""}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("../../../internal/tslib.js");
|
|
5
|
-
tslib_1.__exportStar(require("./
|
|
6
|
-
//# sourceMappingURL=
|
|
5
|
+
tslib_1.__exportStar(require("./products/index.js"), exports);
|
|
6
|
+
//# sourceMappingURL=products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.js","sourceRoot":"","sources":["../../../src/resources/beta/pay/products.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,8DAAiC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export * from "./
|
|
3
|
-
//# sourceMappingURL=
|
|
2
|
+
export * from "./products/index.mjs";
|
|
3
|
+
//# sourceMappingURL=products.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.mjs","sourceRoot":"","sources":["../../../src/resources/beta/pay/products.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.d.mts","sourceRoot":"","sources":["../../src/resources/beta/pay.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../src/resources/beta/pay.ts"],"names":[],"mappings":""}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("../../internal/tslib.js");
|
|
5
|
-
tslib_1.__exportStar(require("./
|
|
6
|
-
//# sourceMappingURL=
|
|
5
|
+
tslib_1.__exportStar(require("./pay/index.js"), exports);
|
|
6
|
+
//# sourceMappingURL=pay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.js","sourceRoot":"","sources":["../../src/resources/beta/pay.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,yDAA4B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export * from "./
|
|
3
|
-
//# sourceMappingURL=
|
|
2
|
+
export * from "./pay/index.mjs";
|
|
3
|
+
//# sourceMappingURL=pay.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.mjs","sourceRoot":"","sources":["../../src/resources/beta/pay.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
package/src/client.ts
CHANGED
|
@@ -32,13 +32,15 @@ import {
|
|
|
32
32
|
} from './internal/utils/log';
|
|
33
33
|
import { isEmptyObj } from './internal/utils/values';
|
|
34
34
|
|
|
35
|
+
export type ApiVersion = '2025-12-09';
|
|
36
|
+
|
|
35
37
|
export interface ClientOptions {
|
|
36
38
|
/**
|
|
37
39
|
* Defaults to process.env['HERCULES_API_KEY'].
|
|
38
40
|
*/
|
|
39
41
|
apiKey?: string | null | undefined;
|
|
40
42
|
|
|
41
|
-
apiVersion
|
|
43
|
+
apiVersion: ApiVersion;
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
@@ -114,7 +116,7 @@ export interface ClientOptions {
|
|
|
114
116
|
*/
|
|
115
117
|
export class Hercules {
|
|
116
118
|
apiKey: string | null;
|
|
117
|
-
apiVersion:
|
|
119
|
+
apiVersion: ApiVersion;
|
|
118
120
|
|
|
119
121
|
baseURL: string;
|
|
120
122
|
maxRetries: number;
|
|
@@ -144,9 +146,9 @@ export class Hercules {
|
|
|
144
146
|
constructor({
|
|
145
147
|
baseURL = readEnv('HERCULES_BASE_URL'),
|
|
146
148
|
apiKey = readEnv('HERCULES_API_KEY') ?? null,
|
|
147
|
-
apiVersion
|
|
149
|
+
apiVersion,
|
|
148
150
|
...opts
|
|
149
|
-
}: ClientOptions
|
|
151
|
+
}: ClientOptions & { apiVersion: ApiVersion }) {
|
|
150
152
|
const options: ClientOptions = {
|
|
151
153
|
apiKey,
|
|
152
154
|
apiVersion,
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
|
-
import * as
|
|
4
|
+
import * as PayAPI from './pay/pay';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from './
|
|
6
|
+
Pay,
|
|
7
|
+
PayCancelParams,
|
|
8
|
+
PayCancelResponse,
|
|
9
|
+
PayCheckParams,
|
|
10
|
+
PayCheckResponse,
|
|
11
|
+
PayCheckoutParams,
|
|
12
|
+
PayCheckoutResponse,
|
|
13
|
+
} from './pay/pay';
|
|
14
14
|
|
|
15
15
|
export class Beta extends APIResource {
|
|
16
|
-
|
|
16
|
+
pay: PayAPI.Pay = new PayAPI.Pay(this._client);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
Beta.
|
|
19
|
+
Beta.Pay = Pay;
|
|
20
20
|
|
|
21
21
|
export declare namespace Beta {
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
23
|
+
Pay as Pay,
|
|
24
|
+
type PayCancelResponse as PayCancelResponse,
|
|
25
|
+
type PayCheckResponse as PayCheckResponse,
|
|
26
|
+
type PayCheckoutResponse as PayCheckoutResponse,
|
|
27
|
+
type PayCancelParams as PayCancelParams,
|
|
28
|
+
type PayCheckParams as PayCheckParams,
|
|
29
|
+
type PayCheckoutParams as PayCheckoutParams,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
export { Beta } from './beta';
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
} from './
|
|
5
|
+
Pay,
|
|
6
|
+
type PayCancelResponse,
|
|
7
|
+
type PayCheckResponse,
|
|
8
|
+
type PayCheckoutResponse,
|
|
9
|
+
type PayCancelParams,
|
|
10
|
+
type PayCheckParams,
|
|
11
|
+
type PayCheckoutParams,
|
|
12
|
+
} from './pay/index';
|
|
@@ -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 entitlement
|
|
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
|
+
}
|