Add simple getTimtable methods

This commit is contained in:
Timo Ley 2020-01-19 13:07:22 +01:00
parent a09caa9152
commit 5da4f26f67
5 changed files with 95 additions and 1 deletions

View File

@ -228,5 +228,36 @@ public class UntisClient {
}
}
/**
* Get timetable for klasse, teacher, student, room, subject
* @param id the id of the element
* @param type the type of the element (use Constants class for this)
* @return an ArrayList of period objects
* @throws APIRequestException
*/
public TimetableResponse getTimetable(int id, int type) throws APIRequestException {
try {
return client.invoke("getTimetable", new SimpleTimetableParams(id, type), TimetableResponse.class);
} catch (Throwable e) {
throw new APIRequestException(e);
}
}
/**
* Get timetable for klasse, teacher, student, room, subject
* @param id the id of the element
* @param type the type of the element (use Constants class for this)
* @param startDate the start date of the requested days
* @param endDate the end date of the requested days
* @return an ArrayList of period objects
* @throws APIRequestException
*/
public TimetableResponse getTimetable(int id, int type, int startDate, int endDate) throws APIRequestException {
try {
return client.invoke("getTimetable", new SimpleTimetableDateParams(id, type, startDate, endDate), TimetableResponse.class);
} catch (Throwable e) {
throw new APIRequestException(e);
}
}
}

View File

@ -2,6 +2,7 @@ package ley.untis.data;
public class Constants {
//Days
public static final int SUNDAY = 1;
public static final int MONDAY = 2;
public static final int TUESDAY = 3;
@ -9,7 +10,7 @@ public class Constants {
public static final int THURSDAY = 5;
public static final int FRIDAY = 6;
public static final int SATURDAY = 7;
//Types
public static final int KLASSE = 1;
public static final int TEACHER = 2;
public static final int ROOM = 3;

View File

@ -0,0 +1,13 @@
package ley.untis.data;
public class SimpleTimetableDateParams extends SimpleTimetableParams {
public int startDate;
public int endDate;
public SimpleTimetableDateParams(int id, int type, int startDate, int endDate) {
super(id, type);
this.startDate = startDate;
this.endDate = endDate;
}
}

View File

@ -0,0 +1,12 @@
package ley.untis.data;
public class SimpleTimetableParams {
public int id;
public int type;
public SimpleTimetableParams(int id, int type) {
this.id = id;
this.type = type;
}
}

View File

@ -0,0 +1,37 @@
package ley.untis.data;
import java.util.ArrayList;
public class TimetableResponse extends ArrayList<TimetableResponse.Period> {
public static class Period {
public int id;
public int date;
public int startTime;
public int endTime;
public String lstype;
public String code;
public String info;
public String substText;
public String lstext;
public int lsnumber;
public String statflags;
public String activityType;
public String sg;
public String bkRemark;
public String bkText;
public Holder[] kl;
public Holder[] te;
public Holder[] su;
public Holder[] ro;
public static class Holder {
public int id;
public String name;
public String longname;
public String externalkey;
}
}
}