You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-26Lines changed: 42 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -38,23 +38,25 @@ public class Main {
38
38
try {
39
39
Session session =Session.login("your webuntis username", "your webuntis password", "https://example.webuntis.com", "myschool"); // create a new webuntis session
40
40
41
-
for (Timetable.Lesson lesson: session.getTimetableFromKlasseId(LocalDate.now(), LocalDate.now())) { // get the timetable and loop over it
42
-
System.out.println("Lesson "+String.join(", ", lesson.getSubjectIds()) +" from "+ lesson.getStartTime() +" to "+ lesson.getEndTime()); // print the subject and the lesson time (from x to y)
41
+
// print out all classes with their names and ids
42
+
for (Classes.ClassObject classObject : session.getClasses()) {
43
+
System.out.printf("Class name: '%s' - Class id: '%d'\n", classObject.getName(), classObject.getId());
43
44
}
44
45
45
-
session.logout(); //logout
46
-
} catch (LoginException e) { // this exception get thrown if something went wrong with Session.login
46
+
// logout
47
+
session.logout();
48
+
} catch (LoginException e) {
49
+
// this exception get thrown if something went wrong with Session.login
47
50
System.out.println("Failed to login: "+ e.getMessage());
48
-
return;
49
-
} catch (IOException e) {// if an error appears this get thrown
51
+
} catch (IOException e) {
52
+
// if an error appears this get thrown
50
53
e.printStackTrace();
51
-
return;
52
54
}
53
55
}
54
56
}
55
57
```
56
58
57
-
## Get a specific klasse
59
+
## Find / search a specific class
58
60
59
61
```java
60
62
publicclassMain {
@@ -63,18 +65,26 @@ public class Main {
63
65
try {
64
66
Session session =Session.login("your webuntis username", "your webuntis password", "https://example.webuntis.com", "myschool"); // creates a new webuntis session
65
67
66
-
Klassen klassen = session.getKlassen(); // get all klassen which are registered on the server
67
-
Klassen.KlasseObject myKlasse = klassen.findById(1234); // find an klasse by its id
68
+
Classes classes = session.getClasses();
68
69
69
-
System.out.println("Name of my klasse: "+ myKlasse.getLongName());
70
+
// get a class by its id
71
+
// findBy(...) methods only returns one result
72
+
System.out.println(classes.findById(1234));
70
73
71
-
session.logout(); //logout
72
-
} catch (LoginException e) { // this exception get thrown if something went wrong with Session.login
74
+
// this prints all classes which contains 's' in their name.
75
+
// searchBy(...) methods can return multiple results / matches
76
+
for (Classes.ClassObject classObject : classes.searchByName("s")) {
77
+
System.out.println(classObject);
78
+
}
79
+
80
+
// logout
81
+
session.logout();
82
+
} catch (LoginException e) {
83
+
// this exception get thrown if something went wrong with Session.login
73
84
System.out.println("Failed to login: "+ e.getMessage());
74
-
return;
75
-
} catch (IOException e) {// if an error appears this get thrown
85
+
} catch (IOException e) {
86
+
// if an error appears this get thrown
76
87
e.printStackTrace();
77
-
return;
78
88
}
79
89
}
80
90
@@ -88,25 +98,31 @@ public class Main {
88
98
89
99
publicstaticvoidmain(String[] args) {
90
100
try {
91
-
Session session =Session.login("your webuntis username", "your webuntis password", "webuntis.grupet.at", "demo_inf"); // creates a new webuntis session
0 commit comments