Add custom getTimtable methods
This commit is contained in:
parent
5da4f26f67
commit
e5eb2c3628
|
@ -247,8 +247,8 @@ 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)
|
||||
* @param startDate the start date of the requested days
|
||||
* @param endDate the end date of the requested days
|
||||
* @param startDate the start date of the requested days (format: YYYYMMDD)
|
||||
* @param endDate the end date of the requested days (format: YYYYMMDD)
|
||||
* @return an ArrayList of period objects
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
|
@ -260,4 +260,38 @@ public class UntisClient {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a customizable 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 options optianal options to customize the return object
|
||||
* @return an ArrayList of period objects
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public TimetableResponse getTimetable(int id, int type, Options options) throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getTimetable", new CustonTimetableParams(id, type, options), TimetableResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id the id of the element
|
||||
* @param type the type of the element (use Constants class for this)
|
||||
* @param options optianal options to customize the return object
|
||||
* @param startDate the start date of the requested days (format: YYYYMMDD)
|
||||
* @param endDate the end date of the requested days (format: YYYYMMDD)
|
||||
* @return an ArrayList of period objects
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public TimetableResponse getTimetable(int id, int type, Options options, int startDate, int endDate) throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getTimetable", new CustonTimetableParams(id, type, options, startDate, endDate), TimetableResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package ley.untis.data;
|
||||
|
||||
public class CustonTimetableParams {
|
||||
|
||||
public Option options;
|
||||
|
||||
public CustonTimetableParams(int id, int type, Options options) {
|
||||
this.options = new Option(id, type, options);
|
||||
}
|
||||
|
||||
public CustonTimetableParams(int id, int type, Options options, int startDate, int endDate) {
|
||||
this.options = new DateOption(id, type, options, startDate, endDate);
|
||||
}
|
||||
|
||||
public static class Option {
|
||||
public Element element;
|
||||
public boolean onlyBaseTimetable;
|
||||
public boolean showBooking;
|
||||
public boolean showInfo;
|
||||
public boolean showSubstText;
|
||||
public boolean showLsText;
|
||||
public boolean showLsNumber;
|
||||
public boolean showStudentgroup;
|
||||
public String[] klasseFields;
|
||||
public String[] teacherFields;
|
||||
public String[] subjectFields;
|
||||
public String[] roomFields;
|
||||
|
||||
public Option(int id, int type, Options options) {
|
||||
element = new Element(id, type);
|
||||
onlyBaseTimetable = options.onlyBaseTimetable;
|
||||
showBooking = options.showBooking;
|
||||
showInfo = options.showInfo;
|
||||
showSubstText = options.showSubstText;
|
||||
showLsText = options.showLsText;
|
||||
showLsNumber = options.showLsNumber;
|
||||
showStudentgroup = options.showStudentgroup;
|
||||
if(options.klasseFields == null) {
|
||||
klasseFields = new String[1];
|
||||
klasseFields[0] = "id";
|
||||
} else {
|
||||
klasseFields = options.klasseFields;
|
||||
}
|
||||
if(options.teacherFields == null) {
|
||||
teacherFields = new String[1];
|
||||
teacherFields[0] = "id";
|
||||
} else {
|
||||
teacherFields = options.teacherFields;
|
||||
}
|
||||
if(options.subjectFields == null) {
|
||||
subjectFields = new String[1];
|
||||
subjectFields[0] = "id";
|
||||
} else {
|
||||
subjectFields = options.subjectFields;
|
||||
}
|
||||
if(options.roomFields == null) {
|
||||
roomFields = new String[1];
|
||||
roomFields[0] = "id";
|
||||
} else {
|
||||
roomFields = options.roomFields;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Element {
|
||||
public Element(int id, int type) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
}
|
||||
public int id;
|
||||
public int type;
|
||||
public String keyType= "id";
|
||||
}
|
||||
}
|
||||
|
||||
public static class DateOption extends Option {
|
||||
public int startDate;
|
||||
public int endDate;
|
||||
|
||||
public DateOption(int id, int type, Options options, int startDate, int endDate) {
|
||||
super(id, type, options);
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package ley.untis.data;
|
||||
|
||||
public class Options {
|
||||
public boolean onlyBaseTimetable;
|
||||
public boolean showBooking;
|
||||
public boolean showInfo;
|
||||
public boolean showSubstText;
|
||||
public boolean showLsText;
|
||||
public boolean showLsNumber;
|
||||
public boolean showStudentgroup;
|
||||
public String[] klasseFields;
|
||||
public String[] teacherFields;
|
||||
public String[] subjectFields;
|
||||
public String[] roomFields;
|
||||
}
|
Loading…
Reference in New Issue