purdue_api

package module
v0.0.0-...-e5c11aa Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiningLocations = []string{
	"Earhart", "Ford", "Hillenbrand", "Wiley", "Windsor",
	"1Bowl", "All American Dining Room", "Pete's Za", "The Gathering Place",
	"Earhart On-the-GO!", "Ford On-the-GO!", "Knoy On-the-GO!", "Lawson On-the-GO!", "Lilly On-the-GO!",
	"Windsor On-the-GO!",
}

Valid dining options are retrieved from https://dining.purdue.edu/menus/

View Source
var GenericParameterErr = errors.New("invalid parameter")

Generic errors wrapped to make others

View Source
var GenericParsingErr = errors.New("error parsing")
View Source
var GenericRequestErr = errors.New("error performing request") // wrap??
View Source
var InvalidDayRangeErr = errors.Wrap(GenericParameterErr, "invalid day range")
View Source
var InvalidLocationErr = errors.Wrap(GenericParameterErr, "invalid location")

More specific errors for different purposes

Functions

func GetDiningDays

func GetDiningDays(location string, date time.Time, dayStart int, dayEnd int) (map[int]*DiningInfo, error)

TODO maybe use config for controlling number of concurrent goroutines? GetDiningDays gets dining info for one location over a range of dates (positive or negative number of days). Returns a populated map[int]*DiningInfo if successful (where int represents date range), else returns err != nil. For concurrency, the last error found is returned if any is found.

func GetDiningLocations

func GetDiningLocations(date time.Time) (map[string]*DiningInfo, error)

GetDiningLocations gets all dining info (from what's been implemented) for a specific day. Returns a populated map[string]*DiningInfo if successful (where string represents location), else returns err !- nil. For concurrency, the last error found is returned if any is found.

Types

type DiningInfo

type DiningInfo struct {
	Notes     string          `json:"Notes"`
	Available bool            `json:"Available"` // whether has menu info
	Location  string          `json:"Location"`
	Meals     map[string]Meal `json:"Meals"`
}

DiningInfo contains information about one location's meals for one day.

func GetDining

func GetDining(location string, date time.Time) (*DiningInfo, error)

TODO deal with locations being case sensitive, seriously Purdue? GetDining retrieves the day's dining for one dining "location" (just meal courts?). Returns a populated pointer if successful, otherwise returns an error (refer to above errors for errors.Is)

type Item

type Item struct {
	Name       string   `json:"Name"`
	Vegetarian bool     `json:"Vegetarian"`
	Allergens  []string `json:"Allergens"`
}

Item represents a single served item

type Meal

type Meal struct {
	Name          string             `json:"Name"` // just in case
	Open          bool               `json:"Open"`
	Type          string             `json:"Type"`
	StartingHours string             `json:"StartingHours"` // sick of parsing...
	EndingHours   string             `json:"EndingHours"`   // sick of parsing...
	Stations      map[string]Station `json:"Stations"`
}

Meal contains meal information including opening hours and station dishes (meal name is key in map)

type Station

type Station struct {
	Name    string `json:"Name"`
	Items   []Item `json:"Items"`
	IconURL string `json:"IconURL"`
}

Station represents a single serving station containing items

Jump to

Keyboard shortcuts

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