Skip to content
Snippets Groups Projects
Commit 7653d038 authored by Florian Meissner's avatar Florian Meissner
Browse files

finished printMeals

parent 11f797d0
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import ohm.softa.a11.openmensa.OpenMensaAPI;
import ohm.softa.a11.openmensa.OpenMensaAPIService;
import ohm.softa.a11.openmensa.model.Canteen;
import ohm.softa.a11.openmensa.model.PageInfo;
import retrofit2.HttpException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -109,6 +110,21 @@ public class App {
/* TODO fetch all meals for the currently selected canteen
* to avoid errors retrieve at first the state of the canteen and check if the canteen is opened at the selected day
* don't forget to check if a canteen was selected previously! */
if (currentCanteenId == -1) {
System.out.println("Error: no canteen selected");
return;
}
openMensaAPI
.getMeals(currentCanteenId, dateFormat.format(currentDate.getTime()))
.exceptionally((e) -> {
System.out.println(e.getMessage());
if (e instanceof HttpException) System.out.println(((HttpException) e).response());
return List.of();
})
.thenAccept(meals -> meals.forEach(System.out::println))
.join();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment