Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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/
var GenericParameterErr = errors.New("invalid parameter")
Generic errors wrapped to make others
var GenericParsingErr = errors.New("error parsing")
var GenericRequestErr = errors.New("error performing request") // wrap??
var InvalidDayRangeErr = errors.Wrap(GenericParameterErr, "invalid day range")
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)