@checkoutpage/sdk 0.1.32 → 0.1.34
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/README.md +138 -0
- package/dist/index.d.mts +6587 -2036
- package/dist/index.d.ts +6587 -2036
- package/dist/index.js +129 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -323,8 +323,10 @@ var CouponResource = class {
|
|
|
323
323
|
/**
|
|
324
324
|
* Update an existing coupon. Only the fields you supply are changed.
|
|
325
325
|
*
|
|
326
|
-
* `
|
|
327
|
-
*
|
|
326
|
+
* `rules` replaces every stored rule rather than merging; an empty list makes
|
|
327
|
+
* the coupon work on every checkout page and event. `pageIds` and
|
|
328
|
+
* `ticketTypeIds` are deprecated: they are accepted only without `rules`, and
|
|
329
|
+
* the API refuses them with a 400 when the coupon has rules they can't express.
|
|
328
330
|
*
|
|
329
331
|
* The discount itself (`code`, `amountOff`, `percentOff`, `currency`,
|
|
330
332
|
* `duration`) is fixed once the coupon is mirrored into Stripe. To change a
|
|
@@ -343,6 +345,24 @@ var CouponResource = class {
|
|
|
343
345
|
body: params
|
|
344
346
|
});
|
|
345
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Create a coupon. `rules` says where it works and what it discounts, one rule
|
|
350
|
+
* per checkout page or event; omit it for a coupon that discounts the whole
|
|
351
|
+
* order everywhere. `pageIds` and `ticketTypeIds` are deprecated in favour of
|
|
352
|
+
* `rules` and cannot be sent with it.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* await client.coupons.create({
|
|
356
|
+
* type: 'percent',
|
|
357
|
+
* label: 'Monthly plus workbook',
|
|
358
|
+
* code: 'BUNDLE20',
|
|
359
|
+
* percentOff: 20,
|
|
360
|
+
* duration: 'once',
|
|
361
|
+
* rules: [
|
|
362
|
+
* { pageId, appliesTo: 'pricesAndBumps', priceIds: [monthlyPriceId], bumpProductIds: [workbookId] },
|
|
363
|
+
* ],
|
|
364
|
+
* });
|
|
365
|
+
*/
|
|
346
366
|
async create(params) {
|
|
347
367
|
const body = {
|
|
348
368
|
label: params.label,
|
|
@@ -358,6 +378,9 @@ var CouponResource = class {
|
|
|
358
378
|
if (params.appliesToTicketFees !== void 0) {
|
|
359
379
|
body.appliesToTicketFees = params.appliesToTicketFees;
|
|
360
380
|
}
|
|
381
|
+
if (params.rules !== void 0) {
|
|
382
|
+
body.rules = params.rules;
|
|
383
|
+
}
|
|
361
384
|
if (params.pageIds !== void 0) {
|
|
362
385
|
body.pageIds = params.pageIds;
|
|
363
386
|
}
|
|
@@ -740,6 +763,14 @@ var TicketResource = class {
|
|
|
740
763
|
};
|
|
741
764
|
|
|
742
765
|
// src/resources/products/products.ts
|
|
766
|
+
var ORDER_BUMP_CARD_FIELDS = [
|
|
767
|
+
"shortDescription",
|
|
768
|
+
"callToActionText",
|
|
769
|
+
"headingText",
|
|
770
|
+
"features",
|
|
771
|
+
"calloutText",
|
|
772
|
+
"calloutIcon"
|
|
773
|
+
];
|
|
743
774
|
var ProductResource = class {
|
|
744
775
|
constructor(client) {
|
|
745
776
|
this.client = client;
|
|
@@ -758,6 +789,33 @@ var ProductResource = class {
|
|
|
758
789
|
query
|
|
759
790
|
});
|
|
760
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Creates an order bump product (`role: 'orderbump'`). Order bump products use
|
|
794
|
+
* a single one-time price; page products are created with their page.
|
|
795
|
+
*/
|
|
796
|
+
async create(params) {
|
|
797
|
+
return this.client.request({
|
|
798
|
+
method: "POST",
|
|
799
|
+
path: "/v1/products/",
|
|
800
|
+
body: params
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Deletes an order bump product that has never been bought. Pass
|
|
805
|
+
* `fromAllPages: true` to remove it from the pages offering it first.
|
|
806
|
+
*/
|
|
807
|
+
async delete(productId, options = {}) {
|
|
808
|
+
if (!productId) {
|
|
809
|
+
throw new Error("Product ID is required");
|
|
810
|
+
}
|
|
811
|
+
return this.client.request({
|
|
812
|
+
method: "DELETE",
|
|
813
|
+
path: `/v1/products/${productId}`,
|
|
814
|
+
query: {
|
|
815
|
+
fromAllPages: options.fromAllPages === void 0 ? void 0 : String(options.fromAllPages)
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
761
819
|
async get(productId) {
|
|
762
820
|
if (!productId) {
|
|
763
821
|
throw new Error("Product ID is required");
|
|
@@ -835,6 +893,11 @@ var ProductResource = class {
|
|
|
835
893
|
if (params.pricePicker !== void 0) {
|
|
836
894
|
body.pricePicker = params.pricePicker;
|
|
837
895
|
}
|
|
896
|
+
for (const field of ORDER_BUMP_CARD_FIELDS) {
|
|
897
|
+
if (params[field] !== void 0) {
|
|
898
|
+
body[field] = params[field];
|
|
899
|
+
}
|
|
900
|
+
}
|
|
838
901
|
return this.client.request({
|
|
839
902
|
method: "PATCH",
|
|
840
903
|
path: `/v1/products/${productId}`,
|
|
@@ -884,6 +947,66 @@ var FileResource = class {
|
|
|
884
947
|
}
|
|
885
948
|
};
|
|
886
949
|
|
|
950
|
+
// src/resources/order-bumps/order-bumps.ts
|
|
951
|
+
var OrderBumpsResource = class {
|
|
952
|
+
constructor(client, pageResource) {
|
|
953
|
+
this.client = client;
|
|
954
|
+
this.pageResource = pageResource;
|
|
955
|
+
}
|
|
956
|
+
basePath(pageId) {
|
|
957
|
+
if (!pageId) {
|
|
958
|
+
throw new Error("Page ID is required");
|
|
959
|
+
}
|
|
960
|
+
return `/v1/${this.pageResource}/${pageId}/order-bumps`;
|
|
961
|
+
}
|
|
962
|
+
/** Lists the order bumps on the page in display order, including unavailable ones. */
|
|
963
|
+
async list(pageId) {
|
|
964
|
+
return this.client.request({
|
|
965
|
+
method: "GET",
|
|
966
|
+
path: this.basePath(pageId)
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/** Offers an order bump product on the page. It is added last. */
|
|
970
|
+
async create(pageId, params) {
|
|
971
|
+
return this.client.request({
|
|
972
|
+
method: "POST",
|
|
973
|
+
path: this.basePath(pageId),
|
|
974
|
+
body: params
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
/** Updates how the order bump is offered on the page. `showHideLogic` is replaced whole. */
|
|
978
|
+
async update(pageId, productId, params) {
|
|
979
|
+
const path = this.basePath(pageId);
|
|
980
|
+
if (!productId) {
|
|
981
|
+
throw new Error("Product ID is required");
|
|
982
|
+
}
|
|
983
|
+
return this.client.request({
|
|
984
|
+
method: "PATCH",
|
|
985
|
+
path: `${path}/${productId}`,
|
|
986
|
+
body: params
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
/** Stops offering the order bump on the page. The product is kept. */
|
|
990
|
+
async delete(pageId, productId) {
|
|
991
|
+
const path = this.basePath(pageId);
|
|
992
|
+
if (!productId) {
|
|
993
|
+
throw new Error("Product ID is required");
|
|
994
|
+
}
|
|
995
|
+
return this.client.request({
|
|
996
|
+
method: "DELETE",
|
|
997
|
+
path: `${path}/${productId}`
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
/** Sets the display order. `productIds` must list every order bump on the page exactly once. */
|
|
1001
|
+
async reorder(pageId, params) {
|
|
1002
|
+
return this.client.request({
|
|
1003
|
+
method: "POST",
|
|
1004
|
+
path: `${this.basePath(pageId)}/reorder`,
|
|
1005
|
+
body: params
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
|
|
887
1010
|
// src/resources/checkout-pages/checkout-pages.ts
|
|
888
1011
|
var CheckoutPageFieldsResource = class {
|
|
889
1012
|
constructor(client) {
|
|
@@ -948,10 +1071,12 @@ var CheckoutPageFieldsResource = class {
|
|
|
948
1071
|
};
|
|
949
1072
|
var CheckoutPagesResource = class {
|
|
950
1073
|
fields;
|
|
1074
|
+
orderBumps;
|
|
951
1075
|
client;
|
|
952
1076
|
constructor(client) {
|
|
953
1077
|
this.client = client;
|
|
954
1078
|
this.fields = new CheckoutPageFieldsResource(client);
|
|
1079
|
+
this.orderBumps = new OrderBumpsResource(client, "checkout-pages");
|
|
955
1080
|
}
|
|
956
1081
|
async list(args = {}) {
|
|
957
1082
|
const query = {
|
|
@@ -1211,9 +1336,11 @@ var EventsResource = class {
|
|
|
1211
1336
|
this.client = client;
|
|
1212
1337
|
this.ticketGroups = new EventTicketGroupsResource(client);
|
|
1213
1338
|
this.fields = new EventFieldsResource(client);
|
|
1339
|
+
this.orderBumps = new OrderBumpsResource(client, "events");
|
|
1214
1340
|
}
|
|
1215
1341
|
ticketGroups;
|
|
1216
1342
|
fields;
|
|
1343
|
+
orderBumps;
|
|
1217
1344
|
async list(args = {}) {
|
|
1218
1345
|
const query = {
|
|
1219
1346
|
limit: args.limit?.toString(),
|