booking

package
v0.0.0-...-8d74fbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlreadyBookedError

type AlreadyBookedError struct {
	Desk string
	Slot Slot
	Err  error
}

func (AlreadyBookedError) Error

func (err AlreadyBookedError) Error() string

func (AlreadyBookedError) Unwrap

func (err AlreadyBookedError) Unwrap() error

type Booking

type Booking struct {
	ID   ID
	User string
	Desk string
	Slot Slot
}

type ID

type ID int

type Service

type Service struct {
	Store Store
}

func (Service) Book

func (svc Service) Book(ctx context.Context, user string, d string, slot Slot) (Booking, error)

Book attempts to create a booking for a user at a for a given time slot. It checks for any issues with the desk's status and for any booking conflicts before creating the booking entry in the store.

func (Service) Bookings

func (svc Service) Bookings(ctx context.Context, date time.Time) ([]Booking, error)

func (Service) CancelBooking

func (svc Service) CancelBooking(ctx context.Context, id ID, user string) error

func (Service) UserBookings

func (svc Service) UserBookings(ctx context.Context, user string) ([]Booking, error)

type Slot

type Slot struct {
	Start, End time.Time
}

type Store

type Store interface {
	GetDeskBookings(context.Context, string) ([]Booking, error)
	AddBooking(context.Context, Booking) error
	GetAllBookingsForDate(context.Context, time.Time) ([]Booking, error)
	GetFutureBookingsForUser(context.Context, string) ([]Booking, error)
	DeleteBooking(context.Context, ID) error
}

type UnbookableDeskError

type UnbookableDeskError struct {
	Desk   int
	Status int
}

func (UnbookableDeskError) Error

func (err UnbookableDeskError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL