Skip to content

Code Documentation

Kangaroo edited this page Jul 12, 2024 · 42 revisions

In this section you find short explanations for methods provided by classes and their instances, that are supposed to be used by developers. For further details, refer to the code.


MWApiWrapper Documentation

Class Methods

baseEndpoint

Returns the base URL for the OpenMensa API.

mealsPostfix

Returns the postfix URL for fetching meals, with placeholders for canteen ID and date.

locationPostfix

Returns a postfix for a URL to get all canteens within the area of coordinates, which includes placeholders for longitude, latitude, and a radius.

getMealsFrom:on:using:

This function fetches the meals from openmensa.org for a specified canteen on a specified date using a specified endpoint. Both parameters should be strings, and the date needs to be formatted as 'YYYY-MM-DD'. The endpoint should be a class, e.g. WebClient. The return type is a JSON string.

getOutletDictFrom:and:andRadius:

This function fetches all canteens within the radius of the coordinates from openmensa.org. All parameters should be strings. The return type is a Json.

MWCanteen Documentation

Class methods

newWithId:Name:Date:Meals:

Returns a prebuilt instance of the MWCanteen where all attributes have been set according to the parameters.

Instance methods

build

Returns a prebuilt version of the MWCanteen instance.

MWConfiguration Documentation

Class methods

getPopUp

Returns the PopUp for choosing the priceGroup.

MWDataGettingWrapper Documentation

Class Methods

hpiLatitude, hpiLongitude, hpiRadius

Return the coordinates of the HPI values for latitude, longitude, and radius.

initialLatitude, initialLongitude, initialRadius

Return the most recently selected values for latitude, longitude, and radius by the user. If the user has never set these values, they default to the coordinates of the HPI.

canteenDict

Returns a dictionary with canteen ID strings as keys and corresponding canteen name strings as values.

getTodaysMeals

Returns a Collection of CanteenObjects filled in with id, name, date, and meals using the date of today and all in the dictionary, that is stored class side, canteen Ids. The Canteens respectively hold their meals for today. It works by using the MWParser and MWApiWrapper look there for more documentation.

getMealsOn:

Returns a Collection of CanteenObjects filled in with id, name, date and meals using the date that is given to the function in the dict, that is stored class side, canteen Ids. The Canteens respectively hold their meals for today It works by using the MWParser and MWApiWrapper look there for more documentation.

requestUserInput

Requests User Input for latitude, longitude, and radius via a Popup window.

switchLocation

Switches the canteen dictionary to the current canteens in the area of the specified latitude, longitude, and radius.

switchToDefaultLocation

Switches the canteen dictionary to the canteens in the area of HPI.

MWFavorites Documentation

Class methods

toggleLike:

Likes or unlikes a meal based on a given event.

MWFrame Documentation

Class Methods

register

Initializes the Mensa Widget label in the Apps menu and opens the widget.

newWithDefaultLocation

Opens the Mensa Widget with the default location, the HPI.

newWithLocationSwitch

Prompts the user for latitude, longitude and radius beforehand, then opens the Mensa Widget with this location.

updateCategory

Updates the category across all opened MensaWidgets.

Instance Methods

initialize

Allows instance creation, assembling all the necessary parts. It calls the initializeFrame or setUpScreen based on a previous usage.

updateDate

Updates the content of the MensaWidget based on the current set date.

updateTime

Updates the content of the MensaWidget based on the current set time.

MWMeal Documentation

Class

updatePrice

Updates the price across all instances of the MWMeal.

instance methods

build

Returns the prebuilt version of the MWMeal instance.

MWMealCleaner Documentation

Class Methods

clean:

Takes in a list of MWMeal instances and polishes them in regards to the specific faults of the OpenMensa data.

MWMenuBar Documentation

Instance Methodes

increaseDate

Increases the Date by 1 and tells the associated MWFrame instance to update accordingly.

decreaseDate

Decreases the Date by 1 and tells the associated MWFrame instance to update accordingly.

toggleTime

Switches the time and tells the associated MWFrame instance to update accordingly.

MWParser Documentation

Class Methods

put:in:

Translates the Dataset that is input as a String into a Json or multiple Jsons and reads the information provided into instances of a given class. The function returns a list of instances of the provided class, as many as there are valid JSON objects in the Dataset.

putJSON:in:

Translates a Dataset that is input as a JSON into instances of the given class. The function returns a list of instances of the provided class, as many as there are valid JSON objects in the Dataset.

set:on:from:

Sets a desired instance variable on any class instance from a dataset. If no data is provided for the given instance variable, nil is the default value.

transformToDict

Translates a Dataset that is input as a String into a Dictionary.

transformJSONToDict

Translates a Dataset that is input as a JSON into a Dictionary.

Clone this wiki locally