Add getTeachers, getStudents, getRooms and getKlassen methods to UntisClient
This commit is contained in:
parent
2b5bca72ae
commit
77428f59ae
|
@ -1,9 +1,7 @@
|
|||
package ley.untis;
|
||||
|
||||
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
|
||||
import ley.untis.data.AuthParams;
|
||||
import ley.untis.data.AuthResponse;
|
||||
import ley.untis.data.SubjectResponse;
|
||||
import ley.untis.data.*;
|
||||
import ley.untis.exception.APIRequestException;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -69,7 +67,7 @@ public class UntisClient {
|
|||
* @return an ArrayList of subjects
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public SubjectResponse getSubjects() throws APIRequestException{
|
||||
public SubjectResponse getSubjects() throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getSubjects", new Object[0], SubjectResponse.class);
|
||||
} catch (Throwable e) {
|
||||
|
@ -77,5 +75,72 @@ public class UntisClient {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of teachers
|
||||
* @return an ArrayList of teachers
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public TeacherResponse getTeachers() throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getTeachers", new Object[0], TeacherResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of Klassen (base class) for schoolyear
|
||||
* @param schoolyearId Id of the schoolyear
|
||||
* @return an ArrayList of Klassen
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public KlasseResponse getKlassen(String schoolyearId) throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getKlassen", new KlasseParams(schoolyearId), KlasseResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of Klassen (base class) for current schoolyear
|
||||
* @return an ArrayList of Klassen
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public KlasseResponse getKlassen() throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getKlassen", new Object[0], KlasseResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of students
|
||||
* @return an ArrayList of students
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public StudentResponse getStudents() throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getStudents", new Object[0], StudentResponse.class);
|
||||
} catch (Throwable e) {
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of rooms
|
||||
* @return an ArrayList of rooms
|
||||
* @throws APIRequestException
|
||||
*/
|
||||
public RoomResponse getRooms() throws APIRequestException {
|
||||
try {
|
||||
return client.invoke("getRooms", new Object[0], RoomResponse.class);
|
||||
} catch (Throwable e)
|
||||
{
|
||||
throw new APIRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
10
src/main/java/ley/untis/data/KlasseParams.java
Normal file
10
src/main/java/ley/untis/data/KlasseParams.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package ley.untis.data;
|
||||
|
||||
public class KlasseParams {
|
||||
|
||||
public String schoolyearId;
|
||||
|
||||
public KlasseParams(String schoolyearId) {
|
||||
this.schoolyearId = schoolyearId;
|
||||
}
|
||||
}
|
17
src/main/java/ley/untis/data/KlasseResponse.java
Normal file
17
src/main/java/ley/untis/data/KlasseResponse.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package ley.untis.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class KlasseResponse extends ArrayList<KlasseResponse.Klasse> {
|
||||
|
||||
public static class Klasse {
|
||||
public int id;
|
||||
public String name;
|
||||
public String longName;
|
||||
public String backColor;
|
||||
public String longColor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
15
src/main/java/ley/untis/data/RoomResponse.java
Normal file
15
src/main/java/ley/untis/data/RoomResponse.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ley.untis.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RoomResponse extends ArrayList<RoomResponse.Room> {
|
||||
|
||||
public static class Room {
|
||||
public int id;
|
||||
public String name;
|
||||
public String longName;
|
||||
public String foreColor;
|
||||
public String backColor;
|
||||
}
|
||||
|
||||
}
|
16
src/main/java/ley/untis/data/StudentResponse.java
Normal file
16
src/main/java/ley/untis/data/StudentResponse.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ley.untis.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StudentResponse extends ArrayList<StudentResponse.Student> {
|
||||
|
||||
public static class Student {
|
||||
public int id;
|
||||
public String key;
|
||||
public String name;
|
||||
public String foreName;
|
||||
public String longName;
|
||||
public String gender;
|
||||
}
|
||||
|
||||
}
|
18
src/main/java/ley/untis/data/TeacherResponse.java
Normal file
18
src/main/java/ley/untis/data/TeacherResponse.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package ley.untis.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TeacherResponse extends ArrayList<TeacherResponse.Teacher> {
|
||||
|
||||
public static class Teacher {
|
||||
|
||||
public int id;
|
||||
public String name;
|
||||
public String longName;
|
||||
public String foreName;
|
||||
public String foreColor;
|
||||
public String backColor;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue