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