From 2b5bca72ae12d2b8c44ea1ed0ade7936427de6d6 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Sat, 18 Jan 2020 15:53:09 +0100 Subject: [PATCH] Add getSubjects method to UntisClient --- src/main/java/ley/untis/UntisClient.java | 14 ++++++++++++++ .../java/ley/untis/data/SubjectResponse.java | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/ley/untis/data/SubjectResponse.java diff --git a/src/main/java/ley/untis/UntisClient.java b/src/main/java/ley/untis/UntisClient.java index 84cd448..93ad002 100644 --- a/src/main/java/ley/untis/UntisClient.java +++ b/src/main/java/ley/untis/UntisClient.java @@ -3,6 +3,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.exception.APIRequestException; import java.net.URL; @@ -63,5 +64,18 @@ public class UntisClient { } } + /** + * Get list of subjects + * @return an ArrayList of subjects + * @throws APIRequestException + */ + public SubjectResponse getSubjects() throws APIRequestException{ + try { + return client.invoke("getSubjects", new Object[0], SubjectResponse.class); + } catch (Throwable e) { + throw new APIRequestException(e); + } + } + } diff --git a/src/main/java/ley/untis/data/SubjectResponse.java b/src/main/java/ley/untis/data/SubjectResponse.java new file mode 100644 index 0000000..846fdf0 --- /dev/null +++ b/src/main/java/ley/untis/data/SubjectResponse.java @@ -0,0 +1,17 @@ +package ley.untis.data; + +import java.util.ArrayList; + +public class SubjectResponse extends ArrayList { + + public static class Subject { + public int id; + public String name; + public String longName; + public String foreColor; + public String backColor; + public String alternateName; + public boolean active; + } + +}