Specify return type explicity in public API
This commit is contained in:
parent
4c50ae000f
commit
59042d9458
2 changed files with 165 additions and 103 deletions
|
@ -1,19 +1,48 @@
|
|||
package io.github.wulkanowy.sdk.scrapper
|
||||
|
||||
import io.github.wulkanowy.sdk.scrapper.attendance.Absent
|
||||
import io.github.wulkanowy.sdk.scrapper.attendance.Attendance
|
||||
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceSummary
|
||||
import io.github.wulkanowy.sdk.scrapper.attendance.Subject
|
||||
import io.github.wulkanowy.sdk.scrapper.conferences.Conference
|
||||
import io.github.wulkanowy.sdk.scrapper.exams.Exam
|
||||
import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException
|
||||
import io.github.wulkanowy.sdk.scrapper.grades.Grade
|
||||
import io.github.wulkanowy.sdk.scrapper.grades.GradePointsSummary
|
||||
import io.github.wulkanowy.sdk.scrapper.grades.GradeSummary
|
||||
import io.github.wulkanowy.sdk.scrapper.grades.GradesStatisticsPartial
|
||||
import io.github.wulkanowy.sdk.scrapper.grades.GradesStatisticsSemester
|
||||
import io.github.wulkanowy.sdk.scrapper.home.DirectorInformation
|
||||
import io.github.wulkanowy.sdk.scrapper.home.GovernmentUnit
|
||||
import io.github.wulkanowy.sdk.scrapper.home.LuckyNumber
|
||||
import io.github.wulkanowy.sdk.scrapper.homework.Homework
|
||||
import io.github.wulkanowy.sdk.scrapper.login.LoginHelper
|
||||
import io.github.wulkanowy.sdk.scrapper.messages.Folder
|
||||
import io.github.wulkanowy.sdk.scrapper.messages.Message
|
||||
import io.github.wulkanowy.sdk.scrapper.messages.Recipient
|
||||
import io.github.wulkanowy.sdk.scrapper.messages.ReportingUnit
|
||||
import io.github.wulkanowy.sdk.scrapper.messages.SentMessage
|
||||
import io.github.wulkanowy.sdk.scrapper.mobile.Device
|
||||
import io.github.wulkanowy.sdk.scrapper.mobile.TokenResponse
|
||||
import io.github.wulkanowy.sdk.scrapper.notes.Note
|
||||
import io.github.wulkanowy.sdk.scrapper.register.Semester
|
||||
import io.github.wulkanowy.sdk.scrapper.register.Student
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.AccountRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.HomepageRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.MessagesRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.RegisterRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.StudentRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.repository.StudentStartRepository
|
||||
import io.github.wulkanowy.sdk.scrapper.school.School
|
||||
import io.github.wulkanowy.sdk.scrapper.school.Teacher
|
||||
import io.github.wulkanowy.sdk.scrapper.service.ServiceManager
|
||||
import io.github.wulkanowy.sdk.scrapper.student.StudentInfo
|
||||
import io.github.wulkanowy.sdk.scrapper.student.StudentPhoto
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.CompletedLesson
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.Timetable
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.TimetableAdditional
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.TimetableDayHeader
|
||||
import io.github.wulkanowy.sdk.scrapper.timetable.TimetableFull
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import java.net.URL
|
||||
|
@ -230,73 +259,73 @@ class Scrapper {
|
|||
HomepageRepository(serviceManager.getHomepageService())
|
||||
}
|
||||
|
||||
suspend fun getPasswordResetCaptcha(registerBaseUrl: String, symbol: String) = account.getPasswordResetCaptcha(registerBaseUrl, symbol)
|
||||
suspend fun getPasswordResetCaptcha(registerBaseUrl: String, symbol: String): Pair<String, String> = account.getPasswordResetCaptcha(registerBaseUrl, symbol)
|
||||
|
||||
suspend fun sendPasswordResetRequest(registerBaseUrl: String, symbol: String, email: String, captchaCode: String): String {
|
||||
return account.sendPasswordResetRequest(registerBaseUrl, symbol, email.trim(), captchaCode)
|
||||
}
|
||||
|
||||
suspend fun getStudents() = register.getStudents()
|
||||
suspend fun getStudents(): List<Student> = register.getStudents()
|
||||
|
||||
suspend fun getSemesters(): List<Semester> = studentStart.getSemesters()
|
||||
|
||||
suspend fun getAttendance(startDate: LocalDate, endDate: LocalDate? = null) = student.getAttendance(startDate, endDate)
|
||||
suspend fun getAttendance(startDate: LocalDate, endDate: LocalDate? = null): List<Attendance> = student.getAttendance(startDate, endDate)
|
||||
|
||||
suspend fun getAttendanceSummary(subjectId: Int? = -1) = student.getAttendanceSummary(subjectId)
|
||||
suspend fun getAttendanceSummary(subjectId: Int? = -1): List<AttendanceSummary> = student.getAttendanceSummary(subjectId)
|
||||
|
||||
suspend fun excuseForAbsence(absents: List<Absent>, content: String? = null) = student.excuseForAbsence(absents, content)
|
||||
suspend fun excuseForAbsence(absents: List<Absent>, content: String? = null): Boolean = student.excuseForAbsence(absents, content)
|
||||
|
||||
suspend fun getSubjects() = student.getSubjects()
|
||||
suspend fun getSubjects(): List<Subject> = student.getSubjects()
|
||||
|
||||
suspend fun getExams(startDate: LocalDate, endDate: LocalDate? = null) = student.getExams(startDate, endDate)
|
||||
suspend fun getExams(startDate: LocalDate, endDate: LocalDate? = null): List<Exam> = student.getExams(startDate, endDate)
|
||||
|
||||
suspend fun getGrades(semesterId: Int) = student.getGrades(semesterId)
|
||||
suspend fun getGrades(semesterId: Int): Pair<List<Grade>, List<GradeSummary>> = student.getGrades(semesterId)
|
||||
|
||||
suspend fun getGradesDetails(semesterId: Int? = null) = student.getGradesDetails(semesterId)
|
||||
suspend fun getGradesDetails(semesterId: Int? = null): List<Grade> = student.getGradesDetails(semesterId)
|
||||
|
||||
suspend fun getGradesSummary(semesterId: Int? = null) = student.getGradesSummary(semesterId)
|
||||
suspend fun getGradesSummary(semesterId: Int? = null): List<GradeSummary> = student.getGradesSummary(semesterId)
|
||||
|
||||
suspend fun getGradesPartialStatistics(semesterId: Int) = student.getGradesPartialStatistics(semesterId)
|
||||
suspend fun getGradesPartialStatistics(semesterId: Int): List<GradesStatisticsPartial> = student.getGradesPartialStatistics(semesterId)
|
||||
|
||||
suspend fun getGradesPointsStatistics(semesterId: Int) = student.getGradesPointsStatistics(semesterId)
|
||||
suspend fun getGradesPointsStatistics(semesterId: Int): List<GradePointsSummary> = student.getGradesPointsStatistics(semesterId)
|
||||
|
||||
suspend fun getGradesSemesterStatistics(semesterId: Int) = student.getGradesAnnualStatistics(semesterId)
|
||||
suspend fun getGradesSemesterStatistics(semesterId: Int): List<GradesStatisticsSemester> = student.getGradesAnnualStatistics(semesterId)
|
||||
|
||||
suspend fun getHomework(startDate: LocalDate, endDate: LocalDate? = null) = student.getHomework(startDate, endDate)
|
||||
suspend fun getHomework(startDate: LocalDate, endDate: LocalDate? = null): List<Homework> = student.getHomework(startDate, endDate)
|
||||
|
||||
suspend fun getNotes() = student.getNotes()
|
||||
suspend fun getNotes(): List<Note> = student.getNotes()
|
||||
|
||||
suspend fun getConferences() = student.getConferences()
|
||||
suspend fun getConferences(): List<Conference> = student.getConferences()
|
||||
|
||||
suspend fun getTimetableFull(startDate: LocalDate, endDate: LocalDate? = null) = student.getTimetableFull(startDate, endDate)
|
||||
suspend fun getTimetableFull(startDate: LocalDate, endDate: LocalDate? = null): TimetableFull = student.getTimetableFull(startDate, endDate)
|
||||
|
||||
suspend fun getTimetable(startDate: LocalDate, endDate: LocalDate? = null) = student.getTimetable(startDate, endDate)
|
||||
suspend fun getTimetable(startDate: LocalDate, endDate: LocalDate? = null): Pair<List<Timetable>, List<TimetableAdditional>> = student.getTimetable(startDate, endDate)
|
||||
|
||||
suspend fun getTimetableNormal(startDate: LocalDate, endDate: LocalDate? = null) = student.getTimetableNormal(startDate, endDate)
|
||||
suspend fun getTimetableNormal(startDate: LocalDate, endDate: LocalDate? = null): List<Timetable> = student.getTimetableNormal(startDate, endDate)
|
||||
|
||||
suspend fun getTimetableHeaders(startDate: LocalDate) = student.getTimetableHeaders(startDate)
|
||||
suspend fun getTimetableHeaders(startDate: LocalDate): List<TimetableDayHeader> = student.getTimetableHeaders(startDate)
|
||||
|
||||
suspend fun getTimetableAdditional(startDate: LocalDate) = student.getTimetableAdditional(startDate)
|
||||
suspend fun getTimetableAdditional(startDate: LocalDate): List<TimetableAdditional> = student.getTimetableAdditional(startDate)
|
||||
|
||||
suspend fun getCompletedLessons(startDate: LocalDate, endDate: LocalDate? = null, subjectId: Int = -1) = student.getCompletedLessons(startDate, endDate, subjectId)
|
||||
suspend fun getCompletedLessons(startDate: LocalDate, endDate: LocalDate? = null, subjectId: Int = -1): List<CompletedLesson> = student.getCompletedLessons(startDate, endDate, subjectId)
|
||||
|
||||
suspend fun getRegisteredDevices() = student.getRegisteredDevices()
|
||||
suspend fun getRegisteredDevices(): List<Device> = student.getRegisteredDevices()
|
||||
|
||||
suspend fun getToken() = student.getToken()
|
||||
suspend fun getToken(): TokenResponse = student.getToken()
|
||||
|
||||
suspend fun unregisterDevice(id: Int) = student.unregisterDevice(id)
|
||||
suspend fun unregisterDevice(id: Int): Boolean = student.unregisterDevice(id)
|
||||
|
||||
suspend fun getTeachers() = student.getTeachers()
|
||||
suspend fun getTeachers(): List<Teacher> = student.getTeachers()
|
||||
|
||||
suspend fun getSchool() = student.getSchool()
|
||||
suspend fun getSchool(): School = student.getSchool()
|
||||
|
||||
suspend fun getStudentInfo() = student.getStudentInfo()
|
||||
suspend fun getStudentInfo(): StudentInfo = student.getStudentInfo()
|
||||
|
||||
suspend fun getStudentPhoto() = student.getStudentPhoto()
|
||||
suspend fun getStudentPhoto(): StudentPhoto = student.getStudentPhoto()
|
||||
|
||||
suspend fun getReportingUnits() = messages.getReportingUnits()
|
||||
suspend fun getReportingUnits(): List<ReportingUnit> = messages.getReportingUnits()
|
||||
|
||||
suspend fun getRecipients(unitId: Int, role: Int = 2) = messages.getRecipients(unitId, role)
|
||||
suspend fun getRecipients(unitId: Int, role: Int = 2): List<Recipient> = messages.getRecipients(unitId, role)
|
||||
|
||||
suspend fun getMessages(
|
||||
folder: Folder,
|
||||
|
@ -312,39 +341,39 @@ class Scrapper {
|
|||
|
||||
suspend fun getReceivedMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null) = messages.getReceivedMessages(startDate, endDate)
|
||||
|
||||
suspend fun getSentMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null) = messages.getSentMessages(startDate, endDate)
|
||||
suspend fun getSentMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null): List<Message> = messages.getSentMessages(startDate, endDate)
|
||||
|
||||
suspend fun getDeletedMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null) = messages.getDeletedMessages(startDate, endDate)
|
||||
suspend fun getDeletedMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null): List<Message> = messages.getDeletedMessages(startDate, endDate)
|
||||
|
||||
suspend fun getMessageRecipients(messageId: Int, loginId: Int = 0) = messages.getMessageRecipients(messageId, loginId)
|
||||
suspend fun getMessageRecipients(messageId: Int, loginId: Int = 0): List<Recipient> = messages.getMessageRecipients(messageId, loginId)
|
||||
|
||||
suspend fun getMessageDetails(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null) = messages.getMessageDetails(messageId, folderId, read, id)
|
||||
suspend fun getMessageDetails(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null): Message = messages.getMessageDetails(messageId, folderId, read, id)
|
||||
|
||||
suspend fun getMessageContent(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null) = messages.getMessage(messageId, folderId, read, id)
|
||||
suspend fun getMessageContent(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null): String = messages.getMessage(messageId, folderId, read, id)
|
||||
|
||||
suspend fun sendMessage(subject: String, content: String, recipients: List<Recipient>) = messages.sendMessage(subject, content, recipients)
|
||||
suspend fun sendMessage(subject: String, content: String, recipients: List<Recipient>): SentMessage = messages.sendMessage(subject, content, recipients)
|
||||
|
||||
suspend fun deleteMessages(messagesToDelete: List<Int>, folderId: Int) = messages.deleteMessages(messagesToDelete, folderId)
|
||||
suspend fun deleteMessages(messagesToDelete: List<Int>, folderId: Int): Boolean = messages.deleteMessages(messagesToDelete, folderId)
|
||||
|
||||
suspend fun getDirectorInformation() = homepage.getDirectorInformation()
|
||||
suspend fun getDirectorInformation(): List<DirectorInformation> = homepage.getDirectorInformation()
|
||||
|
||||
suspend fun getSelfGovernments() = homepage.getSelfGovernments()
|
||||
suspend fun getSelfGovernments(): List<GovernmentUnit> = homepage.getSelfGovernments()
|
||||
|
||||
suspend fun getStudentThreats() = homepage.getStudentThreats()
|
||||
suspend fun getStudentThreats(): List<String> = homepage.getStudentThreats()
|
||||
|
||||
suspend fun getStudentsTrips() = homepage.getStudentsTrips()
|
||||
suspend fun getStudentsTrips(): List<String> = homepage.getStudentsTrips()
|
||||
|
||||
suspend fun getLastGrades() = homepage.getLastGrades()
|
||||
suspend fun getLastGrades(): List<String> = homepage.getLastGrades()
|
||||
|
||||
suspend fun getFreeDays() = homepage.getFreeDays()
|
||||
suspend fun getFreeDays(): List<String> = homepage.getFreeDays()
|
||||
|
||||
suspend fun getKidsLuckyNumbers() = homepage.getKidsLuckyNumbers()
|
||||
suspend fun getKidsLuckyNumbers(): List<LuckyNumber> = homepage.getKidsLuckyNumbers()
|
||||
|
||||
suspend fun getKidsLessonPlan() = homepage.getKidsLessonPlan()
|
||||
suspend fun getKidsLessonPlan(): List<String> = homepage.getKidsLessonPlan()
|
||||
|
||||
suspend fun getLastHomework() = homepage.getLastHomework()
|
||||
suspend fun getLastHomework(): List<String> = homepage.getLastHomework()
|
||||
|
||||
suspend fun getLastTests() = homepage.getLastTests()
|
||||
suspend fun getLastTests(): List<String> = homepage.getLastTests()
|
||||
|
||||
suspend fun getLastStudentLessons() = homepage.getLastStudentLessons()
|
||||
suspend fun getLastStudentLessons(): List<String> = homepage.getLastStudentLessons()
|
||||
}
|
||||
|
|
|
@ -40,9 +40,40 @@ import io.github.wulkanowy.sdk.mapper.mapToUnits
|
|||
import io.github.wulkanowy.sdk.mapper.mapToken
|
||||
import io.github.wulkanowy.sdk.mobile.Mobile
|
||||
import io.github.wulkanowy.sdk.pojo.Absent
|
||||
import io.github.wulkanowy.sdk.pojo.Attendance
|
||||
import io.github.wulkanowy.sdk.pojo.AttendanceSummary
|
||||
import io.github.wulkanowy.sdk.pojo.CompletedLesson
|
||||
import io.github.wulkanowy.sdk.pojo.Conference
|
||||
import io.github.wulkanowy.sdk.pojo.Device
|
||||
import io.github.wulkanowy.sdk.pojo.DirectorInformation
|
||||
import io.github.wulkanowy.sdk.pojo.Exam
|
||||
import io.github.wulkanowy.sdk.pojo.Folder
|
||||
import io.github.wulkanowy.sdk.pojo.GovernmentUnit
|
||||
import io.github.wulkanowy.sdk.pojo.Grade
|
||||
import io.github.wulkanowy.sdk.pojo.GradePointsStatistics
|
||||
import io.github.wulkanowy.sdk.pojo.GradeStatisticsSemester
|
||||
import io.github.wulkanowy.sdk.pojo.GradeStatisticsSubject
|
||||
import io.github.wulkanowy.sdk.pojo.GradeSummary
|
||||
import io.github.wulkanowy.sdk.pojo.Homework
|
||||
import io.github.wulkanowy.sdk.pojo.LuckyNumber
|
||||
import io.github.wulkanowy.sdk.pojo.Message
|
||||
import io.github.wulkanowy.sdk.pojo.MessageDetails
|
||||
import io.github.wulkanowy.sdk.pojo.Note
|
||||
import io.github.wulkanowy.sdk.pojo.Recipient
|
||||
import io.github.wulkanowy.sdk.pojo.ReportingUnit
|
||||
import io.github.wulkanowy.sdk.pojo.School
|
||||
import io.github.wulkanowy.sdk.pojo.Semester
|
||||
import io.github.wulkanowy.sdk.pojo.SentMessage
|
||||
import io.github.wulkanowy.sdk.pojo.Student
|
||||
import io.github.wulkanowy.sdk.pojo.StudentInfo
|
||||
import io.github.wulkanowy.sdk.pojo.StudentPhoto
|
||||
import io.github.wulkanowy.sdk.pojo.Subject
|
||||
import io.github.wulkanowy.sdk.pojo.Teacher
|
||||
import io.github.wulkanowy.sdk.pojo.Timetable
|
||||
import io.github.wulkanowy.sdk.pojo.TimetableAdditional
|
||||
import io.github.wulkanowy.sdk.pojo.TimetableDayHeader
|
||||
import io.github.wulkanowy.sdk.pojo.TimetableFull
|
||||
import io.github.wulkanowy.sdk.pojo.Token
|
||||
import io.github.wulkanowy.sdk.scrapper.Scrapper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -239,11 +270,11 @@ class Sdk {
|
|||
scrapper.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode)
|
||||
}
|
||||
|
||||
suspend fun getStudentsFromMobileApi(token: String, pin: String, symbol: String, firebaseToken: String, apiKey: String = "") = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentsFromMobileApi(token: String, pin: String, symbol: String, firebaseToken: String, apiKey: String = ""): List<Student> = withContext(Dispatchers.IO) {
|
||||
mobile.getStudents(mobile.getCertificate(token, pin, symbol, buildTag, androidVersion, firebaseToken), apiKey).mapStudents(symbol)
|
||||
}
|
||||
|
||||
suspend fun getStudentsFromScrapper(email: String, password: String, scrapperBaseUrl: String, symbol: String = "Default") = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentsFromScrapper(email: String, password: String, scrapperBaseUrl: String, symbol: String = "Default"): List<Student> = withContext(Dispatchers.IO) {
|
||||
scrapper.let {
|
||||
it.baseUrl = scrapperBaseUrl
|
||||
it.email = email
|
||||
|
@ -283,175 +314,175 @@ class Sdk {
|
|||
}.toList().flatten()
|
||||
}
|
||||
|
||||
suspend fun getSemesters() = withContext(Dispatchers.IO) {
|
||||
suspend fun getSemesters(): List<Semester> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSemesters().mapSemesters()
|
||||
Mode.API -> mobile.getStudents().mapSemesters(studentId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getAttendance(startDate: LocalDate, endDate: LocalDate, semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getAttendance(startDate: LocalDate, endDate: LocalDate, semesterId: Int): List<Attendance> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getAttendance(startDate, endDate).mapAttendance()
|
||||
Mode.HYBRID, Mode.API -> mobile.getAttendance(startDate, endDate, semesterId).mapAttendance(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getAttendanceSummary(subjectId: Int? = -1) = withContext(Dispatchers.IO) {
|
||||
suspend fun getAttendanceSummary(subjectId: Int? = -1): List<AttendanceSummary> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getAttendanceSummary(subjectId).mapAttendanceSummary()
|
||||
Mode.API -> throw FeatureNotAvailableException("Attendance summary is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun excuseForAbsence(absents: List<Absent>, content: String? = null) = withContext(Dispatchers.IO) {
|
||||
suspend fun excuseForAbsence(absents: List<Absent>, content: String? = null): Boolean = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.excuseForAbsence(absents.mapToScrapperAbsent(), content)
|
||||
Mode.API -> throw FeatureNotAvailableException("Absence excusing is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSubjects() = withContext(Dispatchers.IO) {
|
||||
suspend fun getSubjects(): List<Subject> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSubjects().mapSubjects()
|
||||
Mode.API -> mobile.getDictionaries().subjects.mapSubjects()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getExams(start: LocalDate, end: LocalDate, semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getExams(start: LocalDate, end: LocalDate, semesterId: Int): List<Exam> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getExams(start, end).mapExams()
|
||||
Mode.HYBRID, Mode.API -> mobile.getExams(start, end, semesterId).mapExams(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGrades(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGrades(semesterId: Int): Pair<List<Grade>, List<GradeSummary>> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getGrades(semesterId).mapGrades()
|
||||
Mode.HYBRID, Mode.API -> mobile.getGrades(semesterId).mapGrades(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGradesDetails(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGradesDetails(semesterId: Int): List<Grade> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getGradesDetails(semesterId).mapGradesDetails()
|
||||
Mode.HYBRID, Mode.API -> mobile.getGradesDetails(semesterId).mapGradesDetails(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGradesSummary(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGradesSummary(semesterId: Int): List<GradeSummary> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getGradesSummary(semesterId).mapGradesSummary()
|
||||
Mode.HYBRID, Mode.API -> mobile.getGradesSummary(semesterId).mapGradesSummary(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGradesSemesterStatistics(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGradesSemesterStatistics(semesterId: Int): List<GradeStatisticsSemester> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getGradesSemesterStatistics(semesterId).mapGradesSemesterStatistics()
|
||||
Mode.API -> throw FeatureNotAvailableException("Class grades annual statistics is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGradesPartialStatistics(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGradesPartialStatistics(semesterId: Int): List<GradeStatisticsSubject> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getGradesPartialStatistics(semesterId).mapGradeStatistics()
|
||||
Mode.API -> throw FeatureNotAvailableException("Class grades partial statistics is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGradesPointsStatistics(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getGradesPointsStatistics(semesterId: Int): List<GradePointsStatistics> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getGradesPointsStatistics(semesterId).mapGradePointsStatistics()
|
||||
Mode.API -> throw FeatureNotAvailableException("Class grades points statistics is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getHomework(start: LocalDate, end: LocalDate, semesterId: Int = 0) = withContext(Dispatchers.IO) {
|
||||
suspend fun getHomework(start: LocalDate, end: LocalDate, semesterId: Int = 0): List<Homework> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getHomework(start, end).mapHomework()
|
||||
Mode.HYBRID, Mode.API -> mobile.getHomework(start, end, semesterId).mapHomework(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getNotes(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getNotes(semesterId: Int): List<Note> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getNotes().mapNotes()
|
||||
Mode.HYBRID, Mode.API -> mobile.getNotes(semesterId).mapNotes(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getConferences() = withContext(Dispatchers.IO) {
|
||||
suspend fun getConferences(): List<Conference> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getConferences().mapConferences(registerTimeZone)
|
||||
Mode.API -> throw FeatureNotAvailableException("Conferences is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getRegisteredDevices() = withContext(Dispatchers.IO) {
|
||||
suspend fun getRegisteredDevices(): List<Device> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getRegisteredDevices().mapDevices(registerTimeZone)
|
||||
Mode.API -> throw FeatureNotAvailableException("Devices management is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getToken() = withContext(Dispatchers.IO) {
|
||||
suspend fun getToken(): Token = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getToken().mapToken()
|
||||
Mode.API -> throw FeatureNotAvailableException("Devices management is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun unregisterDevice(id: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun unregisterDevice(id: Int): Boolean = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.unregisterDevice(id)
|
||||
Mode.API -> throw FeatureNotAvailableException("Devices management is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getTeachers(semesterId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTeachers(semesterId: Int): List<Teacher> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTeachers().mapTeachers()
|
||||
Mode.HYBRID, Mode.API -> mobile.getTeachers(studentId, semesterId).mapTeachers(mobile.getDictionaries())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSchool() = withContext(Dispatchers.IO) {
|
||||
suspend fun getSchool(): School = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSchool().mapSchool()
|
||||
Mode.API -> throw FeatureNotAvailableException("School info is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getStudentInfo() = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentInfo(): StudentInfo = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getStudentInfo().mapStudent()
|
||||
Mode.API -> throw FeatureNotAvailableException("Student info is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getStudentPhoto() = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentPhoto(): StudentPhoto = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getStudentPhoto().mapPhoto()
|
||||
Mode.API -> throw FeatureNotAvailableException("Student photo is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getReportingUnits() = withContext(Dispatchers.IO) {
|
||||
suspend fun getReportingUnits(): List<ReportingUnit> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getReportingUnits().mapReportingUnits()
|
||||
Mode.API -> mobile.getStudents().mapReportingUnits(studentId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getRecipients(unitId: Int, role: Int = 2) = withContext(Dispatchers.IO) {
|
||||
suspend fun getRecipients(unitId: Int, role: Int = 2): List<Recipient> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getRecipients(unitId, role).mapRecipients()
|
||||
Mode.API -> mobile.getDictionaries().teachers.mapRecipients(unitId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getMessages(folder: Folder, start: LocalDateTime, end: LocalDateTime) = withContext(Dispatchers.IO) {
|
||||
suspend fun getMessages(folder: Folder, start: LocalDateTime, end: LocalDateTime): List<Message> = withContext(Dispatchers.IO) {
|
||||
when (folder) {
|
||||
Folder.RECEIVED -> getReceivedMessages(start, end)
|
||||
Folder.SENT -> getSentMessages(start, end)
|
||||
|
@ -459,35 +490,35 @@ class Sdk {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getReceivedMessages(start: LocalDateTime, end: LocalDateTime) = withContext(Dispatchers.IO) {
|
||||
suspend fun getReceivedMessages(start: LocalDateTime, end: LocalDateTime): List<Message> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getReceivedMessages(start, end).mapMessages(registerTimeZone)
|
||||
Mode.API -> mobile.getMessages(start, end).mapMessages(mobile.getDictionaries(), registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSentMessages(start: LocalDateTime, end: LocalDateTime) = withContext(Dispatchers.IO) {
|
||||
suspend fun getSentMessages(start: LocalDateTime, end: LocalDateTime): List<Message> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSentMessages(start, end).mapMessages(registerTimeZone)
|
||||
Mode.API -> mobile.getMessagesSent(start, end).mapMessages(mobile.getDictionaries(), registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getDeletedMessages(start: LocalDateTime, end: LocalDateTime) = withContext(Dispatchers.IO) {
|
||||
suspend fun getDeletedMessages(start: LocalDateTime, end: LocalDateTime): List<Message> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getDeletedMessages(start, end).mapMessages(registerTimeZone)
|
||||
Mode.API -> mobile.getMessagesDeleted(start, end).mapMessages(mobile.getDictionaries(), registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getMessageRecipients(messageId: Int, senderId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun getMessageRecipients(messageId: Int, senderId: Int): List<Recipient> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getMessageRecipients(messageId, senderId).mapRecipients()
|
||||
Mode.API -> TODO()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getMessageDetails(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null) = withContext(Dispatchers.IO) {
|
||||
suspend fun getMessageDetails(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null): MessageDetails = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getMessageDetails(messageId, folderId, read, id).mapScrapperMessage()
|
||||
Mode.API -> {
|
||||
|
@ -502,14 +533,14 @@ class Sdk {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun sendMessage(subject: String, content: String, recipients: List<Recipient>) = withContext(Dispatchers.IO) {
|
||||
suspend fun sendMessage(subject: String, content: String, recipients: List<Recipient>): SentMessage = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.sendMessage(subject, content, recipients.mapFromRecipientsToScraper()).mapSentMessage()
|
||||
Mode.API -> mobile.sendMessage(subject, content, recipients.mapFromRecipientsToMobile()).mapSentMessage(loginId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteMessages(messages: List<Int>, folderId: Int) = withContext(Dispatchers.IO) {
|
||||
suspend fun deleteMessages(messages: List<Int>, folderId: Int): Boolean = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.deleteMessages(messages, folderId)
|
||||
Mode.HYBRID, Mode.API -> messages.map { messageId ->
|
||||
|
@ -523,56 +554,58 @@ class Sdk {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getTimetableFull(start: LocalDate, end: LocalDate) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTimetableFull(start: LocalDate, end: LocalDate): TimetableFull = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTimetableFull(start, end).mapTimetableFull(registerTimeZone)
|
||||
Mode.HYBRID, Mode.API -> mobile.getTimetable(start, end, 0).mapTimetableFull(mobile.getDictionaries(), registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getTimetable(start: LocalDate, end: LocalDate) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTimetable(start: LocalDate, end: LocalDate): Pair<List<Timetable>, List<TimetableAdditional>> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTimetable(start, end).let { (normal, additional) -> normal.mapTimetable(registerTimeZone) to additional.mapTimetableAdditional(registerTimeZone) }
|
||||
Mode.SCRAPPER -> scrapper.getTimetable(start, end)
|
||||
.let { (normal, additional) -> normal.mapTimetable(registerTimeZone) to additional.mapTimetableAdditional(registerTimeZone) }
|
||||
|
||||
Mode.HYBRID, Mode.API -> mobile.getTimetable(start, end, 0).mapTimetable(mobile.getDictionaries(), registerTimeZone) to emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getTimetableHeaders(start: LocalDate, end: LocalDate) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTimetableHeaders(start: LocalDate, end: LocalDate): List<TimetableDayHeader> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTimetableHeaders(start).mapTimetableDayHeaders()
|
||||
Mode.HYBRID, Mode.API -> throw FeatureNotAvailableException("Timetable headers are not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getTimetableNormal(start: LocalDate, end: LocalDate) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTimetableNormal(start: LocalDate, end: LocalDate): List<Timetable> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTimetableNormal(start, end).mapTimetable(registerTimeZone)
|
||||
Mode.HYBRID, Mode.API -> mobile.getTimetable(start, end, 0).mapTimetable(mobile.getDictionaries(), registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getTimetableAdditional(start: LocalDate) = withContext(Dispatchers.IO) {
|
||||
suspend fun getTimetableAdditional(start: LocalDate): List<TimetableAdditional> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.SCRAPPER -> scrapper.getTimetableAdditional(start).mapTimetableAdditional(registerTimeZone)
|
||||
Mode.HYBRID, Mode.API -> throw FeatureNotAvailableException("Additional timetable lessons are not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getCompletedLessons(start: LocalDate, end: LocalDate? = null, subjectId: Int = -1) = withContext(Dispatchers.IO) {
|
||||
suspend fun getCompletedLessons(start: LocalDate, end: LocalDate? = null, subjectId: Int = -1): List<CompletedLesson> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getCompletedLessons(start, end, subjectId).mapCompletedLessons()
|
||||
Mode.API -> throw FeatureNotAvailableException("Completed lessons are not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLuckyNumber(unitName: String = "") = withContext(Dispatchers.IO) {
|
||||
suspend fun getLuckyNumber(unitName: String = ""): LuckyNumber? = withContext(Dispatchers.IO) {
|
||||
val numbers = getKidsLuckyNumbers()
|
||||
// if lucky number unitName match unit name from student tile
|
||||
numbers.singleOrNull { number -> number.unitName == unitName }?.let {
|
||||
return@withContext it
|
||||
}
|
||||
|
||||
// if there there is only one lucky number and its doesn't match to any student
|
||||
// if there is only one lucky number and its doesn't match to any student
|
||||
if (numbers.size == 1) {
|
||||
return@withContext numbers.single()
|
||||
}
|
||||
|
@ -586,77 +619,77 @@ class Sdk {
|
|||
null
|
||||
}
|
||||
|
||||
suspend fun getDirectorInformation() = withContext(Dispatchers.IO) {
|
||||
suspend fun getDirectorInformation(): List<DirectorInformation> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getDirectorInformation().mapDirectorInformation()
|
||||
Mode.API -> throw FeatureNotAvailableException("Director information is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSelfGovernments() = withContext(Dispatchers.IO) {
|
||||
suspend fun getSelfGovernments(): List<GovernmentUnit> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSelfGovernments().mapToUnits()
|
||||
Mode.API -> throw FeatureNotAvailableException("Self governments is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getStudentThreats() = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentThreats(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getStudentThreats()
|
||||
Mode.API -> throw FeatureNotAvailableException("Student threats are not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getStudentsTrips() = withContext(Dispatchers.IO) {
|
||||
suspend fun getStudentsTrips(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getStudentsTrips()
|
||||
Mode.API -> throw FeatureNotAvailableException("Students trips is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastGrades() = withContext(Dispatchers.IO) {
|
||||
suspend fun getLastGrades(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getLastGrades()
|
||||
Mode.API -> throw FeatureNotAvailableException("Last grades is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getFreeDays() = withContext(Dispatchers.IO) {
|
||||
suspend fun getFreeDays(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getFreeDays()
|
||||
Mode.API -> throw FeatureNotAvailableException("Free days is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getKidsLuckyNumbers() = withContext(Dispatchers.IO) {
|
||||
suspend fun getKidsLuckyNumbers(): List<LuckyNumber> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getKidsLuckyNumbers().mapLuckyNumbers()
|
||||
Mode.API -> throw FeatureNotAvailableException("Kids Lucky number is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getKidsTimetable() = withContext(Dispatchers.IO) {
|
||||
suspend fun getKidsTimetable(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getKidsLessonPlan()
|
||||
Mode.API -> throw FeatureNotAvailableException("Kids timetable is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastHomework() = withContext(Dispatchers.IO) {
|
||||
suspend fun getLastHomework(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getLastHomework()
|
||||
Mode.API -> throw FeatureNotAvailableException("Last homework is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastExams() = withContext(Dispatchers.IO) {
|
||||
suspend fun getLastExams(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getLastTests()
|
||||
Mode.API -> throw FeatureNotAvailableException("Last exams is not available in API mode")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastStudentLessons() = withContext(Dispatchers.IO) {
|
||||
suspend fun getLastStudentLessons(): List<String> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getLastStudentLessons()
|
||||
Mode.API -> throw FeatureNotAvailableException("Last student lesson is not available in API mode")
|
||||
|
|
Loading…
Reference in a new issue