Documentation
¶
Overview ¶
Package openmensa provides an API to interface with OpenMensa.org.
Index ¶
- Constants
- Variables
- type Canteen
- func (c *Canteen) AllMenus() ([]Menu, error)
- func (c *Canteen) CurrentMenu() (*Menu, error)
- func (c *Canteen) Day(date time.Time) (*Day, error)
- func (c *Canteen) Days() ([]Day, error)
- func (c *Canteen) Meal(date time.Time, mealId int) (*Meal, error)
- func (c *Canteen) MenuOn(date time.Time) (*Menu, error)
- func (c Canteen) String() string
- type Day
- type Meal
- type Menu
- type Opening
Constants ¶
const DateLayout = "2006-01-02"
Simplified ISO 8601 date layout used by OpenMensa.
Can be used for Time.Format() et al.
Variables ¶
var Endpoint = "https://openmensa.org/api/v2"
API endpoint URL
Functions ¶
This section is empty.
Types ¶
type Canteen ¶
type Canteen struct { // Id is a unique identifier of the canteen. Id int `json:"id"` // Name of the canteen. Name string `json:"name"` // City the canteen is located in. City string `json:"city"` // Address of the canteen. Address string `json:"address"` // Geographic coordinates of the canteen. Coordinates []float64 `json:"coordinates"` }
Canteen contains information associated with a specific canteen, cafe, cafeteria, etc.
func AllCanteens ¶ added in v0.3.0
AllCanteens returns all canteens listed in OpenMensa
func CanteensNear ¶ added in v0.3.0
CanteensNear returns canteens in the radius of the given latitude and longitude
func GetCanteen ¶
GetCanteen returns data about a specific canteen.
func GetCanteens ¶
GetCanteens retrieves multiple canteens specified by their IDs.
func SearchCanteens ¶ added in v0.3.0
SearchCanteens returns a slice of canteens whose names match the given pattern
func (*Canteen) CurrentMenu ¶ added in v0.4.0
CurrentMenu returns returns all meals served by a canteen on today's date.
func (*Canteen) Day ¶ added in v0.3.0
Day returns specific opening information of a given canteen on a given date.
func (*Canteen) Meal ¶ added in v0.3.0
Meal returns a specific meal.
A single meal is identified by the day it is served on and its ID.
type Day ¶
type Day struct { // Date is the given date of operation. Date Opening `json:"date"` // Closed indicates if the canteen is closed on the given date. Closed bool `json:"closed"` }
Day represents a canteen's opening status.
type Meal ¶
type Meal struct { // Id is a unique identifier for the meal. Id int `json:"id"` // Name is the title of the meal. Name string `json:"name"` // Optional category metadata Category string `json:"category"` // Notes include extra information, such as allergens. Notes []string `json:"notes"` // Prices vary for different groups of patrons. // // Note that the groups vary by canteen operator. // Typically these include "students", "employees", "others", and "pupils". Prices map[string]float64 `json:"prices"` }
Meal is the representation of a canteen's menu item.
func (Meal) String ¶
String returns a human-readable representation of a meal.
Currently, this is simply the meal's name.
func (*Meal) UnmarshalJSON ¶ added in v0.4.1
UnmarshalJSON is a custom unmarshaller for Meals. This function acts as a regular json.Unmarshal, but removes duplicate note entries.
This function may be removed should the official OpenMensa API perform server-side duplicate handling one day.
type Menu ¶ added in v0.4.0
Menu represents all meals served by a canteen on a given day.
In German, this is the semantic equivalent to a "Speiseplan"
func (*Menu) UnmarshalJSON ¶ added in v0.4.0
Custom unmarshaller to get around the inconsistency between /canteens/{id}/days/{date}, which returns an object with two attributes, and /canteens/{id}/meals, which returns two attributes and meals directly
This function may be removed should the official OpenMensa API return opening information as a single JSON object one day.