libcal

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthenticationRequired = &Error{
	Code: "libcal_authentication_required", Message: "LibCal needs a USC sign-in",
	Cause: &auth.SiteError{Site: auth.SiteLibCal, Err: auth.ErrCredentialsRequired},
}
View Source
var ErrBookingUnknown = &Error{Code: "libcal_booking_unknown", Message: "LibCal booking outcome is unknown; check the confirmation email, then release the checkout before booking again"}

Functions

func CancelCode added in v0.1.1

func CancelCode(link string) (string, error)

func ParseDate

func ParseDate(value string) (time.Time, error)

Types

type Availability added in v0.1.1

type Availability struct {
	Start     time.Time         `json:"start"`
	End       time.Time         `json:"end"`
	Timezone  string            `json:"timezone"`
	Matches   []Space           `json:"matches"`
	WindowEnd map[Category]bool `json:"window_end"`
}

type AvailabilityOptions added in v0.1.1

type AvailabilityOptions struct {
	Start       time.Time
	End         time.Time
	Category    Category
	MinCapacity int
	MaxCapacity int
}

type Booking added in v0.1.1

type Booking struct {
	ID         int       `json:"id"`
	Space      string    `json:"space"`
	Category   string    `json:"category"`
	Start      time.Time `json:"start"`
	End        time.Time `json:"end"`
	Cancelable bool      `json:"cancelable"`
}

type Cancellation added in v0.1.1

type Cancellation struct {
	BookingID     int  `json:"booking_id"`
	Canceled      bool `json:"canceled"`
	MoreRemaining bool `json:"more_remaining"`
}

type Category

type Category string
const (
	CategoryRooms  Category = "rooms"
	CategoryPods   Category = "pods"
	CategoryAll    Category = "all"
	CategoryFirst  Category = "lvl1"
	CategorySecond Category = "lvl2"
	CategoryThird  Category = "lvl3"
)

type CategoryInfo

type CategoryInfo struct {
	ID   int      `json:"id"`
	Name string   `json:"name"`
	Slug Category `json:"slug"`
	Kind string   `json:"kind"`
}

func Categories

func Categories() []CategoryInfo

type CategorySchedule

type CategorySchedule struct {
	Category  CategoryInfo    `json:"category"`
	WindowEnd bool            `json:"window_end"`
	Spaces    []SpaceSchedule `json:"spaces"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(httpClient Doer) *Client

func NewPublic

func NewPublic() *Client

func Open

func Open(options auth.Options) (*Client, error)

func (*Client) Availability added in v0.1.1

func (c *Client) Availability(ctx context.Context, options AvailabilityOptions) (Availability, error)

func (*Client) Book

func (c *Client) Book(ctx context.Context, selection Selection, details ReservationDetails) (reservation Reservation, resultErr error)

func (*Client) Bookings added in v0.1.1

func (c *Client) Bookings(ctx context.Context, code string) ([]Booking, error)

func (*Client) Cancel added in v0.1.1

func (c *Client) Cancel(ctx context.Context, code string, bookingID int) (Cancellation, error)

func (*Client) Release

func (c *Client) Release(ctx context.Context) error

func (*Client) Schedule

func (c *Client) Schedule(ctx context.Context, options ScheduleOptions) (Schedule, error)

func (*Client) Space

func (c *Client) Space(ctx context.Context, id int) (Space, error)

func (*Client) Spaces

func (c *Client) Spaces(ctx context.Context, selector Category) ([]Space, error)

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

type Error

type Error struct {
	Code    string
	Message string
	Cause   error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) ErrorCode

func (e *Error) ErrorCode() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Interval

type Interval struct {
	Start     time.Time `json:"start"`
	End       time.Time `json:"end"`
	Available bool      `json:"available"`
	Status    string    `json:"status"`
	// contains filtered or unexported fields
}

type Reservation

type Reservation struct {
	Space       Space     `json:"space"`
	Start       time.Time `json:"start"`
	End         time.Time `json:"end"`
	State       string    `json:"state"`
	ConfirmedAt time.Time `json:"confirmed_at"`
}

type ReservationDetails

type ReservationDetails struct {
	Fields      map[string]string
	AcceptTerms bool
}

type ResponseError

type ResponseError struct {
	Operation string
	Status    int
	BodyBytes int
	Cause     error
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

func (*ResponseError) ErrorCode

func (e *ResponseError) ErrorCode() string

func (*ResponseError) Unwrap

func (e *ResponseError) Unwrap() error

type Schedule

type Schedule struct {
	StartDate  string             `json:"start_date"`
	EndDate    string             `json:"end_date"`
	Timezone   string             `json:"timezone"`
	Categories []CategorySchedule `json:"categories"`
}

func (Schedule) Availability added in v0.1.1

func (s Schedule) Availability(start, end time.Time) (Availability, error)

type ScheduleOptions

type ScheduleOptions struct {
	Date        time.Time
	EndDate     time.Time
	Category    Category
	MinCapacity int
	MaxCapacity int
}

type Selection

type Selection struct {
	SpaceID int       `json:"space_id"`
	Start   time.Time `json:"start"`
	End     time.Time `json:"end"`
}

func (Selection) Validate

func (s Selection) Validate() error

type Space

type Space struct {
	ID           int      `json:"id"`
	Name         string   `json:"name"`
	Capacity     int      `json:"capacity"`
	Category     string   `json:"category"`
	CategoryID   int      `json:"category_id"`
	CategorySlug Category `json:"category_slug"`
	Kind         string   `json:"kind"`
	URL          string   `json:"url"`
}

type SpaceSchedule

type SpaceSchedule struct {
	Space     Space      `json:"space"`
	Intervals []Interval `json:"intervals"`
}

Jump to

Keyboard shortcuts

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