order3000 0.12.1 → 0.13.1
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/dist/client.cjs +83 -1
- package/dist/client.d.cts +107 -5
- package/dist/client.d.mts +107 -5
- package/dist/client.mjs +83 -1
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
|
@@ -263,6 +263,17 @@ class MenusResource extends BaseResource {
|
|
|
263
263
|
async getBundles(menuIdOrAccessor) {
|
|
264
264
|
return this.request("GET", `/${menuIdOrAccessor}/bundles`);
|
|
265
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Get all active subscriptions for a menu
|
|
268
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
269
|
+
* @returns Array of menu subscriptions with posters
|
|
270
|
+
*/
|
|
271
|
+
async getSubscriptions(menuIdOrAccessor) {
|
|
272
|
+
return this.request(
|
|
273
|
+
"GET",
|
|
274
|
+
`/${menuIdOrAccessor}/subscriptions`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
266
277
|
buildQueryString(options) {
|
|
267
278
|
if (!options?.expand?.length) return "";
|
|
268
279
|
return `?expand=${options.expand.join(",")}`;
|
|
@@ -283,7 +294,9 @@ class OrdersResource extends BaseResource {
|
|
|
283
294
|
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
284
295
|
*/
|
|
285
296
|
async place(order) {
|
|
286
|
-
|
|
297
|
+
const { fulfillmentAt, ...rest } = order;
|
|
298
|
+
const fulfillmentTime = fulfillmentAt ? `${String(fulfillmentAt.getHours()).padStart(2, "0")}:${String(fulfillmentAt.getMinutes()).padStart(2, "0")}` : void 0;
|
|
299
|
+
return this.request("POST", "", { ...rest, fulfillmentTime });
|
|
287
300
|
}
|
|
288
301
|
async get(orderId) {
|
|
289
302
|
return this.request("GET", `/${orderId}`);
|
|
@@ -336,6 +349,70 @@ class ReservationsResource extends BaseResource {
|
|
|
336
349
|
}
|
|
337
350
|
}
|
|
338
351
|
|
|
352
|
+
class SubscriptionsResource extends BaseResource {
|
|
353
|
+
constructor(tokenManager, baseUrl) {
|
|
354
|
+
super(tokenManager, baseUrl, "/subscriptions");
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Get a subscription by ID
|
|
358
|
+
* @param id - The subscription UUID
|
|
359
|
+
* @returns The subscription with posters
|
|
360
|
+
*/
|
|
361
|
+
async get(id) {
|
|
362
|
+
return this.request("GET", `/${id}`);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Get a subscription by accessor
|
|
366
|
+
* @param accessor - The subscription accessor (slug)
|
|
367
|
+
* @returns The subscription with posters
|
|
368
|
+
*/
|
|
369
|
+
async getByAccessor(accessor) {
|
|
370
|
+
return this.request("GET", `/${accessor}`);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Subscribe a customer to a subscription plan via Stripe Checkout
|
|
374
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
375
|
+
* @param request - Subscribe request with email and redirect URLs
|
|
376
|
+
* @returns Stripe Checkout URL and session ID
|
|
377
|
+
*/
|
|
378
|
+
async subscribe(subscriptionIdOrAccessor, request) {
|
|
379
|
+
return this.request(
|
|
380
|
+
"POST",
|
|
381
|
+
`/${subscriptionIdOrAccessor}/subscribe`,
|
|
382
|
+
request
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Cancel a customer's subscription
|
|
387
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
388
|
+
* @param subscriberId - The subscriber record ID
|
|
389
|
+
*/
|
|
390
|
+
async cancel(subscriptionIdOrAccessor, subscriberId) {
|
|
391
|
+
await this.request(
|
|
392
|
+
"POST",
|
|
393
|
+
`/${subscriptionIdOrAccessor}/cancel`,
|
|
394
|
+
{ subscriberId }
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get credits for a subscriber
|
|
399
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
400
|
+
* @param subscriberId - The subscriber record ID
|
|
401
|
+
* @param status - Optional filter by credit status
|
|
402
|
+
* @returns Array of subscription credits
|
|
403
|
+
*/
|
|
404
|
+
async getCredits(subscriptionIdOrAccessor, subscriberId, status) {
|
|
405
|
+
const params = new URLSearchParams({ subscriberId });
|
|
406
|
+
if (status) {
|
|
407
|
+
params.set("status", status);
|
|
408
|
+
}
|
|
409
|
+
return this.request(
|
|
410
|
+
"GET",
|
|
411
|
+
`/${subscriptionIdOrAccessor}/credits?${params.toString()}`
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
339
416
|
var __defProp$2 = Object.defineProperty;
|
|
340
417
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
341
418
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -666,6 +743,7 @@ class Order3000Client {
|
|
|
666
743
|
__publicField(this, "orders");
|
|
667
744
|
__publicField(this, "paymentIntents");
|
|
668
745
|
__publicField(this, "reservations");
|
|
746
|
+
__publicField(this, "subscriptions");
|
|
669
747
|
__publicField(this, "realtime");
|
|
670
748
|
__publicField(this, "baseUrl");
|
|
671
749
|
__publicField(this, "tokenManager");
|
|
@@ -689,6 +767,10 @@ class Order3000Client {
|
|
|
689
767
|
this.tokenManager,
|
|
690
768
|
this.baseUrl
|
|
691
769
|
);
|
|
770
|
+
this.subscriptions = new SubscriptionsResource(
|
|
771
|
+
this.tokenManager,
|
|
772
|
+
this.baseUrl
|
|
773
|
+
);
|
|
692
774
|
this.realtime = new RealtimeManager(this.tokenManager, this.baseUrl);
|
|
693
775
|
}
|
|
694
776
|
}
|
package/dist/client.d.cts
CHANGED
|
@@ -47,7 +47,7 @@ interface components {
|
|
|
47
47
|
maxPartySize?: number | null;
|
|
48
48
|
isPublic?: boolean;
|
|
49
49
|
isRecurring?: boolean;
|
|
50
|
-
|
|
50
|
+
reservationsEnabled?: boolean;
|
|
51
51
|
bookingOpensAtDays?: number | null;
|
|
52
52
|
bookingClosesAtHours?: number | null;
|
|
53
53
|
isActive?: boolean;
|
|
@@ -91,7 +91,7 @@ interface components {
|
|
|
91
91
|
maxPartySize: number | null;
|
|
92
92
|
isPublic: boolean;
|
|
93
93
|
isRecurring: boolean;
|
|
94
|
-
|
|
94
|
+
reservationsEnabled: boolean;
|
|
95
95
|
bookingOpensAtDays: number | null;
|
|
96
96
|
bookingClosesAtHours: number | null;
|
|
97
97
|
isActive: boolean;
|
|
@@ -404,7 +404,7 @@ interface Event {
|
|
|
404
404
|
isPublic: boolean;
|
|
405
405
|
isRecurring: boolean;
|
|
406
406
|
isClosed: boolean;
|
|
407
|
-
|
|
407
|
+
reservationsEnabled: boolean;
|
|
408
408
|
bookingOpensAtDays: number | null;
|
|
409
409
|
bookingClosesAtHours: number | null;
|
|
410
410
|
isActive: boolean;
|
|
@@ -559,7 +559,7 @@ interface EventByAccessor {
|
|
|
559
559
|
maxPartySize: number | null;
|
|
560
560
|
isPublic: boolean;
|
|
561
561
|
isRecurring: boolean;
|
|
562
|
-
|
|
562
|
+
reservationsEnabled: boolean;
|
|
563
563
|
bookingOpensAtDays: number | null;
|
|
564
564
|
bookingClosesAtHours: number | null;
|
|
565
565
|
isActive: boolean;
|
|
@@ -671,6 +671,64 @@ interface ConfirmOrderResponse {
|
|
|
671
671
|
status: string;
|
|
672
672
|
publicId: string | null;
|
|
673
673
|
}
|
|
674
|
+
type SubscriptionPeriod = 'week' | 'month' | 'year';
|
|
675
|
+
type SubscriberStatus = 'active' | 'paused' | 'cancelled' | 'past_due' | 'trialing';
|
|
676
|
+
type SubscriptionCreditStatus = 'available' | 'redeemed' | 'expired';
|
|
677
|
+
interface MenuSubscriptionPoster {
|
|
678
|
+
id: string;
|
|
679
|
+
menuSubscriptionId: string;
|
|
680
|
+
storagePath: string;
|
|
681
|
+
/** Signed URL for accessing the poster image (1 hour expiry) */
|
|
682
|
+
signedUrl: string | null;
|
|
683
|
+
filename: string;
|
|
684
|
+
contentType: string;
|
|
685
|
+
sizeBytes: number;
|
|
686
|
+
sortIndex: string | null;
|
|
687
|
+
createdBy: string | null;
|
|
688
|
+
createdAt: string | null;
|
|
689
|
+
}
|
|
690
|
+
interface MenuSubscription {
|
|
691
|
+
id: string;
|
|
692
|
+
menuId: string;
|
|
693
|
+
accessor: string;
|
|
694
|
+
name: Record<string, string>;
|
|
695
|
+
shortName: Record<string, string> | null;
|
|
696
|
+
description: Record<string, string> | null;
|
|
697
|
+
scheduleId: string | null;
|
|
698
|
+
allowance: number;
|
|
699
|
+
billingPeriod: SubscriptionPeriod;
|
|
700
|
+
allowancePeriod: SubscriptionPeriod;
|
|
701
|
+
redeemableTagSets: string[][];
|
|
702
|
+
expiryInDays: number;
|
|
703
|
+
price: number;
|
|
704
|
+
currency: Currency;
|
|
705
|
+
isActive: boolean;
|
|
706
|
+
sortIndex: string | null;
|
|
707
|
+
posters: MenuSubscriptionPoster[];
|
|
708
|
+
}
|
|
709
|
+
interface SubscribeRequest {
|
|
710
|
+
email: string;
|
|
711
|
+
firstName?: string;
|
|
712
|
+
lastName?: string;
|
|
713
|
+
sessionId?: string;
|
|
714
|
+
successUrl: string;
|
|
715
|
+
cancelUrl: string;
|
|
716
|
+
}
|
|
717
|
+
interface SubscribeResponse {
|
|
718
|
+
checkoutUrl: string;
|
|
719
|
+
sessionId: string;
|
|
720
|
+
}
|
|
721
|
+
interface SubscriptionCredit {
|
|
722
|
+
id: string;
|
|
723
|
+
subscriberId: string;
|
|
724
|
+
periodStart: string;
|
|
725
|
+
periodEnd: string;
|
|
726
|
+
expiresAt: string;
|
|
727
|
+
status: SubscriptionCreditStatus;
|
|
728
|
+
redeemedAt: string | null;
|
|
729
|
+
orderId: string | null;
|
|
730
|
+
createdAt: string | null;
|
|
731
|
+
}
|
|
674
732
|
|
|
675
733
|
declare class BasketsResource extends BaseResource {
|
|
676
734
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
@@ -752,6 +810,12 @@ declare class MenusResource extends BaseResource {
|
|
|
752
810
|
* @returns Array of menu bundles
|
|
753
811
|
*/
|
|
754
812
|
getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
|
|
813
|
+
/**
|
|
814
|
+
* Get all active subscriptions for a menu
|
|
815
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
816
|
+
* @returns Array of menu subscriptions with posters
|
|
817
|
+
*/
|
|
818
|
+
getSubscriptions(menuIdOrAccessor: string): Promise<MenuSubscription[]>;
|
|
755
819
|
private buildQueryString;
|
|
756
820
|
}
|
|
757
821
|
|
|
@@ -804,6 +868,43 @@ declare class ReservationsResource extends BaseResource {
|
|
|
804
868
|
get(reservationId: string): Promise<MakeReservationResponse>;
|
|
805
869
|
}
|
|
806
870
|
|
|
871
|
+
declare class SubscriptionsResource extends BaseResource {
|
|
872
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
873
|
+
/**
|
|
874
|
+
* Get a subscription by ID
|
|
875
|
+
* @param id - The subscription UUID
|
|
876
|
+
* @returns The subscription with posters
|
|
877
|
+
*/
|
|
878
|
+
get(id: string): Promise<MenuSubscription>;
|
|
879
|
+
/**
|
|
880
|
+
* Get a subscription by accessor
|
|
881
|
+
* @param accessor - The subscription accessor (slug)
|
|
882
|
+
* @returns The subscription with posters
|
|
883
|
+
*/
|
|
884
|
+
getByAccessor(accessor: string): Promise<MenuSubscription>;
|
|
885
|
+
/**
|
|
886
|
+
* Subscribe a customer to a subscription plan via Stripe Checkout
|
|
887
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
888
|
+
* @param request - Subscribe request with email and redirect URLs
|
|
889
|
+
* @returns Stripe Checkout URL and session ID
|
|
890
|
+
*/
|
|
891
|
+
subscribe(subscriptionIdOrAccessor: string, request: SubscribeRequest): Promise<SubscribeResponse>;
|
|
892
|
+
/**
|
|
893
|
+
* Cancel a customer's subscription
|
|
894
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
895
|
+
* @param subscriberId - The subscriber record ID
|
|
896
|
+
*/
|
|
897
|
+
cancel(subscriptionIdOrAccessor: string, subscriberId: string): Promise<void>;
|
|
898
|
+
/**
|
|
899
|
+
* Get credits for a subscriber
|
|
900
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
901
|
+
* @param subscriberId - The subscriber record ID
|
|
902
|
+
* @param status - Optional filter by credit status
|
|
903
|
+
* @returns Array of subscription credits
|
|
904
|
+
*/
|
|
905
|
+
getCredits(subscriptionIdOrAccessor: string, subscriberId: string, status?: SubscriptionCreditStatus): Promise<SubscriptionCredit[]>;
|
|
906
|
+
}
|
|
907
|
+
|
|
807
908
|
type RealtimeEvent = 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
808
909
|
type RealtimeRow = {
|
|
809
910
|
[key: string]: any;
|
|
@@ -967,10 +1068,11 @@ declare class Order3000Client {
|
|
|
967
1068
|
orders: OrdersResource;
|
|
968
1069
|
paymentIntents: PaymentIntentsResource;
|
|
969
1070
|
reservations: ReservationsResource;
|
|
1071
|
+
subscriptions: SubscriptionsResource;
|
|
970
1072
|
realtime: RealtimeManager;
|
|
971
1073
|
private readonly baseUrl;
|
|
972
1074
|
private readonly tokenManager;
|
|
973
1075
|
constructor(config: Order3000ClientConfig);
|
|
974
1076
|
}
|
|
975
1077
|
|
|
976
|
-
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
|
1078
|
+
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, type MenuSubscription, type MenuSubscriptionPoster, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscribeRequest, type SubscribeResponse, type SubscriberStatus, type SubscriptionCredit, type SubscriptionCreditStatus, type SubscriptionOptions, type SubscriptionPeriod, type TimeSlot, type Unit, getScheduleInfo };
|
package/dist/client.d.mts
CHANGED
|
@@ -47,7 +47,7 @@ interface components {
|
|
|
47
47
|
maxPartySize?: number | null;
|
|
48
48
|
isPublic?: boolean;
|
|
49
49
|
isRecurring?: boolean;
|
|
50
|
-
|
|
50
|
+
reservationsEnabled?: boolean;
|
|
51
51
|
bookingOpensAtDays?: number | null;
|
|
52
52
|
bookingClosesAtHours?: number | null;
|
|
53
53
|
isActive?: boolean;
|
|
@@ -91,7 +91,7 @@ interface components {
|
|
|
91
91
|
maxPartySize: number | null;
|
|
92
92
|
isPublic: boolean;
|
|
93
93
|
isRecurring: boolean;
|
|
94
|
-
|
|
94
|
+
reservationsEnabled: boolean;
|
|
95
95
|
bookingOpensAtDays: number | null;
|
|
96
96
|
bookingClosesAtHours: number | null;
|
|
97
97
|
isActive: boolean;
|
|
@@ -404,7 +404,7 @@ interface Event {
|
|
|
404
404
|
isPublic: boolean;
|
|
405
405
|
isRecurring: boolean;
|
|
406
406
|
isClosed: boolean;
|
|
407
|
-
|
|
407
|
+
reservationsEnabled: boolean;
|
|
408
408
|
bookingOpensAtDays: number | null;
|
|
409
409
|
bookingClosesAtHours: number | null;
|
|
410
410
|
isActive: boolean;
|
|
@@ -559,7 +559,7 @@ interface EventByAccessor {
|
|
|
559
559
|
maxPartySize: number | null;
|
|
560
560
|
isPublic: boolean;
|
|
561
561
|
isRecurring: boolean;
|
|
562
|
-
|
|
562
|
+
reservationsEnabled: boolean;
|
|
563
563
|
bookingOpensAtDays: number | null;
|
|
564
564
|
bookingClosesAtHours: number | null;
|
|
565
565
|
isActive: boolean;
|
|
@@ -671,6 +671,64 @@ interface ConfirmOrderResponse {
|
|
|
671
671
|
status: string;
|
|
672
672
|
publicId: string | null;
|
|
673
673
|
}
|
|
674
|
+
type SubscriptionPeriod = 'week' | 'month' | 'year';
|
|
675
|
+
type SubscriberStatus = 'active' | 'paused' | 'cancelled' | 'past_due' | 'trialing';
|
|
676
|
+
type SubscriptionCreditStatus = 'available' | 'redeemed' | 'expired';
|
|
677
|
+
interface MenuSubscriptionPoster {
|
|
678
|
+
id: string;
|
|
679
|
+
menuSubscriptionId: string;
|
|
680
|
+
storagePath: string;
|
|
681
|
+
/** Signed URL for accessing the poster image (1 hour expiry) */
|
|
682
|
+
signedUrl: string | null;
|
|
683
|
+
filename: string;
|
|
684
|
+
contentType: string;
|
|
685
|
+
sizeBytes: number;
|
|
686
|
+
sortIndex: string | null;
|
|
687
|
+
createdBy: string | null;
|
|
688
|
+
createdAt: string | null;
|
|
689
|
+
}
|
|
690
|
+
interface MenuSubscription {
|
|
691
|
+
id: string;
|
|
692
|
+
menuId: string;
|
|
693
|
+
accessor: string;
|
|
694
|
+
name: Record<string, string>;
|
|
695
|
+
shortName: Record<string, string> | null;
|
|
696
|
+
description: Record<string, string> | null;
|
|
697
|
+
scheduleId: string | null;
|
|
698
|
+
allowance: number;
|
|
699
|
+
billingPeriod: SubscriptionPeriod;
|
|
700
|
+
allowancePeriod: SubscriptionPeriod;
|
|
701
|
+
redeemableTagSets: string[][];
|
|
702
|
+
expiryInDays: number;
|
|
703
|
+
price: number;
|
|
704
|
+
currency: Currency;
|
|
705
|
+
isActive: boolean;
|
|
706
|
+
sortIndex: string | null;
|
|
707
|
+
posters: MenuSubscriptionPoster[];
|
|
708
|
+
}
|
|
709
|
+
interface SubscribeRequest {
|
|
710
|
+
email: string;
|
|
711
|
+
firstName?: string;
|
|
712
|
+
lastName?: string;
|
|
713
|
+
sessionId?: string;
|
|
714
|
+
successUrl: string;
|
|
715
|
+
cancelUrl: string;
|
|
716
|
+
}
|
|
717
|
+
interface SubscribeResponse {
|
|
718
|
+
checkoutUrl: string;
|
|
719
|
+
sessionId: string;
|
|
720
|
+
}
|
|
721
|
+
interface SubscriptionCredit {
|
|
722
|
+
id: string;
|
|
723
|
+
subscriberId: string;
|
|
724
|
+
periodStart: string;
|
|
725
|
+
periodEnd: string;
|
|
726
|
+
expiresAt: string;
|
|
727
|
+
status: SubscriptionCreditStatus;
|
|
728
|
+
redeemedAt: string | null;
|
|
729
|
+
orderId: string | null;
|
|
730
|
+
createdAt: string | null;
|
|
731
|
+
}
|
|
674
732
|
|
|
675
733
|
declare class BasketsResource extends BaseResource {
|
|
676
734
|
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
@@ -752,6 +810,12 @@ declare class MenusResource extends BaseResource {
|
|
|
752
810
|
* @returns Array of menu bundles
|
|
753
811
|
*/
|
|
754
812
|
getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
|
|
813
|
+
/**
|
|
814
|
+
* Get all active subscriptions for a menu
|
|
815
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
816
|
+
* @returns Array of menu subscriptions with posters
|
|
817
|
+
*/
|
|
818
|
+
getSubscriptions(menuIdOrAccessor: string): Promise<MenuSubscription[]>;
|
|
755
819
|
private buildQueryString;
|
|
756
820
|
}
|
|
757
821
|
|
|
@@ -804,6 +868,43 @@ declare class ReservationsResource extends BaseResource {
|
|
|
804
868
|
get(reservationId: string): Promise<MakeReservationResponse>;
|
|
805
869
|
}
|
|
806
870
|
|
|
871
|
+
declare class SubscriptionsResource extends BaseResource {
|
|
872
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
873
|
+
/**
|
|
874
|
+
* Get a subscription by ID
|
|
875
|
+
* @param id - The subscription UUID
|
|
876
|
+
* @returns The subscription with posters
|
|
877
|
+
*/
|
|
878
|
+
get(id: string): Promise<MenuSubscription>;
|
|
879
|
+
/**
|
|
880
|
+
* Get a subscription by accessor
|
|
881
|
+
* @param accessor - The subscription accessor (slug)
|
|
882
|
+
* @returns The subscription with posters
|
|
883
|
+
*/
|
|
884
|
+
getByAccessor(accessor: string): Promise<MenuSubscription>;
|
|
885
|
+
/**
|
|
886
|
+
* Subscribe a customer to a subscription plan via Stripe Checkout
|
|
887
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
888
|
+
* @param request - Subscribe request with email and redirect URLs
|
|
889
|
+
* @returns Stripe Checkout URL and session ID
|
|
890
|
+
*/
|
|
891
|
+
subscribe(subscriptionIdOrAccessor: string, request: SubscribeRequest): Promise<SubscribeResponse>;
|
|
892
|
+
/**
|
|
893
|
+
* Cancel a customer's subscription
|
|
894
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
895
|
+
* @param subscriberId - The subscriber record ID
|
|
896
|
+
*/
|
|
897
|
+
cancel(subscriptionIdOrAccessor: string, subscriberId: string): Promise<void>;
|
|
898
|
+
/**
|
|
899
|
+
* Get credits for a subscriber
|
|
900
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
901
|
+
* @param subscriberId - The subscriber record ID
|
|
902
|
+
* @param status - Optional filter by credit status
|
|
903
|
+
* @returns Array of subscription credits
|
|
904
|
+
*/
|
|
905
|
+
getCredits(subscriptionIdOrAccessor: string, subscriberId: string, status?: SubscriptionCreditStatus): Promise<SubscriptionCredit[]>;
|
|
906
|
+
}
|
|
907
|
+
|
|
807
908
|
type RealtimeEvent = 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
808
909
|
type RealtimeRow = {
|
|
809
910
|
[key: string]: any;
|
|
@@ -967,10 +1068,11 @@ declare class Order3000Client {
|
|
|
967
1068
|
orders: OrdersResource;
|
|
968
1069
|
paymentIntents: PaymentIntentsResource;
|
|
969
1070
|
reservations: ReservationsResource;
|
|
1071
|
+
subscriptions: SubscriptionsResource;
|
|
970
1072
|
realtime: RealtimeManager;
|
|
971
1073
|
private readonly baseUrl;
|
|
972
1074
|
private readonly tokenManager;
|
|
973
1075
|
constructor(config: Order3000ClientConfig);
|
|
974
1076
|
}
|
|
975
1077
|
|
|
976
|
-
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscriptionOptions, type TimeSlot, type Unit, getScheduleInfo };
|
|
1078
|
+
export { type AddToBasketRequest, type AddToBasketResponse, type Basket, type BasketItem, type BasketItemMenuItemRef, type BasketItemMetadata, type BasketStatus, type ConfirmOrderRequest, type ConfirmOrderResponse, type CreatePaymentIntentRequest, type CreatePaymentIntentResponse, type CropArea, type Currency, type DayOfWeek, type Event, type EventByAccessor, type EventMenu, type EventPoster, type EventRow, type GetEventOptions, type GetMenuOptions, type ListEventsOptions, type ListEventsResponse, type Menu, type MenuAsset, type MenuBeverage, type MenuBundle, type MenuBundleDeposit, type MenuDish, type MenuItem, type MenuItemRow, type MenuItemType, type MenuSubscription, type MenuSubscriptionPoster, Order3000Client, type Order3000ClientConfig, type OrderFulfillmentType, type PlaceOrderRequest, type Promotion, type RealtimeConfig, type RealtimeEvent, type RealtimeSubscription, type RemoveFromBasketResponse, type Schedule, type ScheduleInfo, type ScheduleOverride, type ScheduleOverrideRow, type ScheduleRow, type ScheduleTimeSlot, type ScheduleWithTimeSlots, type SubscribeRequest, type SubscribeResponse, type SubscriberStatus, type SubscriptionCredit, type SubscriptionCreditStatus, type SubscriptionOptions, type SubscriptionPeriod, type TimeSlot, type Unit, getScheduleInfo };
|
package/dist/client.mjs
CHANGED
|
@@ -261,6 +261,17 @@ class MenusResource extends BaseResource {
|
|
|
261
261
|
async getBundles(menuIdOrAccessor) {
|
|
262
262
|
return this.request("GET", `/${menuIdOrAccessor}/bundles`);
|
|
263
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Get all active subscriptions for a menu
|
|
266
|
+
* @param menuIdOrAccessor - The menu UUID or accessor (slug)
|
|
267
|
+
* @returns Array of menu subscriptions with posters
|
|
268
|
+
*/
|
|
269
|
+
async getSubscriptions(menuIdOrAccessor) {
|
|
270
|
+
return this.request(
|
|
271
|
+
"GET",
|
|
272
|
+
`/${menuIdOrAccessor}/subscriptions`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
264
275
|
buildQueryString(options) {
|
|
265
276
|
if (!options?.expand?.length) return "";
|
|
266
277
|
return `?expand=${options.expand.join(",")}`;
|
|
@@ -281,7 +292,9 @@ class OrdersResource extends BaseResource {
|
|
|
281
292
|
* SDK callers cannot provide these values - they're implicit from the basket contents.
|
|
282
293
|
*/
|
|
283
294
|
async place(order) {
|
|
284
|
-
|
|
295
|
+
const { fulfillmentAt, ...rest } = order;
|
|
296
|
+
const fulfillmentTime = fulfillmentAt ? `${String(fulfillmentAt.getHours()).padStart(2, "0")}:${String(fulfillmentAt.getMinutes()).padStart(2, "0")}` : void 0;
|
|
297
|
+
return this.request("POST", "", { ...rest, fulfillmentTime });
|
|
285
298
|
}
|
|
286
299
|
async get(orderId) {
|
|
287
300
|
return this.request("GET", `/${orderId}`);
|
|
@@ -334,6 +347,70 @@ class ReservationsResource extends BaseResource {
|
|
|
334
347
|
}
|
|
335
348
|
}
|
|
336
349
|
|
|
350
|
+
class SubscriptionsResource extends BaseResource {
|
|
351
|
+
constructor(tokenManager, baseUrl) {
|
|
352
|
+
super(tokenManager, baseUrl, "/subscriptions");
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get a subscription by ID
|
|
356
|
+
* @param id - The subscription UUID
|
|
357
|
+
* @returns The subscription with posters
|
|
358
|
+
*/
|
|
359
|
+
async get(id) {
|
|
360
|
+
return this.request("GET", `/${id}`);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get a subscription by accessor
|
|
364
|
+
* @param accessor - The subscription accessor (slug)
|
|
365
|
+
* @returns The subscription with posters
|
|
366
|
+
*/
|
|
367
|
+
async getByAccessor(accessor) {
|
|
368
|
+
return this.request("GET", `/${accessor}`);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Subscribe a customer to a subscription plan via Stripe Checkout
|
|
372
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
373
|
+
* @param request - Subscribe request with email and redirect URLs
|
|
374
|
+
* @returns Stripe Checkout URL and session ID
|
|
375
|
+
*/
|
|
376
|
+
async subscribe(subscriptionIdOrAccessor, request) {
|
|
377
|
+
return this.request(
|
|
378
|
+
"POST",
|
|
379
|
+
`/${subscriptionIdOrAccessor}/subscribe`,
|
|
380
|
+
request
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Cancel a customer's subscription
|
|
385
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
386
|
+
* @param subscriberId - The subscriber record ID
|
|
387
|
+
*/
|
|
388
|
+
async cancel(subscriptionIdOrAccessor, subscriberId) {
|
|
389
|
+
await this.request(
|
|
390
|
+
"POST",
|
|
391
|
+
`/${subscriptionIdOrAccessor}/cancel`,
|
|
392
|
+
{ subscriberId }
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Get credits for a subscriber
|
|
397
|
+
* @param subscriptionIdOrAccessor - The subscription UUID or accessor
|
|
398
|
+
* @param subscriberId - The subscriber record ID
|
|
399
|
+
* @param status - Optional filter by credit status
|
|
400
|
+
* @returns Array of subscription credits
|
|
401
|
+
*/
|
|
402
|
+
async getCredits(subscriptionIdOrAccessor, subscriberId, status) {
|
|
403
|
+
const params = new URLSearchParams({ subscriberId });
|
|
404
|
+
if (status) {
|
|
405
|
+
params.set("status", status);
|
|
406
|
+
}
|
|
407
|
+
return this.request(
|
|
408
|
+
"GET",
|
|
409
|
+
`/${subscriptionIdOrAccessor}/credits?${params.toString()}`
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
337
414
|
var __defProp$2 = Object.defineProperty;
|
|
338
415
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
339
416
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -664,6 +741,7 @@ class Order3000Client {
|
|
|
664
741
|
__publicField(this, "orders");
|
|
665
742
|
__publicField(this, "paymentIntents");
|
|
666
743
|
__publicField(this, "reservations");
|
|
744
|
+
__publicField(this, "subscriptions");
|
|
667
745
|
__publicField(this, "realtime");
|
|
668
746
|
__publicField(this, "baseUrl");
|
|
669
747
|
__publicField(this, "tokenManager");
|
|
@@ -687,6 +765,10 @@ class Order3000Client {
|
|
|
687
765
|
this.tokenManager,
|
|
688
766
|
this.baseUrl
|
|
689
767
|
);
|
|
768
|
+
this.subscriptions = new SubscriptionsResource(
|
|
769
|
+
this.tokenManager,
|
|
770
|
+
this.baseUrl
|
|
771
|
+
);
|
|
690
772
|
this.realtime = new RealtimeManager(this.tokenManager, this.baseUrl);
|
|
691
773
|
}
|
|
692
774
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "order3000",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "order3000 node.js sdk",
|
|
5
5
|
"main": "./dist/client.cjs",
|
|
6
6
|
"module": "./dist/client.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"tsx": "^4.19.2",
|
|
32
32
|
"typescript": "^5.9.3",
|
|
33
33
|
"@kolaveri/prettier-config": "1.0.6",
|
|
34
|
-
"@kolaveri/eslint-config": "1.4.
|
|
34
|
+
"@kolaveri/eslint-config": "1.4.1",
|
|
35
35
|
"@kolaveri/tsconfig": "1.0.1"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|