INNER CODE UNIT · TypeScript
found
rowboatlabs/rowboat · apps/harbor/packages/server/src/connectors/cal/index.ts:80
const found = types.find((t) => t.slug.toLowerCase() === slug.toLowerCase());
if (!found) throw new UsageError(`There's no event type "${slug}". Yours: ${types.map((t) => t.slug).join(', ') || 'none'}.`);
return found;
}
async slots(eventTypeId: number, start: string, end: string, timeZone: string): Promise<Record<string, { start: string }[]>> {
const q = new URLSearchParams({ eventTypeId: String(eventTypeId), start, end, timeZone });
return ((await this.call(`/slots?${q}`, VERSIONS.slots)) as Record<string, { start: string }[]> | undefined) ?? {};
}
async book(input: { eventTypeId: number; start: string; attendee: { name: string; email: string; timeZone: string } }): Promise<Booking> {
return (await this.call('/bookings', VERSIONS.createBooking, { method: 'POST', body: JSON.stringify(input) })) as Booking;
}
async cancel(uid: string, reason?: string): Promise<void> {
await this.call(`/bookings/${encodeURIComponent(uid)}/cancel`, VERSIONS.cancel, {
method: 'POST',
body: JSON.stringify(reason ? { cancellationReason: reason } : {}),