import { Type } from 'class-transformer'; export type TokenType = 'bearer'; export interface IToastOauthToken { // added by library expiry_at: Date; // an encoded string that contains an authentication token. // You can present this string when you make requests to other, secure Toast API resources. readonly access_token: string; // the number of seconds that the authentication token is valid. // For example, an authentication token might be valid for 3600 seconds after the user management API issues it. readonly expires_in: number; // an identifier for the authentication token. You do not need to use the information in this field. jti: string; // the name of your organization. readonly namingAuthority: string; // the globally unique identifier (GUID) of the top-level unit in your restaurant chain. // For example, this identifier might be for the parent unit for multiple restaurants, or for a single, independent restaurant. readonly rsGuid: string; // a space-delimited list of Toast APIs that will accept the authentication token. // The user management API does not return a complete list of the Toast APIs that your client is authorized to use. // You can present an authentication token to any Toast API. readonly scope: string; // the Oauth 2 authentication scheme used for the authentication token. // Toast API authentication uses the bearer authentication scheme. readonly token_type: TokenType; } export interface IToastOauthPartnerToken { // added by library expiry_at: Date; // an encoded string that contains an authentication token. // You can present this string when you make requests to other, secure Toast API resources. readonly access_token: string; // the number of seconds that the authentication token is valid. // For example, an authentication token might be valid for 3600 seconds after the user management API issues it. readonly expires_in: number; // an identifier for the authentication token. You do not need to use the information in this field. jti: string; // the name of your organization. readonly namingAuthority: string; readonly partnerGuid: string; // a space-delimited list of Toast APIs that will accept the authentication token. // The user management API does not return a complete list of the Toast APIs that your client is authorized to use. // You can present an authentication token to any Toast API. readonly scope: string; // the Oauth 2 authentication scheme used for the authentication token. // Toast API authentication uses the bearer authentication scheme. readonly token_type: TokenType; } export interface IToastAuthorizationConfig { clientId: string; clientSecret: string; } /** * A wrapper object with fields that allow reference to a Toast entity by Toast GUID or a partner's identifier. */ export class ToastReference { readonly guid?: string; entityType?: ToastEntityTypeEnum; constructor() { this.entityType = this.constructor.name.replace('ToastFile', '').replace('Toast', '') as ToastEntityTypeEnum; } } export class ToastRequiredReference extends ToastReference { guid: string; } export class ToastExternalReference extends ToastReference { externalId?: string; } export const enum ToastPricingModeEnum { INCLUDED = 'INCLUDED', ADJUSTS_PRICE = 'ADJUSTS_PRICE', } export const enum ToastEntityTypeEnum { MENU = 'Menu', MENU_ITEM = 'MenuItem', MENU_GROUP = 'MenuGroup', MENU_OPTION_GROUP = 'MenuOptionGroup', } export const enum ToastDiningBehaviorEnum { DINE_IN = 'DINE_IN', TAKE_OUT = 'TAKE_OUT', DELIVERY = 'DELIVERY', } export class ToastDiningOption extends ToastRequiredReference { name: string; behavior: ToastDiningBehaviorEnum; } export const enum ToastPaymentTypeEnum { CASH = 'CASH', CREDIT = 'CREDIT', // GIFTCARD = 'GIFTCARD', // HOUSE_ACCOUNT = 'HOUSE_ACCOUNT', // REWARDCARD = 'REWARDCARD', // LEVELUP = 'LEVELUP', OTHER = 'OTHER', // UNDETERMINED = 'UNDETERMINED', } export const enum ToastChargeType { FIXED = 'fixed', PERCENT = 'percent', OPEN = 'open', } export const enum ToastSelectionType { NONE = 'NONE', OPEN_ITEM = 'OPEN_ITEM', SPECIAL_REQUEST = 'SPECIAL_REQUEST', PORTION = 'PORTION', } /** * A Selection object can represent either a primary item (i.e. ToastCheck.selections) or a modifier (ToastSelection.modifiers) selection. * All selections must have valid item and itemGroup fields. Quantity defaults to 1. * Specify a modifier selection by adding it to the modifiers list of another selection. * For each modifier selection, its optionGroup field must be set correctly, because a ToastMenuItem can be included in multiple MenuOptionGroups, potentially with different prices or sizing. */ export class ToastSelection extends ToastReference { @Type(() => ToastReference) item: ToastReference; @Type(() => ToastReference) itemGroup: ToastReference; @Type(() => ToastSelection) modifiers: ToastSelection[] = []; /** A reference to the modifier group from which the menu item was selected. Only applies if this is a modifier selection. */ @Type(() => ToastRequiredReference) optionGroup: ToastRequiredReference; quantity: number; displayName?: string; selectionType: ToastSelectionType = ToastSelectionType.NONE; } export class ToastCustomer extends ToastReference { firstName: string; lastName: string; email: string; phone: string; } export class ToastPayment extends ToastReference { /** The date at which the payment was made */ // paidDate?: Date; /** * The payment method. * When POSTing, only OTHER is supported. All other types are response only. * For cash payments, please create an external cash payment type in Other Payment Options. */ type: ToastPaymentTypeEnum; /** The amount of this payment, excluding tips. */ amount: number; /** The amount tipped on this payment. */ tipAmount: number; /** * Required when the payment type is `OTHER`. * A reference to an alternative payment method configured by the restaurant. */ @Type(() => ToastRequiredReference) otherPayment: ToastRequiredReference; } /** * A discount applied to a check or item. * The Toast POS system calculates service charges before applying discounts. * The system calculates tax after applying discounts. * In a POST request, the type of the discount must be fixed amount or fixed percentage, and the discount must be applied to a check. */ export class ToastAppliedDiscount extends ToastRequiredReference { /** The discount amount in USD. This amount will be subtracted from the check or item. */ discountAmount?: number; /** A GUID reference to the discount configured for the restaurant. */ discount: ToastRequiredReference; /** The promo code that was applied for this discount. */ appliedPromoCode?: string; } export class ToastAppliedServiceCharge extends ToastExternalReference { guid: typeof ToastRequiredReference.prototype.guid; /** The final applied amount excluding tax. This is required if the amountType is OPEN */ chargeAmount?: number; /** * A reference to the restaurant-configured service charge. * If a service charge is taxable, the tax amount will be applied to the check. */ serviceCharge: ToastExternalReference; /** Derived from serviceCharge - the configured human readable label for the service charge. Response only */ readonly chargeType: ToastChargeType; /** Derived from serviceCharge - the configured human readable label for the service charge. Response only */ readonly name: string; /** Derived from serviceCharge - whether this service charge is a delivery charge. Response only. */ readonly delivery: boolean; /** Derived from serviceCharge - whether this service charge is a gratuity. Can be used to derive required tip amount on the check. Response only. */ readonly gratuity: boolean; /** Derived from serviceCharge - whether this service charge is taxable. Response only. */ readonly taxable: boolean; /** Derived from serviceCharge - the taxes applied to the service */ // appliedTaxes?: ToastAppliedTaxRate[]; } export class ToastCheck extends ToastReference { /** * Generally starts at one each day and counts up. * Toast will fill this in if it is not specified when POSTing. * Not guaranteed to be unique. * * Goparrot set here our order.orderNumber */ displayNumber: string; @Type(() => ToastCustomer) customer: ToastCustomer; @Type(() => ToastSelection) selections: ToastSelection[]; /** The discounts applied to this check. In a `POST` request, only one `appliedDiscount` is allowed per check. */ @Type(() => ToastAppliedDiscount) appliedDiscounts: ToastAppliedDiscount[] = []; /** Payments made on this check */ @Type(() => ToastPayment) payments: ToastPayment[] = []; /** Any restaurant-configured service charges that applied to this check. */ @Type(() => ToastAppliedServiceCharge) appliedServiceCharges?: ToastAppliedServiceCharge[]; /** The dollar amount due on this check in USD, after discounts but before tax. Response only. */ readonly amount?: number; /** The computed tax amount in USD. Includes service charge and item level taxes. Response only. */ readonly taxAmount?: number; /** The total amount due on this check in USD, including discounts and taxes. Response only. */ readonly totalAmount?: number; } export interface IToastDelivery { address1: string; address2?: string; city: string; state: string; zipCode: string; latitude?: number; longitude?: number; notes?: string; } export class ToastDeliveryInfo implements IToastDelivery { address1: string; address2?: string; city: string; state: string; zipCode: string; latitude?: number; longitude?: number; notes?: string; // string($date-time) /** * The date and time that the delivery employee indicated that the order is delivered in the Toast POS. * Response only. * This value is only set when the dining option for the order is DELIVERY. * For other dining options, the value is null. */ deliveredDate?: Date; /** * The date and time that the restaurant indicated that the order was available for delivery and assigned to a delivery employee in the Toast POS. * This value is only set when the dining option for the order is DELIVERY. * For other dining options, the value is null. */ dispatchedDate?: Date; } export class ToastOrder extends ToastExternalReference { @Type(() => ToastReference) diningOption: ToastReference; @Type(() => ToastCheck) checks: ToastCheck[]; /** Required if the dining option behavior is DELIVERY */ @Type(() => ToastDeliveryInfo) deliveryInfo?: ToastDeliveryInfo; openedDate: string; // Date promisedDate?: string; // Date } export enum ToastYesNoEnum { YES = 'YES', NO = 'NO', } export enum ToastVisibilityEnum { ALL = 'ALL', POS_ONLY = 'POS_ONLY', NONE = 'NONE', } export class ToastMenu extends ToastRequiredReference { name: string; @Type(() => ToastRequiredReference) groups: ToastRequiredReference[] = []; visibility: ToastVisibilityEnum; orderableOnline: ToastYesNoEnum; } export class ToastMenuItem extends ToastRequiredReference { price?: number; inheritOptionGroups: boolean; visibility: ToastVisibilityEnum; orderableOnline: ToastYesNoEnum; name: string; calories: number | null; @Type(() => ToastRequiredReference) optionGroups: ToastRequiredReference[]; // ToastMenuOptionGroup } export class ToastMenuGroup extends ToastRequiredReference { inheritOptionGroups: boolean; visibility: ToastVisibilityEnum; orderableOnline: ToastYesNoEnum; name: string; @Type(() => ToastRequiredReference) parent?: ToastRequiredReference | null; @Type(() => ToastRequiredReference) menu: ToastRequiredReference; @Type(() => ToastRequiredReference) items?: ToastRequiredReference[]; @Type(() => ToastRequiredReference) subgroups?: ToastRequiredReference[]; // optionGroups: ToastRequiredReference[]; // ToastOptionGroup } export class ToastMenuOptionGroup extends ToastRequiredReference { name: string; @Type(() => ToastRequiredReference) private options: ToastRequiredReference[]; // ToastMenuItem[] | ToastMenuOptionGroup[]; minSelections?: number; maxSelections?: number; getOptions(): ToastRequiredReference[] { return Array.isArray(this.options) ? this.options : []; } } export class ToastAlternatePaymentType extends ToastExternalReference { name: string; } export class ToastRestaurant extends ToastRequiredReference {} export class ToastRestaurantInfo extends ToastRequiredReference { general: { name: string; locationName: string; locationCode: string; description: string; timeZone: string; closeoutHour: number; managementGroupGuid: string; }; // ... } export class ToastPartnerRestaurant { restaurantGuid: string; restaurantName: string; locationName: string; createdByEmailAddress?: string; externalGroupRef?: string; externalRestaurantRef?: string; modifiedDate: number; createdDate: number; }