diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dfe19f4..900ffd5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] # Plugins -kotlin = "2.3.0" +kotlin = "2.4.0" maven-publish = "0.36.0" androidGradlePlugin = "9.0.0" diff --git a/jecnaapi-canteen/src/commonMain/kotlin/io/github/tomhula/jecnaapi/CanteenClient.kt b/jecnaapi-canteen/src/commonMain/kotlin/io/github/tomhula/jecnaapi/CanteenClient.kt index b3066eb..dc7a34f 100644 --- a/jecnaapi-canteen/src/commonMain/kotlin/io/github/tomhula/jecnaapi/CanteenClient.kt +++ b/jecnaapi-canteen/src/commonMain/kotlin/io/github/tomhula/jecnaapi/CanteenClient.kt @@ -5,6 +5,7 @@ import io.github.tomhula.jecnaapi.data.canteen.ExchangeItem import io.github.tomhula.jecnaapi.data.canteen.MenuItem import io.github.tomhula.jecnaapi.data.canteen.MenuPage import io.github.tomhula.jecnaapi.data.canteen.Orderable +import io.github.tomhula.jecnaapi.parser.ParseException import io.github.tomhula.jecnaapi.web.Auth import kotlinx.coroutines.flow.Flow import kotlinx.datetime.LocalDate @@ -14,15 +15,24 @@ import kotlinx.datetime.LocalDate */ interface CanteenClient { + @Throws(RuntimeException::class) suspend fun login(auth: Auth): Boolean + @Throws(RuntimeException::class) suspend fun login(username: String, password: String) = login(Auth(username, password)) + @Throws(RuntimeException::class) suspend fun logout() + @Throws(RuntimeException::class) suspend fun isLoggedIn(): Boolean /** Prefer using [getMenuAsync] instead. */ + @Throws(ParseException::class, RuntimeException::class) suspend fun getMenuPage(): MenuPage + @Throws(ParseException::class, RuntimeException::class) fun getMenuAsync(days: Iterable): Flow + @Throws(ParseException::class, RuntimeException::class) suspend fun getDayMenu(day: LocalDate): DayMenu + @Throws(ParseException::class, RuntimeException::class) suspend fun getExchange(): List + @Throws(ParseException::class, RuntimeException::class) suspend fun getCredit(): Float /** * Places an order for the given [orderable]. @@ -33,7 +43,9 @@ interface CanteenClient * @param orderable The [io.github.tomhula.jecnaapi.canteen.Orderable] to order. * @return -1f for success with no credit info, non-negative value for a new credit, or null for failure. */ + @Throws(RuntimeException::class) suspend fun order(orderable: Orderable): Float? + @Throws(RuntimeException::class) suspend fun putOnExchange(menuItem: MenuItem): Boolean companion object diff --git a/jecnaapi-jecna/src/commonMain/kotlin/io/github/tomhula/jecnaapi/JecnaClient.kt b/jecnaapi-jecna/src/commonMain/kotlin/io/github/tomhula/jecnaapi/JecnaClient.kt index 9d40c05..52d99c4 100644 --- a/jecnaapi-jecna/src/commonMain/kotlin/io/github/tomhula/jecnaapi/JecnaClient.kt +++ b/jecnaapi-jecna/src/commonMain/kotlin/io/github/tomhula/jecnaapi/JecnaClient.kt @@ -17,6 +17,7 @@ import io.github.tomhula.jecnaapi.data.schoolStaff.TeachersPage import io.github.tomhula.jecnaapi.data.student.Locker import io.github.tomhula.jecnaapi.data.student.Student import io.github.tomhula.jecnaapi.data.timetable.TimetablePage +import io.github.tomhula.jecnaapi.parser.ParseException import io.github.tomhula.jecnaapi.util.SchoolYear import io.github.tomhula.jecnaapi.util.SchoolYearHalf import io.github.tomhula.jecnaapi.web.Auth @@ -26,34 +27,61 @@ import kotlin.time.Duration.Companion.seconds interface JecnaClient { + @Throws(IllegalStateException::class, RuntimeException::class) suspend fun login(auth: Auth): Boolean + @Throws(IllegalStateException::class, RuntimeException::class) suspend fun login(username: String, password: String): Boolean = login(Auth(username, password)) + @Throws(RuntimeException::class) suspend fun logout() + @Throws(RuntimeException::class) suspend fun isLoggedIn(): Boolean + @Throws(ParseException::class, RuntimeException::class) suspend fun getNewsPage(): NewsPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getGradesPage(schoolYear: SchoolYear, schoolYearHalf: SchoolYearHalf): GradesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getGradesPage(): GradesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getTimetablePage(schoolYear: SchoolYear, periodId: Int?): TimetablePage + @Throws(ParseException::class, RuntimeException::class) suspend fun getTimetablePage(schoolYear: SchoolYear, periodOption: TimetablePage.PeriodOption? = null) = getTimetablePage(schoolYear, periodOption?.id) + @Throws(ParseException::class, RuntimeException::class) suspend fun getTimetablePage(): TimetablePage + @Throws(ParseException::class, RuntimeException::class) suspend fun getAttendancesPage(schoolYear: SchoolYear, month: Month): AttendancesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getAttendancesPage(): AttendancesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getAbsencesPage(schoolYear: SchoolYear): AbsencesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getAbsencesPage(): AbsencesPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getTeachersPage(): TeachersPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getTeacher(teacherTag: String): Teacher + @Throws(ParseException::class, RuntimeException::class) suspend fun getTeacher(teacherReference: TeacherReference): Teacher = getTeacher(teacherReference.tag) + @Throws(ParseException::class, RuntimeException::class) suspend fun getRoomsPage(): RoomsPage + @Throws(ParseException::class, RuntimeException::class) suspend fun getRoom(roomCode: String): Room + @Throws(ParseException::class, RuntimeException::class) suspend fun getRoom(roomReference: RoomReference): Room = getRoom(roomReference.roomCode) + @Throws(ParseException::class, RuntimeException::class) suspend fun getLocker(): Locker? + @Throws(ParseException::class, RuntimeException::class) suspend fun getStudentProfile(): Student + @Throws(ParseException::class, RuntimeException::class) suspend fun getStudentProfile(username: String): Student + @Throws(ParseException::class, RuntimeException::class) suspend fun getNotifications(): List + @Throws(ParseException::class, RuntimeException::class) suspend fun getNotification(notification: NotificationReference): Notification /** @return the list of student's certificates or `null` if the student cannot have any certificates (i.e. he is not in the 4th grade) */ + @Throws(ParseException::class, RuntimeException::class) suspend fun getStudentCertificates(): List? + @Throws(ParseException::class, RuntimeException::class) suspend fun getDocumentsPage(path: String = "/dokumenty"): DocumentsPage companion object