Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
# Plugins
kotlin = "2.3.0"
kotlin = "2.4.0"
maven-publish = "0.36.0"
androidGradlePlugin = "9.0.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<LocalDate>): Flow<DayMenu>
@Throws(ParseException::class, RuntimeException::class)
suspend fun getDayMenu(day: LocalDate): DayMenu
@Throws(ParseException::class, RuntimeException::class)
suspend fun getExchange(): List<ExchangeItem>
@Throws(ParseException::class, RuntimeException::class)
suspend fun getCredit(): Float
/**
* Places an order for the given [orderable].
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<NotificationReference>
@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<Certificate>?
@Throws(ParseException::class, RuntimeException::class)
suspend fun getDocumentsPage(path: String = "/dokumenty"): DocumentsPage

companion object
Expand Down