Awesomate docs v0.27.0

Reference

Bookings client

createBookingsClient() and every method on it: what can be booked and when, booking, and the customer's own link.

The client for a business's own booking page, for visitors who are not signed in. It uses the booking key from Contacts, Bookings, which is public and works only on the sites it lists. Generated from the SDK's own code.

createBookingsClient()

The client for a business's own booking page. Use the booking key from Contacts, Bookings, On your website; it works on every plan, from the sites the key lists.

createBookingsClient(options: BookingsClientOptions): AwesomateBookingsClient
Parameter Type
options BookingsClientOptions

Example

import { createBookingsClient } from '@awesomate/sdk';

const bookings = createBookingsClient({ key: 'bk_your_booking_key' });
const { services } = await bookings.services();
const times = await bookings.openTimes(services[0].key);

What can be booked

services()

The business's name and what it offers to book.

bookings.services(): Promise<{ business: string; services: BookableService[] }>

openTimes()

The times a service can be booked, soonest first, from now for two weeks unless told otherwise (at most 62 days at once). Times are UTC; show them in the calendar's own zone.

bookings.openTimes(
  service: string,
  options?: { calendar?: string; from?: string | Date; seats?: number; to?: string | Date },
): Promise<OpenTime[]>
Parameter Type
service string
options (optional) { calendar?: string; from?: string | Date; seats?: number; to?: string | Date }

Booking

book()

Book a time for a visitor. They get an email with an invite and a link to change or cancel; the business gets a notice. A refusal has code conflict and field saying why:

  • not_open, slot_taken, too_many_seats, session_full, day_full: the time is not free (taken since you listed it, or not enough places left): list the times again;
  • too_many_open: this email already has three bookings coming up;
  • monthly_limit: the business has taken its plan's online bookings for the month.

Show personMessage to the visitor for the last two.

bookings.book(request: BookingRequest): Promise<BookingResult>
Parameter Type
request BookingRequest

booking()

One booking, from the token in its manage link (manageTokenFrom()), with how the business looks so the page can match it.

bookings.booking(
  manageToken: string,
): Promise<{ booking: ManagedBooking; business: string; look: BookingPageLook }>
Parameter Type
manageToken string

openTimesToMove()

The times a booking could move to, leaving its own time out.

bookings.openTimesToMove(
  manageToken: string,
  options?: { from?: string | Date; to?: string | Date },
): Promise<OpenTime[]>
Parameter Type
manageToken string
options (optional) { from?: string | Date; to?: string | Date }

move()

Move a booking to a time from openTimesToMove(). Refused with code conflict and field too_late once changes have closed, or not_open (or another of book()'s reasons) when the time is no longer free.

bookings.move(manageToken: string, startsAt: string): Promise<{ endsAt: string; startsAt: string }>
Parameter Type
manageToken string
startsAt string

cancel()

Cancel a booking from its manage link. A second cancel answers cancelled: false. Once changes have closed (canCancel false) it is refused with code conflict, field too_late.

bookings.cancel(manageToken: string, reason?: string): Promise<{ cancelled: boolean }>
Parameter Type
manageToken string
reason (optional) string