From 76e6a0e5bd7f26a9d74bdc7f10e28de2b2f1d34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sat, 8 Apr 2023 01:09:29 +0200 Subject: [PATCH] Remove deprecated sdk-mobile module --- build.gradle | 1 - sdk-mobile/build.gradle | 20 - .../github/wulkanowy/sdk/mobile/ApiRequest.kt | 31 - .../wulkanowy/sdk/mobile/ApiResponse.kt | 29 - .../io/github/wulkanowy/sdk/mobile/Mobile.kt | 189 ---- .../sdk/mobile/ResettableLazyManager.kt | 55 -- .../io/github/wulkanowy/sdk/mobile/Utils.kt | 9 - .../sdk/mobile/attendance/Attendance.kt | 29 - .../mobile/attendance/AttendanceRequest.kt | 24 - .../mobile/attendance/AttendanceResponse.kt | 23 - .../mobile/dictionaries/AttendanceCategory.kt | 35 - .../sdk/mobile/dictionaries/AttendanceType.kt | 26 - .../sdk/mobile/dictionaries/Dictionaries.kt | 35 - .../dictionaries/DictionariesRequest.kt | 19 - .../sdk/mobile/dictionaries/Employee.kt | 29 - .../sdk/mobile/dictionaries/GradeCategory.kt | 17 - .../sdk/mobile/dictionaries/LessonTime.kt | 26 - .../sdk/mobile/dictionaries/NoteCategory.kt | 17 - .../sdk/mobile/dictionaries/Subject.kt | 23 - .../sdk/mobile/dictionaries/Teacher.kt | 29 - .../github/wulkanowy/sdk/mobile/exams/Exam.kt | 41 - .../sdk/mobile/exams/ExamsRequest.kt | 24 - .../mobile/exception/InvalidPinException.kt | 5 - .../exception/InvalidSymbolException.kt | 5 - .../mobile/exception/InvalidTokenException.kt | 5 - .../mobile/exception/NoStudentsException.kt | 5 - .../mobile/exception/TokenDeadException.kt | 3 - .../exception/TokenNotFoundException.kt | 3 - .../mobile/exception/UnknownTokenException.kt | 3 - .../exception/UnsupportedTokenException.kt | 5 - .../wulkanowy/sdk/mobile/grades/Grade.kt | 68 -- .../sdk/mobile/grades/GradeSummary.kt | 20 - .../sdk/mobile/grades/GradesRequest.kt | 18 - .../mobile/grades/GradesSummaryResponse.kt | 17 - .../wulkanowy/sdk/mobile/homework/Homework.kt | 29 - .../sdk/mobile/homework/HomeworkRequest.kt | 24 - .../mobile/interceptor/ErrorInterceptor.kt | 21 - .../sdk/mobile/interceptor/SignInterceptor.kt | 32 - .../wulkanowy/sdk/mobile/messages/Message.kt | 56 -- .../messages/MessageStatusChangeRequest.kt | 24 - .../sdk/mobile/messages/MessagesRequest.kt | 21 - .../sdk/mobile/messages/Recipient.kt | 14 - .../sdk/mobile/messages/SendMessageRequest.kt | 26 - .../github/wulkanowy/sdk/mobile/notes/Note.kt | 50 - .../sdk/mobile/notes/NotesRequest.kt | 15 - .../sdk/mobile/register/CertificateRequest.kt | 41 - .../mobile/register/CertificateResponse.kt | 26 - .../wulkanowy/sdk/mobile/register/Student.kt | 102 -- .../sdk/mobile/register/TokenCert.kt | 38 - .../sdk/mobile/repository/MobileRepository.kt | 101 -- .../mobile/repository/RegisterRepository.kt | 23 - .../mobile/repository/RepositoryManager.kt | 55 -- .../repository/RoutingRulesRepository.kt | 21 - .../wulkanowy/sdk/mobile/school/Teacher.kt | 17 - .../sdk/mobile/school/TeachersRequest.kt | 15 - .../sdk/mobile/school/TeachersResponse.kt | 14 - .../sdk/mobile/service/MobileService.kt | 75 -- .../sdk/mobile/service/RegisterService.kt | 20 - .../sdk/mobile/service/RoutingRulesService.kt | 9 - .../wulkanowy/sdk/mobile/timetable/Lesson.kt | 59 -- .../sdk/mobile/timetable/TimetableRequest.kt | 24 - .../wulkanowy/sdk/mobile/BaseLocalTest.kt | 42 - .../github/wulkanowy/sdk/mobile/UonetTest.kt | 124 --- .../wulkanowy/sdk/mobile/exams/ExamsTest.kt | 23 - .../wulkanowy/sdk/mobile/grades/GradesTest.kt | 22 - .../interceptor/ErrorInterceptorTest.kt | 39 - .../sdk/mobile/register/RegisterTest.kt | 21 - .../repository/RoutingRulesRepositoryTest.kt | 49 - .../sdk/mobile/timetable/TimetableTest.kt | 23 - .../github/wulkanowy/sdk/mobile/Slowniki.json | 911 ------------------ .../sdk/mobile/exams/Sprawdziany.json | 52 - .../wulkanowy/sdk/mobile/grades/Oceny.json | 54 -- .../sdk/mobile/grades/OcenyPodsumowanie.json | 68 -- .../sdk/mobile/interceptor/bad-request.txt | 1 - .../mobile/interceptor/invalid-symbol.html | 32 - .../sdk/mobile/register/ListaUczniow-2.json | 41 - .../sdk/mobile/register/ListaUczniow.json | 72 -- .../sdk/mobile/repository/RoutingRules.txt | 14 - .../sdk/mobile/timetable/PlanLekcji.json | 105 -- .../github/wulkanowy/sdk/scrapper/BaseTest.kt | 2 +- sdk/build.gradle | 12 - .../kotlin/io/github/wulkanowy/sdk/Sdk.kt | 153 +-- .../wulkanowy/sdk/mapper/AttendanceMapper.kt | 25 - .../wulkanowy/sdk/mapper/ExamsMapper.kt | 20 - .../wulkanowy/sdk/mapper/GradesMapper.kt | 41 - .../wulkanowy/sdk/mapper/HomeworkMapper.kt | 17 - .../wulkanowy/sdk/mapper/MessagesMapper.kt | 26 - .../wulkanowy/sdk/mapper/NotesMapper.kt | 17 - .../wulkanowy/sdk/mapper/RecipientMapper.kt | 31 - .../wulkanowy/sdk/mapper/SemesterMapper.kt | 32 - .../wulkanowy/sdk/mapper/StudentMapper.kt | 1 - .../wulkanowy/sdk/mapper/StudentsMapper.kt | 27 - .../wulkanowy/sdk/mapper/SubjectsMapper.kt | 9 - .../wulkanowy/sdk/mapper/TeacherMapper.kt | 12 - .../wulkanowy/sdk/mapper/TimetableMapper.kt | 49 +- .../io/github/wulkanowy/sdk/SdkRemoteTest.kt | 266 ----- .../sdk/mapper/AttendanceMapperTest.kt | 118 --- .../wulkanowy/sdk/mapper/ExamsMapperTest.kt | 32 - .../wulkanowy/sdk/mapper/GradesMapperTest.kt | 34 - .../wulkanowy/sdk/mapper/LessonMapperTest.kt | 66 -- .../sdk/mapper/SemesterMapperTest.kt | 55 -- .../sdk/mapper/SubjectsMapperTest.kt | 29 - settings.gradle | 1 - 103 files changed, 15 insertions(+), 4593 deletions(-) delete mode 100644 sdk-mobile/build.gradle delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiResponse.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Mobile.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ResettableLazyManager.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Utils.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/Attendance.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceResponse.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceCategory.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceType.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Dictionaries.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/DictionariesRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Employee.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/GradeCategory.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/LessonTime.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/NoteCategory.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Subject.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Teacher.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/Exam.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidPinException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidSymbolException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidTokenException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/NoStudentsException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenDeadException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenNotFoundException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnknownTokenException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnsupportedTokenException.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/Grade.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradeSummary.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesSummaryResponse.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/Homework.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/HomeworkRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptor.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/SignInterceptor.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Message.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessageStatusChangeRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessagesRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Recipient.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/SendMessageRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/Note.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/NotesRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateResponse.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/Student.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/TokenCert.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/MobileRepository.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RegisterRepository.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RepositoryManager.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepository.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/Teacher.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersRequest.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersResponse.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/MobileService.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RegisterService.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RoutingRulesService.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/Lesson.kt delete mode 100644 sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableRequest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/BaseLocalTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/UonetTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptorTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/register/RegisterTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepositoryTest.kt delete mode 100644 sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableTest.kt delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/Slowniki.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/exams/Sprawdziany.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/Oceny.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/OcenyPodsumowanie.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/bad-request.txt delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/invalid-symbol.html delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow-2.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow.json delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/repository/RoutingRules.txt delete mode 100644 sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/timetable/PlanLekcji.json delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapperTest.kt delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapperTest.kt delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapperTest.kt delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/LessonMapperTest.kt delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapperTest.kt delete mode 100644 sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapperTest.kt diff --git a/build.gradle b/build.gradle index 4e6732e6..81b2d0eb 100644 --- a/build.gradle +++ b/build.gradle @@ -158,7 +158,6 @@ subprojects { dependencies { api project(":sdk") - api project(":sdk-mobile") api project(":sdk-scrapper") api "com.squareup.okhttp3:okhttp" diff --git a/sdk-mobile/build.gradle b/sdk-mobile/build.gradle deleted file mode 100644 index a1c14482..00000000 --- a/sdk-mobile/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -plugins { - id 'java' - id 'org.jetbrains.kotlin.jvm' - id "com.google.devtools.ksp" -} - -dependencies { - implementation "com.github.wulkanowy:uonet-request-signer:c0b8b8ac54" - - implementation "com.brsanthu:migbase64:2.2" - - implementation libs.retrofit.core - implementation libs.retrofit.moshi - implementation libs.retrofit.scalars - - def moshi = "1.14.0" - implementation "com.squareup.moshi:moshi:$moshi" - implementation "com.squareup.moshi:moshi-adapters:$moshi" - ksp "com.squareup.moshi:moshi-kotlin-codegen:$moshi" -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiRequest.kt deleted file mode 100644 index 5be13ff1..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiRequest.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import java.time.LocalDateTime.now -import java.time.ZoneOffset -import java.util.UUID - -@Suppress("unused") -@JsonClass(generateAdapter = true) -open class ApiRequest( - - @Json(name = "RemoteMobileTimeKey") - val remoteMobileTimeKey: Long = now().toEpochSecond(ZoneOffset.UTC), - - @Json(name = "TimeKey") - val timeKey: Long = now().toEpochSecond(ZoneOffset.UTC) - 1, - - @Json(name = "RequestId") - val requestId: String = UUID.randomUUID().toString(), - - @Json(name = "RemoteMobileAppVersion") - val remoteMobileAppVersion: String = MOBILE_APP_VERSION, - - @Json(name = "RemoteMobileAppName") - val remoteMobileAppName: String = "VULCAN-Android-ModulUcznia", -) { - companion object { - const val MOBILE_APP_VERSION = "20.1.1.447" - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiResponse.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiResponse.kt deleted file mode 100644 index 397b5906..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ApiResponse.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class ApiResponse( - - @Json(name = "Status") - val status: String, - - @Json(name = "TimeKey") - val timeKey: String, - - @Json(name = "TimeValue") - val timeValue: String, - - @Json(name = "RequestId") - val requestId: String, - - @Json(name = "DayOfWeek") - val dayOfWeek: String, - - @Json(name = "AppVersion") - val appVersion: String, - - @Json(name = "Data") - val data: T?, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Mobile.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Mobile.kt deleted file mode 100644 index 5989ffe4..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Mobile.kt +++ /dev/null @@ -1,189 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import com.migcomponents.migbase64.Base64 -import io.github.wulkanowy.sdk.mobile.attendance.Attendance -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries -import io.github.wulkanowy.sdk.mobile.exams.Exam -import io.github.wulkanowy.sdk.mobile.exception.InvalidPinException -import io.github.wulkanowy.sdk.mobile.exception.NoStudentsException -import io.github.wulkanowy.sdk.mobile.exception.TokenDeadException -import io.github.wulkanowy.sdk.mobile.exception.TokenNotFoundException -import io.github.wulkanowy.sdk.mobile.exception.UnknownTokenException -import io.github.wulkanowy.sdk.mobile.exception.UnsupportedTokenException -import io.github.wulkanowy.sdk.mobile.grades.Grade -import io.github.wulkanowy.sdk.mobile.grades.GradesSummaryResponse -import io.github.wulkanowy.sdk.mobile.homework.Homework -import io.github.wulkanowy.sdk.mobile.messages.Message -import io.github.wulkanowy.sdk.mobile.messages.Recipient -import io.github.wulkanowy.sdk.mobile.notes.Note -import io.github.wulkanowy.sdk.mobile.register.CertificateResponse -import io.github.wulkanowy.sdk.mobile.register.Student -import io.github.wulkanowy.sdk.mobile.repository.RepositoryManager -import io.github.wulkanowy.sdk.mobile.school.Teacher -import io.github.wulkanowy.sdk.mobile.timetable.Lesson -import io.github.wulkanowy.signer.getPrivateKeyFromCert -import okhttp3.Interceptor -import okhttp3.logging.HttpLoggingInterceptor -import java.nio.charset.Charset -import java.time.LocalDate -import java.time.LocalDateTime - -class Mobile { - - var classId = 0 - - var studentId = 0 - - var loginId = 0 - - private val resettableManager = resettableManager() - - var logLevel = HttpLoggingInterceptor.Level.BASIC - set(value) { - field = value - resettableManager.reset() - } - - var privateKey = "" - set(value) { - field = value - resettableManager.reset() - } - - var certKey = "" - set(value) { - field = value - resettableManager.reset() - } - - var baseUrl = "" - set(value) { - field = value - resettableManager.reset() - } - - var schoolSymbol = "" - set(value) { - field = value - resettableManager.reset() - } - - private val serviceManager by resettableLazy(resettableManager) { RepositoryManager(logLevel, privateKey, certKey, interceptors, baseUrl, schoolSymbol) } - - private val routes by resettableLazy(resettableManager) { serviceManager.getRoutesRepository() } - - private val mobile by resettableLazy(resettableManager) { serviceManager.getMobileRepository() } - - private val interceptors: MutableList> = mutableListOf() - - fun setInterceptor(interceptor: Interceptor, network: Boolean = false) { - interceptors.add(interceptor to network) - } - - private lateinit var dictionaries: Dictionaries - - suspend fun getDictionaries(): Dictionaries { - if (::dictionaries.isInitialized) return dictionaries - - return mobile.getDictionaries(0, 0, classId) - .apply { dictionaries = this } - } - - suspend fun getCertificate(token: String, pin: String, symbol: String, deviceName: String, androidVer: String, firebaseToken: String): CertificateResponse { - val baseUrl = routes.getRouteByToken(token) - return serviceManager.getRegisterRepository(baseUrl, symbol).getCertificate(token, pin, deviceName, androidVer, firebaseToken) - } - - suspend fun getStudents(certRes: CertificateResponse, apiKey: String = ""): List { - if (certRes.isError) { - when { - certRes.message == "TokenDead" -> throw TokenDeadException(certRes.message) - certRes.message == "TokenNotFound" -> throw TokenNotFoundException(certRes.message) - certRes.message?.startsWith("Podany numer PIN jest niepoprawny") == true -> throw InvalidPinException(certRes.message) - certRes.message?.startsWith("Trzykrotnie wpisano niepoprawny kod PIN") == true -> throw InvalidPinException(certRes.message) - certRes.message == "NoPupils" -> throw NoStudentsException(certRes.message) - certRes.message == "OnlyKindergarten" -> throw UnsupportedTokenException(certRes.message) - else -> throw UnknownTokenException(certRes.message.orEmpty()) - } - } - - val cert = certRes.tokenCert!! - val privateKeyValue = apiKey.ifEmpty { - Base64.decode(if (cert.baseUrl.contains("fakelog")) "KDAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OUFCKQ==" else "KENFNzVFQTU5OEM3NzQzQUQ5QjBCNzMyOERFRDg1QjA2KQ==") - .toString(Charset.defaultCharset()) - .removeSurrounding("(", ")") - } - certKey = cert.certificateKey - baseUrl = cert.baseUrl.removeSuffix("/") - privateKey = getPrivateKeyFromCert(privateKeyValue, cert.certificatePfx) - - return serviceManager.getRegisterRepository(cert.baseUrl).getStudents().map { - it.copy().apply { - certificateKey = this@Mobile.certKey - privateKey = this@Mobile.privateKey - mobileBaseUrl = this@Mobile.baseUrl - } - } - } - - suspend fun getStudents(): List { - return serviceManager.getRegisterRepository(baseUrl).getStudents() - } - - suspend fun getAttendance(start: LocalDate, end: LocalDate, classificationPeriodId: Int): List { - return mobile.getAttendance(start, end, classId, classificationPeriodId, studentId) - } - - suspend fun getExams(start: LocalDate, end: LocalDate, classificationPeriodId: Int): List { - return mobile.getExams(start, end, classId, classificationPeriodId, studentId) - } - - suspend fun getGrades(classificationPeriodId: Int): Pair, GradesSummaryResponse> { - return getGradesDetails(classificationPeriodId) to getGradesSummary(classificationPeriodId) - } - - suspend fun getGradesDetails(classificationPeriodId: Int): List { - return mobile.getGradesDetails(classId, classificationPeriodId, studentId) - } - - suspend fun getGradesSummary(classificationPeriodId: Int): GradesSummaryResponse { - return mobile.getGradesSummary(classId, classificationPeriodId, studentId) - } - - suspend fun getHomework(start: LocalDate, end: LocalDate, classificationPeriodId: Int): List { - return mobile.getHomework(start, end, classId, classificationPeriodId, studentId) - } - - suspend fun getNotes(classificationPeriodId: Int): List { - return mobile.getNotes(classificationPeriodId, studentId) - } - - suspend fun getTeachers(studentId: Int, semesterId: Int): List { - return mobile.getTeachers(studentId, semesterId) - } - - suspend fun getMessages(start: LocalDateTime, end: LocalDateTime): List { - return mobile.getMessages(start, end, loginId, studentId) - } - - suspend fun getMessagesSent(start: LocalDateTime, end: LocalDateTime): List { - return mobile.getMessagesSent(start, end, loginId, studentId) - } - - suspend fun getMessagesDeleted(start: LocalDateTime, end: LocalDateTime): List { - return mobile.getMessagesDeleted(start, end, loginId, studentId) - } - - suspend fun changeMessageStatus(messageId: String, folder: String, status: String): String { - return mobile.changeMessageStatus(messageId, folder, status, loginId, studentId) - } - - suspend fun sendMessage(subject: String, content: String, recipients: List): Message { - val sender = getStudents().singleOrNull { it.loginId == loginId }?.name.orEmpty() - return mobile.sendMessage(sender, subject, content, recipients, loginId, studentId) - } - - suspend fun getTimetable(start: LocalDate, end: LocalDate, classificationPeriodId: Int): List { - return mobile.getTimetable(start, end, classId, classificationPeriodId, studentId) - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ResettableLazyManager.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ResettableLazyManager.kt deleted file mode 100644 index 0a66f3ad..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/ResettableLazyManager.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import java.util.LinkedList -import kotlin.reflect.KProperty - -/** - * see https://stackoverflow.com/a/35757638/6695449 - */ -class ResettableLazyManager { - // we synchronize to make sure the timing of a reset() call and new inits do not collide - val managedDelegates = LinkedList() - - fun register(managed: Resettable) { - synchronized(managedDelegates) { - managedDelegates.add(managed) - } - } - - fun reset() { - synchronized(managedDelegates) { - managedDelegates.forEach { it.reset() } - managedDelegates.clear() - } - } -} - -interface Resettable { - fun reset() -} - -class ResettableLazy(val manager: ResettableLazyManager, val init: () -> PROPTYPE) : Resettable { - @Volatile - var lazyHolder = makeInitBlock() - - operator fun getValue(thisRef: Any?, property: KProperty<*>): PROPTYPE { - return lazyHolder.value - } - - override fun reset() { - lazyHolder = makeInitBlock() - } - - fun makeInitBlock(): Lazy { - return lazy { - manager.register(this) - init() - } - } -} - -fun resettableLazy(manager: ResettableLazyManager, init: () -> PROPTYPE): ResettableLazy { - return ResettableLazy(manager, init) -} - -fun resettableManager(): ResettableLazyManager = ResettableLazyManager() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Utils.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Utils.kt deleted file mode 100644 index 4d2e4527..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/Utils.kt +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.format.DateTimeFormatter.ofPattern - -fun LocalDate.toFormat(): String = format(ofPattern("yyyy-MM-dd")) - -fun LocalDateTime.toFormat(): String = format(ofPattern("yyyy-MM-dd")) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/Attendance.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/Attendance.kt deleted file mode 100644 index c97f7092..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/Attendance.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.attendance - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Attendance( - - @Json(name = "IdKategoria") - val categoryId: Int, - - @Json(name = "Numer") - val number: Int, - - @Json(name = "IdPoraLekcji") - val lessonTimeId: Int, - - @Json(name = "Dzien") - val date: Long, - - @Json(name = "DzienTekst") - val dateText: String, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "PrzedmiotNazwa") - val subjectName: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceRequest.kt deleted file mode 100644 index 64dc8c43..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceRequest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.attendance - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class AttendanceRequest( - - @Json(name = "DataPoczatkowa") - val startDate: String, - - @Json(name = "DataKoncowa") - val endDate: String, - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceResponse.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceResponse.kt deleted file mode 100644 index 4b989a0c..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/attendance/AttendanceResponse.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.attendance - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class AttendanceResponse( - - @Json(name = "DataPoczatkowa") - val dateStart: Long, - - @Json(name = "DataPoczatkowaTekst") - val dateStartText: String, - - @Json(name = "DataKoncowa") - val dateEnd: Long, - - @Json(name = "DataKoncowaTekst") - val dateEndText: String, - - @Json(name = "Frekwencje") - val items: List, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceCategory.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceCategory.kt deleted file mode 100644 index ae5ac0b5..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceCategory.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class AttendanceCategory( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Nazwa") - val name: String, - - @Json(name = "Pozycja") - val position: Int, - - @Json(name = "Obecnosc") - val presence: Boolean, - - @Json(name = "Nieobecnosc") - val absence: Boolean, - - @Json(name = "Zwolnienie") - val exemption: Boolean, - - @Json(name = "Spoznienie") - val lateness: Boolean, - - @Json(name = "Usprawiedliwione") - val excused: Boolean, - - @Json(name = "Usuniete") - val deleted: Boolean, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceType.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceType.kt deleted file mode 100644 index d19042dd..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/AttendanceType.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class AttendanceType( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Symbol") - val symbol: String, - - @Json(name = "Nazwa") - val name: String, - - @Json(name = "Aktywny") - val active: Boolean, - - @Json(name = "WpisDomyslny") - val defaultEntry: Boolean, - - @Json(name = "IdKategoriaFrek") - val categoryId: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Dictionaries.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Dictionaries.kt deleted file mode 100644 index 6983bc98..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Dictionaries.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Dictionaries( - - @Json(name = "TimeKey") - val timeKey: Long, - - @Json(name = "Nauczyciele") - val teachers: List, - - @Json(name = "Pracownicy") - val employees: List, - - @Json(name = "Przedmioty") - val subjects: List, - - @Json(name = "PoryLekcji") - val lessonTimes: List, - - @Json(name = "KategorieOcen") - val gradeCategories: List, - - @Json(name = "KategorieUwag") - val noteCategories: List, - - @Json(name = "KategorieFrekwencji") - val attendanceCategories: List, - - @Json(name = "TypyFrekwencji") - val attendanceTypes: List, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/DictionariesRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/DictionariesRequest.kt deleted file mode 100644 index aba707a3..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/DictionariesRequest.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class DictionariesRequest( - - @Json(name = "IdUczen") - val userId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdOddzial") - val classId: Int, - -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Employee.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Employee.kt deleted file mode 100644 index 56d9fb97..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Employee.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Employee( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Imie") - val name: String, - - @Json(name = "Nazwisko") - val surname: String, - - @Json(name = "Kod") - val code: String, - - @Json(name = "Aktywny") - val active: Boolean, - - @Json(name = "Nauczyciel") - val teacher: Boolean, - - @Json(name = "LoginId") - val loginId: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/GradeCategory.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/GradeCategory.kt deleted file mode 100644 index 315f74a8..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/GradeCategory.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class GradeCategory( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Kod") - val code: String, - - @Json(name = "Nazwa") - val name: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/LessonTime.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/LessonTime.kt deleted file mode 100644 index 036ba1d1..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/LessonTime.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class LessonTime( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Numer") - val number: Int, - - @Json(name = "Poczatek") - val start: Long, - - @Json(name = "PoczatekTekst") - val startText: String, - - @Json(name = "Koniec") - val end: Long, - - @Json(name = "KoniecTekst") - val endText: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/NoteCategory.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/NoteCategory.kt deleted file mode 100644 index 4a257778..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/NoteCategory.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class NoteCategory( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Nazwa") - val name: String, - - @Json(name = "Aktywny") - val isActive: Boolean, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Subject.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Subject.kt deleted file mode 100644 index d051f023..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Subject.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Subject( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Nazwa") - val name: String, - - @Json(name = "Kod") - val code: String, - - @Json(name = "Aktywny") - val active: Boolean, - - @Json(name = "Pozycja") - val position: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Teacher.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Teacher.kt deleted file mode 100644 index 42bd92f5..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/dictionaries/Teacher.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.dictionaries - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Teacher( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Imie") - val name: String, - - @Json(name = "Nazwisko") - val surname: String, - - @Json(name = "Kod") - val code: String, - - @Json(name = "Aktywny") - val active: Boolean, - - @Json(name = "Nauczyciel") - val teacher: Boolean, - - @Json(name = "LoginId") - val loginId: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/Exam.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/Exam.kt deleted file mode 100644 index 3ce9aa87..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/Exam.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exams - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Exam( - - @Json(name = "Id") - val id: Int, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "IdPracownik") - val employeeId: Int, - - @Json(name = "IdOddzial") - val classId: Int?, - - @Json(name = "IdPodzial") - val divideId: Int?, - - @Json(name = "PodzialNazwa") - val divideName: String?, - - @Json(name = "Rodzaj") - val type: Boolean, // false - quiz, true - test - - @Json(name = "RodzajNumer") - val typeNumber: Int, - - @Json(name = "Opis") - val description: String, - - @Json(name = "Data") - val date: Long, - - @Json(name = "DataTekst") - val dateText: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsRequest.kt deleted file mode 100644 index ed2976f3..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsRequest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exams - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class ExamsRequest( - - @Json(name = "DataPoczatkowa") - val startDate: String, - - @Json(name = "DataKoncowa") - val endDate: String, - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidPinException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidPinException.kt deleted file mode 100644 index ae6699ee..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidPinException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -import java.io.IOException - -class InvalidPinException(message: String) : IOException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidSymbolException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidSymbolException.kt deleted file mode 100644 index c0af2057..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidSymbolException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -import java.io.IOException - -class InvalidSymbolException : IOException() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidTokenException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidTokenException.kt deleted file mode 100644 index df19f435..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/InvalidTokenException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -import java.io.IOException - -open class InvalidTokenException internal constructor(message: String) : IOException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/NoStudentsException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/NoStudentsException.kt deleted file mode 100644 index 75c82c02..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/NoStudentsException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -import java.io.IOException - -class NoStudentsException(message: String) : IOException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenDeadException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenDeadException.kt deleted file mode 100644 index 0ac94eec..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenDeadException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -class TokenDeadException(message: String) : InvalidTokenException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenNotFoundException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenNotFoundException.kt deleted file mode 100644 index 4f4fc00c..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/TokenNotFoundException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -class TokenNotFoundException(message: String) : InvalidTokenException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnknownTokenException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnknownTokenException.kt deleted file mode 100644 index bce57293..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnknownTokenException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -class UnknownTokenException(message: String) : InvalidTokenException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnsupportedTokenException.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnsupportedTokenException.kt deleted file mode 100644 index 29d14961..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/exception/UnsupportedTokenException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exception - -import java.io.IOException - -class UnsupportedTokenException(message: String) : IOException(message) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/Grade.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/Grade.kt deleted file mode 100644 index 95648147..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/Grade.kt +++ /dev/null @@ -1,68 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.grades - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Grade( - - @Json(name = "Id") - val id: Int, - - @Json(name = "Pozycja") - val position: Int, - - @Json(name = "PrzedmiotPozycja") - val subjectPosition: Int, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "IdKategoria") - val categoryId: Int, - - @Json(name = "Wpis") - val entry: String, - - @Json(name = "Wartosc") - val value: Double, - - @Json(name = "WagaModyfikatora") - val modificationWeight: Double?, - - @Json(name = "WagaOceny") - val gradeWeight: Double, - - @Json(name = "Licznik") - val counter: Double?, - - @Json(name = "Mianownik") - val denominator: Int?, - - @Json(name = "Komentarz") - val comment: String?, - - @Json(name = "Waga") - val weight: String, - - @Json(name = "Opis") - val description: String, - - @Json(name = "DataUtworzenia") - val creationDate: Long, - - @Json(name = "DataUtworzeniaTekst") - val creationDateText: String, - - @Json(name = "DataModyfikacji") - val modificationDate: Long, - - @Json(name = "DataModyfikacjiTekst") - val modificationDateText: String, - - @Json(name = "IdPracownikD") - val employeeIdD: Int, - - @Json(name = "IdPracownikM") - val employeeIdM: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradeSummary.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradeSummary.kt deleted file mode 100644 index 1ea0b9ca..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradeSummary.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.grades - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class GradeSummary( - - @Json(name = "IdPrzedmiot") - val subjectId: Int = 0, - - @Json(name = "Wpis") - val entry: String = "", - - @Json(name = "SredniaOcen") - val average: String = "0", - - @Json(name = "SumaPunktow") - val pointsSum: String = "", -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesRequest.kt deleted file mode 100644 index fe7807c4..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesRequest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.grades - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class GradesRequest( - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesSummaryResponse.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesSummaryResponse.kt deleted file mode 100644 index 6496ef56..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesSummaryResponse.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.grades - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class GradesSummaryResponse( - - @Json(name = "OcenyPrzewidywane") - val predicted: List, - - @Json(name = "OcenyKlasyfikacyjne") - val evaluative: List, - - @Json(name = "SrednieOcen") - val average: List, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/Homework.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/Homework.kt deleted file mode 100644 index 5010c16f..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/Homework.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.homework - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Homework( - - @Json(name = "Id") - val id: Int, - - @Json(name = "IdUczen") - val studentId: Int, - - @Json(name = "Data") - val date: Long, - - @Json(name = "DataTekst") - val dateText: String, - - @Json(name = "IdPracownik") - val employeeId: Int, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "Opis") - val content: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/HomeworkRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/HomeworkRequest.kt deleted file mode 100644 index ab0cd174..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/homework/HomeworkRequest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.homework - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class HomeworkRequest( - - @Json(name = "DataPoczatkowa") - val startDate: String, - - @Json(name = "DataKoncowa") - val endDate: String, - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptor.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptor.kt deleted file mode 100644 index 005a3849..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptor.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.interceptor - -import io.github.wulkanowy.sdk.mobile.exception.InvalidSymbolException -import okhttp3.Interceptor -import okhttp3.Response -import java.io.IOException - -class ErrorInterceptor : Interceptor { - - override fun intercept(chain: Interceptor.Chain): Response { - val response = chain.proceed(chain.request()) - val body = response.peekBody(Long.MAX_VALUE).string() - - when { - body == "Bad Request" -> throw IOException(body) - body.contains("Podany symbol grupujący jest nieprawidłowy") -> throw InvalidSymbolException() - } - - return response - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/SignInterceptor.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/SignInterceptor.kt deleted file mode 100644 index 90b221ae..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/SignInterceptor.kt +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.interceptor - -import io.github.wulkanowy.signer.signContent -import okhttp3.Interceptor -import okhttp3.Response -import okio.Buffer -import java.nio.charset.Charset - -class SignInterceptor( - private val privateKey: String, - private val certKey: String, -) : Interceptor { - - override fun intercept(chain: Interceptor.Chain): Response { - val original = chain.request() - val request = original.newBuilder() - - request.header("User-Agent", "MobileUserAgent") - - if (privateKey.isNotBlank()) { - val signature = Buffer().run { - original.body?.writeTo(this) - signContent(privateKey, readString(Charset.defaultCharset())) - } - - request.header("RequestCertificateKey", certKey) - request.header("RequestSignatureValue", signature) - } - - return chain.proceed(request.method(original.method, original.body).build()) - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Message.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Message.kt deleted file mode 100644 index 55b5a171..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Message.kt +++ /dev/null @@ -1,56 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.messages - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Message( - - @Json(name = "WiadomoscId") - val messageId: Int, - - @Json(name = "Nadawca") - val senderName: String?, - - @Json(name = "NadawcaId") - val senderId: Int, - - @Json(name = "Adresaci") - val recipients: List?, - - @Json(name = "Tytul") - val subject: String, - - @Json(name = "Tresc") - val content: String, - - @Json(name = "DataWyslania") - val sentDate: String, - - @Json(name = "DataWyslaniaUnixEpoch") - val sentDateTime: Long, - - @Json(name = "GodzinaWyslania") - val sentHour: String, - - @Json(name = "DataPrzeczytania") - val readDate: String?, - - @Json(name = "DataPrzeczytaniaUnixEpoch") - val readDateTime: Long?, - - @Json(name = "GodzinaPrzeczytania") - val readHour: String?, - - @Json(name = "StatusWiadomosci") - val status: String, - - @Json(name = "FolderWiadomosci") - val folder: String, - - @Json(name = "Nieprzeczytane") - val unread: String?, - - @Json(name = "Przeczytane") - val read: String?, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessageStatusChangeRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessageStatusChangeRequest.kt deleted file mode 100644 index 9c7d8812..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessageStatusChangeRequest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.messages - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class MessageStatusChangeRequest( - - @Json(name = "WiadomoscId") - val messageId: Int, - - @Json(name = "FolderWiadomosci") - val folder: String, - - @Json(name = "Status") - val status: String, - - @Json(name = "LoginId") - val loginId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessagesRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessagesRequest.kt deleted file mode 100644 index c9f98218..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/MessagesRequest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.messages - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class MessagesRequest( - - @Json(name = "DataPoczatkowa") - val startDate: String, - - @Json(name = "DataKoncowa") - val endDate: String, - - @Json(name = "LoginId") - val loginId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Recipient.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Recipient.kt deleted file mode 100644 index b4364ef2..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/Recipient.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.messages - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Recipient( - - @Json(name = "LoginId") - val loginId: Int, - - @Json(name = "Nazwa") - val name: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/SendMessageRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/SendMessageRequest.kt deleted file mode 100644 index b6e86718..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/messages/SendMessageRequest.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.messages - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class SendMessageRequest( - - @Json(name = "NadawcaWiadomosci") - val sender: String, - - @Json(name = "Tytul") - val subject: String, - - @Json(name = "Tresc") - val content: String, - - @Json(name = "Adresaci") - val recipients: List, - - @Json(name = "LoginId") - val loginId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/Note.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/Note.kt deleted file mode 100644 index 33ddebd6..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/Note.kt +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.notes - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Note( - - @Json(name = "Id") - val id: Int, - - @Json(name = "IdKategoriaUwag") - val noteCategoryId: Int, - - @Json(name = "IdUczen") - val studentId: Int, - - @Json(name = "UczenImie") - val studentName: String, - - @Json(name = "UczenNazwisko") - val studentSurname: String, - - @Json(name = "IdPracownik") - val employeeId: Int, - - @Json(name = "PracownikImie") - val employeeName: String, - - @Json(name = "PracownikNazwisko") - val employeeSurname: String, - - @Json(name = "DataWpisu") - val entryDate: Long, - - @Json(name = "DataWpisuTekst") - val entryDateText: String, - - @Json(name = "DataModyfikacji") - val modificationDate: Long?, - - @Json(name = "DataModyfikacjiTekst") - val modificationDateText: String?, - - @Json(name = "UwagaKey") - val noteKey: String, - - @Json(name = "TrescUwagi") - val content: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/NotesRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/NotesRequest.kt deleted file mode 100644 index 83299971..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/notes/NotesRequest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.notes - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class NotesRequest( - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateRequest.kt deleted file mode 100644 index 2ccae7f2..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateRequest.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.register - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest -import java.util.UUID - -@JsonClass(generateAdapter = true) -data class CertificateRequest( - - @Json(name = "PIN") - val pin: String, - - @Json(name = "TokenKey") - val tokenKey: String, - - @Json(name = "AppVersion") - val appVersion: String = MOBILE_APP_VERSION, - - @Json(name = "DeviceId") - val deviceId: String = UUID.randomUUID().toString(), - - @Json(name = "DeviceName") - val deviceName: String, - - @Json(name = "DeviceNameUser") - val deviceNameUser: String = "", - - @Json(name = "DeviceDescription") - val deviceDescription: String = "", - - @Json(name = "DeviceSystemType") - val deviceSystemType: String = "Android", - - @Json(name = "DeviceSystemVersion") - val deviceSystemVersion: String = "8.1.0", - - @Json(name = "FirebaseTokenKey") - val firebaseToken: String, - -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateResponse.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateResponse.kt deleted file mode 100644 index a8e93166..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/CertificateResponse.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.register - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class CertificateResponse( - - @Json(name = "IsError") - val isError: Boolean, - - @Json(name = "IsMessageForUser") - val isMessageForUser: Boolean, - - @Json(name = "Message") - val message: String?, - - @Json(name = "TokenKey") - val tokenKey: String?, - - @Json(name = "TokenStatus") - val tokenStatus: String?, - - @Json(name = "TokenCert") - val tokenCert: TokenCert?, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/Student.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/Student.kt deleted file mode 100644 index 7a01f00a..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/Student.kt +++ /dev/null @@ -1,102 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.register - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Student( - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "OkresPoziom") - val periodLevel: Int, - - @Json(name = "OkresNumer") - val periodNumber: Int, - - @Json(name = "OkresDataOd") - val periodDateFrom: Long, - - @Json(name = "OkresDataDo") - val periodDateTo: Long, - - @Json(name = "OkresDataOdTekst") - val periodDateFromText: String, - - @Json(name = "OkresDataDoTekst") - val periodDateToText: String, - - @Json(name = "IdJednostkaSprawozdawcza") - val reportingUnitId: Int, - - @Json(name = "JednostkaSprawozdawczaSkrot") - val reportingUnitShortcut: String, - - @Json(name = "JednostkaSprawozdawczaNazwa") - val reportingUnitName: String, - - @Json(name = "JednostkaSprawozdawczaSymbol") - val reportingUnitSymbol: String, - - @Json(name = "IdJednostka") - val unitId: Int, - - @Json(name = "JednostkaNazwa") - val unitName: String, - - @Json(name = "JednostkaSkrot") - val unitShortcut: String, - - @Json(name = "OddzialSymbol") - val classSymbol: String, - - @Json(name = "OddzialKod") - val classCode: String?, - - @Json(name = "UzytkownikRola") - val userRole: String, - - @Json(name = "UzytkownikLogin") - val userLogin: String, - - @Json(name = "UzytkownikLoginId") - val userLoginId: Int, - - @Json(name = "UzytkownikNazwa") - val userName: String, - - @Json(name = "Id") - val id: Int, - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "Imie") - val name: String, - - @Json(name = "Imie2") - val nameSecond: String?, - - @Json(name = "Nazwisko") - val surname: String, - - @Json(name = "Pseudonim") - val nick: String?, - - @Json(name = "UczenPlec") - val pupilGender: Int, - - @Json(name = "Pozycja") - val position: Int, - - @Json(name = "LoginId") - val loginId: Int?, -) { - - var privateKey = "" - - var certificateKey = "" - - var mobileBaseUrl = "" -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/TokenCert.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/TokenCert.kt deleted file mode 100644 index e0648c17..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/register/TokenCert.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.register - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class TokenCert( - - @Json(name = "CertyfikatKlucz") - val certificateKey: String, - - @Json(name = "CertyfikatKluczSformatowanyTekst") - val certificateKeyFormatted: String, - - @Json(name = "CertyfikatDataUtworzenia") - val certificateCreatedDate: Int, - - @Json(name = "CertyfikatDataUtworzeniaSformatowanyTekst") - val certificateCreatedDateText: String, - - @Json(name = "CertyfikatPfx") - val certificatePfx: String, - - @Json(name = "GrupaKlientow") - val symbol: String, - - @Json(name = "AdresBazowyRestApi") - val baseUrl: String, - - @Json(name = "UzytkownikLogin") - val userLogin: String, - - @Json(name = "UzytkownikNazwa") - val userName: String, - - @Json(name = "TypKonta") - val accountType: String?, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/MobileRepository.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/MobileRepository.kt deleted file mode 100644 index b38993ec..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/MobileRepository.kt +++ /dev/null @@ -1,101 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.repository - -import io.github.wulkanowy.sdk.mobile.ApiRequest -import io.github.wulkanowy.sdk.mobile.ApiResponse -import io.github.wulkanowy.sdk.mobile.attendance.Attendance -import io.github.wulkanowy.sdk.mobile.attendance.AttendanceRequest -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries -import io.github.wulkanowy.sdk.mobile.dictionaries.DictionariesRequest -import io.github.wulkanowy.sdk.mobile.exams.Exam -import io.github.wulkanowy.sdk.mobile.exams.ExamsRequest -import io.github.wulkanowy.sdk.mobile.grades.Grade -import io.github.wulkanowy.sdk.mobile.grades.GradesRequest -import io.github.wulkanowy.sdk.mobile.grades.GradesSummaryResponse -import io.github.wulkanowy.sdk.mobile.homework.Homework -import io.github.wulkanowy.sdk.mobile.homework.HomeworkRequest -import io.github.wulkanowy.sdk.mobile.messages.Message -import io.github.wulkanowy.sdk.mobile.messages.MessageStatusChangeRequest -import io.github.wulkanowy.sdk.mobile.messages.MessagesRequest -import io.github.wulkanowy.sdk.mobile.messages.Recipient -import io.github.wulkanowy.sdk.mobile.messages.SendMessageRequest -import io.github.wulkanowy.sdk.mobile.notes.Note -import io.github.wulkanowy.sdk.mobile.notes.NotesRequest -import io.github.wulkanowy.sdk.mobile.school.Teacher -import io.github.wulkanowy.sdk.mobile.school.TeachersRequest -import io.github.wulkanowy.sdk.mobile.service.MobileService -import io.github.wulkanowy.sdk.mobile.timetable.Lesson -import io.github.wulkanowy.sdk.mobile.timetable.TimetableRequest -import io.github.wulkanowy.sdk.mobile.toFormat -import java.time.LocalDate -import java.time.LocalDateTime - -class MobileRepository(private val api: MobileService) { - - suspend fun logStart(): ApiResponse = api.logAppStart(ApiRequest()) - - suspend fun getDictionaries(userId: Int, classificationPeriodId: Int, classId: Int): Dictionaries { - return api.getDictionaries(DictionariesRequest(userId, classificationPeriodId, classId)).data!! - } - - suspend fun getTeachers(studentId: Int, semesterId: Int): List { - return api.getTeachers(TeachersRequest(studentId, semesterId)).data.let { - it?.schoolTeachers.orEmpty().union(it?.teachersSubjects.orEmpty()).toList() - } - } - - suspend fun getTimetable(start: LocalDate, end: LocalDate, classId: Int, classificationPeriodId: Int, studentId: Int): List { - return api.getTimetable(TimetableRequest(start.toFormat(), end.toFormat(), classId, classificationPeriodId, studentId)).data!! - } - - suspend fun getGradesDetails(classId: Int, classificationPeriodId: Int, studentId: Int): List { - return api.getGrades(GradesRequest(classId, classificationPeriodId, studentId)).data!! - } - - suspend fun getGradesSummary(classId: Int, classificationPeriodId: Int, studentId: Int): GradesSummaryResponse { - return api.getGradesSummary(GradesRequest(classId, classificationPeriodId, studentId)).data!! - } - - suspend fun getExams(start: LocalDate, end: LocalDate, classId: Int, classificationPeriodId: Int, studentId: Int): List { - return api.getExams(ExamsRequest(start.toFormat(), end.toFormat(), classId, classificationPeriodId, studentId)).data!! - } - - suspend fun getNotes(classificationPeriodId: Int, studentId: Int): List { - return api.getNotes(NotesRequest(classificationPeriodId, studentId)).data!! - } - - suspend fun getAttendance(start: LocalDate, end: LocalDate, classId: Int, classificationPeriodId: Int, studentId: Int): List { - return api.getAttendance(AttendanceRequest(start.toFormat(), end.toFormat(), classId, classificationPeriodId, studentId)).data!!.items - } - - suspend fun getHomework(start: LocalDate, end: LocalDate, classId: Int, classificationPeriodId: Int, studentId: Int): List { - return api.getHomework(HomeworkRequest(start.toFormat(), end.toFormat(), classId, classificationPeriodId, studentId)).data!! - } - - suspend fun getMessages(start: LocalDateTime, end: LocalDateTime, loginId: Int, studentId: Int): List { - return api.getMessages(MessagesRequest(start.toFormat(), end.toFormat(), loginId, studentId)).data!! - } - - suspend fun getMessagesDeleted(start: LocalDateTime, end: LocalDateTime, loginId: Int, studentId: Int): List { - return api.getMessagesDeleted(MessagesRequest(start.toFormat(), end.toFormat(), loginId, studentId)).data!! - } - - suspend fun getMessagesSent(start: LocalDateTime, end: LocalDateTime, loginId: Int, studentId: Int): List { - return api.getMessagesSent(MessagesRequest(start.toFormat(), end.toFormat(), loginId, studentId)).data!! - } - - suspend fun changeMessageStatus(messageId: String, folder: String, status: String, loginId: Int, studentId: Int): String { - return api.changeMessageStatus(MessageStatusChangeRequest(messageId.toInt(), folder, status, loginId, studentId)).data!! - } - - suspend fun sendMessage(sender: String, subject: String, content: String, recipients: List, loginId: Int, studentId: Int): Message { - val request = SendMessageRequest( - sender = sender, - subject = subject, - content = content, - recipients = recipients, - loginId = loginId, - studentId = studentId, - ) - return api.sendMessage(request) - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RegisterRepository.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RegisterRepository.kt deleted file mode 100644 index ca4c85b4..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RegisterRepository.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.repository - -import io.github.wulkanowy.sdk.mobile.ApiRequest -import io.github.wulkanowy.sdk.mobile.register.CertificateRequest -import io.github.wulkanowy.sdk.mobile.register.CertificateResponse -import io.github.wulkanowy.sdk.mobile.register.Student -import io.github.wulkanowy.sdk.mobile.service.RegisterService - -class RegisterRepository(private val api: RegisterService) { - - suspend fun getCertificate(token: String, pin: String, deviceName: String, android: String, firebaseToken: String): CertificateResponse { - val request = CertificateRequest( - tokenKey = token, - pin = pin, - deviceName = "$deviceName (Wulkanowy)", - deviceSystemVersion = android, - firebaseToken = firebaseToken, - ) - return api.getCertificate(request) - } - - suspend fun getStudents(): List = api.getPupils(object : ApiRequest() {}).data.orEmpty() -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RepositoryManager.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RepositoryManager.kt deleted file mode 100644 index 3406f281..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RepositoryManager.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.repository - -import io.github.wulkanowy.sdk.mobile.interceptor.ErrorInterceptor -import io.github.wulkanowy.sdk.mobile.interceptor.SignInterceptor -import okhttp3.Interceptor -import okhttp3.OkHttpClient -import okhttp3.logging.HttpLoggingInterceptor -import retrofit2.Retrofit -import retrofit2.converter.moshi.MoshiConverterFactory -import retrofit2.converter.scalars.ScalarsConverterFactory -import retrofit2.create - -class RepositoryManager( - private val logLevel: HttpLoggingInterceptor.Level, - private val privateKey: String, - private val certKey: String, - private val interceptors: MutableList>, - private val baseUrl: String, - private val schoolSymbol: String, -) { - - fun getRoutesRepository(): RoutingRulesRepository { - return RoutingRulesRepository(getRetrofitBuilder(interceptors).baseUrl("http://komponenty.vulcan.net.pl").build().create()) - } - - fun getMobileRepository(): MobileRepository { - return MobileRepository(getRetrofitBuilder(interceptors).baseUrl("$baseUrl/$schoolSymbol/mobile-api/Uczen.v3.Uczen/").build().create()) - } - - fun getRegisterRepository(baseUrl: String, symbol: String) = getRegisterRepository("${baseUrl.removeSuffix("/")}/$symbol") - - fun getRegisterRepository(baseUrl: String): RegisterRepository { - return RegisterRepository(getRetrofitBuilder(interceptors).baseUrl("${baseUrl.removeSuffix("/")}/mobile-api/Uczen.v3.UczenStart/").build().create()) - } - - private fun getRetrofitBuilder(interceptors: MutableList>): Retrofit.Builder { - return Retrofit.Builder() - .addConverterFactory(ScalarsConverterFactory.create()) - .addConverterFactory(MoshiConverterFactory.create()) - .client( - OkHttpClient().newBuilder() - .addInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) - .addInterceptor(ErrorInterceptor()) - .addInterceptor(SignInterceptor(privateKey, certKey)) - .apply { - interceptors.forEach { - if (it.second) { - addNetworkInterceptor(it.first) - } else addInterceptor(it.first) - } - } - .build(), - ) - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepository.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepository.kt deleted file mode 100644 index 86d7878d..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepository.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.repository - -import io.github.wulkanowy.sdk.mobile.exception.InvalidTokenException -import io.github.wulkanowy.sdk.mobile.exception.UnknownTokenException -import io.github.wulkanowy.sdk.mobile.service.RoutingRulesService - -class RoutingRulesRepository(private val api: RoutingRulesService) { - - suspend fun getRouteByToken(token: String): String { - if (token.length < 4) throw InvalidTokenException("Token '$token' is too short") - - val tokenSymbol = token.substring(0..2) - - if ("FK1" == tokenSymbol) return "https://api.fakelog.tk" - - return api.getRoutingRules().split("\r?\n".toRegex()) - .singleOrNull { tokenSymbol == it.substringBefore(",") } - ?.substringAfter(",") - ?: throw UnknownTokenException("This token: '$token' is unsupported") - } -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/Teacher.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/Teacher.kt deleted file mode 100644 index 5d986c2a..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/Teacher.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.school - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Teacher( - - @Json(name = "IdPracownik") - val employeeId: Int, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "Rola") - val role: String, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersRequest.kt deleted file mode 100644 index 438ca5b3..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersRequest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.school - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -class TeachersRequest( - - @Json(name = "IdUczen") - val studentId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val semesterId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersResponse.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersResponse.kt deleted file mode 100644 index 2746b36e..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/school/TeachersResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.school - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class TeachersResponse( - - @Json(name = "NauczycieleSzkola") - val schoolTeachers: List, - - @Json(name = "NauczycielePrzedmioty") - val teachersSubjects: List, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/MobileService.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/MobileService.kt deleted file mode 100644 index 034dc52f..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/MobileService.kt +++ /dev/null @@ -1,75 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.service - -import io.github.wulkanowy.sdk.mobile.ApiRequest -import io.github.wulkanowy.sdk.mobile.ApiResponse -import io.github.wulkanowy.sdk.mobile.attendance.AttendanceRequest -import io.github.wulkanowy.sdk.mobile.attendance.AttendanceResponse -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries -import io.github.wulkanowy.sdk.mobile.dictionaries.DictionariesRequest -import io.github.wulkanowy.sdk.mobile.exams.Exam -import io.github.wulkanowy.sdk.mobile.exams.ExamsRequest -import io.github.wulkanowy.sdk.mobile.grades.Grade -import io.github.wulkanowy.sdk.mobile.grades.GradesRequest -import io.github.wulkanowy.sdk.mobile.grades.GradesSummaryResponse -import io.github.wulkanowy.sdk.mobile.homework.Homework -import io.github.wulkanowy.sdk.mobile.homework.HomeworkRequest -import io.github.wulkanowy.sdk.mobile.messages.Message -import io.github.wulkanowy.sdk.mobile.messages.MessageStatusChangeRequest -import io.github.wulkanowy.sdk.mobile.messages.MessagesRequest -import io.github.wulkanowy.sdk.mobile.messages.SendMessageRequest -import io.github.wulkanowy.sdk.mobile.notes.Note -import io.github.wulkanowy.sdk.mobile.notes.NotesRequest -import io.github.wulkanowy.sdk.mobile.school.TeachersRequest -import io.github.wulkanowy.sdk.mobile.school.TeachersResponse -import io.github.wulkanowy.sdk.mobile.timetable.Lesson -import io.github.wulkanowy.sdk.mobile.timetable.TimetableRequest -import retrofit2.http.Body -import retrofit2.http.POST - -interface MobileService { - - @POST("LogAppStart") - suspend fun logAppStart(@Body logAppStartRequest: ApiRequest): ApiResponse - - @POST("Slowniki") - suspend fun getDictionaries(@Body dictionariesRequest: DictionariesRequest): ApiResponse - - @POST("Nauczyciele") - suspend fun getTeachers(@Body teachersRequest: TeachersRequest): ApiResponse - - @POST("PlanLekcjiZeZmianami") - suspend fun getTimetable(@Body timetableRequest: TimetableRequest): ApiResponse> - - @POST("Oceny") - suspend fun getGrades(@Body gradesRequest: GradesRequest): ApiResponse> - - @POST("OcenyPodsumowanie") - suspend fun getGradesSummary(@Body gradesRequest: GradesRequest): ApiResponse - - @POST("Sprawdziany") - suspend fun getExams(@Body examsRequest: ExamsRequest): ApiResponse> - - @POST("UwagiUcznia") - suspend fun getNotes(@Body notesRequest: NotesRequest): ApiResponse> - - @POST("Frekwencje") - suspend fun getAttendance(@Body attendanceRequest: AttendanceRequest): ApiResponse - - @POST("ZadaniaDomowe") - suspend fun getHomework(@Body homeworkRequest: HomeworkRequest): ApiResponse> - - @POST("WiadomosciOdebrane") - suspend fun getMessages(@Body messagesRequest: MessagesRequest): ApiResponse> - - @POST("WiadomosciWyslane") - suspend fun getMessagesSent(@Body messagesRequest: MessagesRequest): ApiResponse> - - @POST("WiadomosciUsuniete") - suspend fun getMessagesDeleted(@Body messagesRequest: MessagesRequest): ApiResponse> - - @POST("ZmienStatusWiadomosci") - suspend fun changeMessageStatus(@Body messageStatusChangeRequest: MessageStatusChangeRequest): ApiResponse - - @POST("DodajWiadomosc") - suspend fun sendMessage(@Body sendMessageRequest: SendMessageRequest): Message -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RegisterService.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RegisterService.kt deleted file mode 100644 index 58cfe769..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RegisterService.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.service - -import io.github.wulkanowy.sdk.mobile.ApiRequest -import io.github.wulkanowy.sdk.mobile.ApiResponse -import io.github.wulkanowy.sdk.mobile.register.CertificateRequest -import io.github.wulkanowy.sdk.mobile.register.CertificateResponse -import io.github.wulkanowy.sdk.mobile.register.Student -import retrofit2.http.Body -import retrofit2.http.Headers -import retrofit2.http.POST - -interface RegisterService { - - @POST("Certyfikat") - @Headers("RequestMobileType: RegisterDevice") - suspend fun getCertificate(@Body certificateRequest: CertificateRequest): CertificateResponse - - @POST("ListaUczniow") - suspend fun getPupils(@Body pupilsListRequest: ApiRequest): ApiResponse> -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RoutingRulesService.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RoutingRulesService.kt deleted file mode 100644 index 98428784..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/service/RoutingRulesService.kt +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.service - -import retrofit2.http.GET - -interface RoutingRulesService { - - @GET("/UonetPlusMobile/RoutingRules.txt") - suspend fun getRoutingRules(): String -} diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/Lesson.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/Lesson.kt deleted file mode 100644 index 41f8d273..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/Lesson.kt +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.timetable - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class Lesson( - - @Json(name = "Dzien") - val day: Long, - - @Json(name = "DzienTekst") - val dayText: String, - - @Json(name = "NumerLekcji") - val lessonNumber: Int, - - @Json(name = "IdPoraLekcji") - val lessonTimeId: Int, - - @Json(name = "IdPrzedmiot") - val subjectId: Int, - - @Json(name = "PrzedmiotNazwa") - val subjectName: String, - - @Json(name = "PodzialSkrot") - val divisionShort: String?, - - @Json(name = "Sala") - val room: String?, - - @Json(name = "IdPracownik") - val employeeId: Int, - - @Json(name = "IdPracownikWspomagajacy") - val employeeSupporterId: Int?, - - @Json(name = "IdPracownikOld") - val employeeOldId: Int?, - - @Json(name = "IdPracownikWspomagajacyOld") - val employeeSupporterOldId: Int?, - - @Json(name = "IdPlanLekcji") - val timetableId: Int, - - @Json(name = "AdnotacjaOZmianie") - val annotationAboutChange: String?, - - @Json(name = "PrzekreslonaNazwa") - val overriddenName: Boolean, - - @Json(name = "PogrubionaNazwa") - val boldName: Boolean, - - @Json(name = "PlanUcznia") - val studentPlan: Boolean, -) diff --git a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableRequest.kt b/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableRequest.kt deleted file mode 100644 index a603661f..00000000 --- a/sdk-mobile/src/main/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableRequest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.timetable - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import io.github.wulkanowy.sdk.mobile.ApiRequest - -@JsonClass(generateAdapter = true) -data class TimetableRequest( - - @Json(name = "DataPoczatkowa") - val startDate: String, - - @Json(name = "DataKoncowa") - val endDate: String, - - @Json(name = "IdOddzial") - val classId: Int, - - @Json(name = "IdOkresKlasyfikacyjny") - val classificationPeriodId: Int, - - @Json(name = "IdUczen") - val studentId: Int, -) : ApiRequest() diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/BaseLocalTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/BaseLocalTest.kt deleted file mode 100644 index 4d62af4b..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/BaseLocalTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import io.github.wulkanowy.sdk.mobile.interceptor.ErrorInterceptor -import okhttp3.OkHttpClient -import okhttp3.logging.HttpLoggingInterceptor -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import org.junit.After -import retrofit2.Retrofit -import retrofit2.converter.moshi.MoshiConverterFactory -import retrofit2.converter.scalars.ScalarsConverterFactory - -open class BaseLocalTest { - - val server = MockWebServer() - - fun MockWebServer.enqueue(fileName: String, clazz: Class<*>) { - enqueue(MockResponse().setBody(clazz.getResource(fileName).readText())) - } - - fun MockWebServer.enqueueAndStart(fileName: String, clazz: Class<*> = this@BaseLocalTest.javaClass, port: Int = 3030) { - enqueue(fileName, clazz) - start(port) - } - - @After - fun tearDown() { - server.shutdown() - } - - fun getRetrofit(baseUrl: String = server.url("/").toString()): Retrofit = getRetrofitBuilder().baseUrl(baseUrl).build() - - fun getRetrofitBuilder(): Retrofit.Builder = Retrofit.Builder() - .addConverterFactory(ScalarsConverterFactory.create()) - .addConverterFactory(MoshiConverterFactory.create()) - .client( - OkHttpClient().newBuilder() - .addInterceptor(ErrorInterceptor()) - .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC)) - .build(), - ) -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/UonetTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/UonetTest.kt deleted file mode 100644 index 0099b076..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/UonetTest.kt +++ /dev/null @@ -1,124 +0,0 @@ -package io.github.wulkanowy.sdk.mobile - -import io.github.wulkanowy.sdk.mobile.interceptor.SignInterceptor -import io.github.wulkanowy.sdk.mobile.register.Student -import io.github.wulkanowy.sdk.mobile.repository.MobileRepository -import io.github.wulkanowy.sdk.mobile.repository.RegisterRepository -import io.github.wulkanowy.signer.getPrivateKeyFromCert -import junit.framework.TestCase.assertEquals -import kotlinx.coroutines.runBlocking -import okhttp3.OkHttpClient -import okhttp3.logging.HttpLoggingInterceptor -import org.junit.BeforeClass -import org.junit.Ignore -import org.junit.Test -import retrofit2.Retrofit -import retrofit2.converter.moshi.MoshiConverterFactory -import retrofit2.converter.scalars.ScalarsConverterFactory -import retrofit2.create -import java.time.LocalDate.of - -const val PASSWORD = "012345678901234567890123456789AB" -const val DEVICE_NAME = "Wulkanowy#client" -const val HOST = "https://api.fakelog.cf" -const val SYMBOL = "powiatwulkanowy" -const val TOKEN = "FK100000" -const val PIN = "999999" - -@Ignore -class UonetTest { - - companion object { - - private lateinit var mobile: MobileRepository - - private lateinit var student: Student - - private fun getRetrofitBuilder(privateKey: String, certKey: String): Retrofit.Builder { - return Retrofit.Builder() - .addConverterFactory(ScalarsConverterFactory.create()) - .addConverterFactory(MoshiConverterFactory.create()) - .client( - OkHttpClient().newBuilder() - .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC)) - .addInterceptor(SignInterceptor(privateKey, certKey)) - .build(), - ) - } - - @JvmStatic - @BeforeClass - fun setUp() { - // RegisterRepository - val register = RegisterRepository( - api = getRetrofitBuilder("", "") - .baseUrl("$HOST/$SYMBOL/mobile-api/Uczen.v3.UczenStart/") - .build().create(), - ) - - val certificate = runBlocking { register.getCertificate(TOKEN, PIN, DEVICE_NAME, "8.1.0", "") } - - assertEquals(false, certificate.isError) - - val tokenCrt = certificate.tokenCert - - val certKey = tokenCrt!!.certificateKey - val cert = tokenCrt.certificatePfx - - val privateKey = getPrivateKeyFromCert(PASSWORD, cert) - - val pupils = runBlocking { register.getStudents() } - assertEquals(2, pupils.size) - - student = pupils[0] - - // MobileRepository - mobile = MobileRepository( - api = getRetrofitBuilder(privateKey, certKey) - .baseUrl("$HOST/powiatwulkanowy/${student.reportingUnitSymbol}/mobile-api/Uczen.v3.Uczen/") - .build().create(), - ) - } - } - - @Test - fun logStartTest() { - val start = runBlocking { mobile.logStart() } - assertEquals("Ok", start.status) - } - - @Test - fun dictionariesTest() { - runBlocking { mobile.getDictionaries(student.userLoginId, student.classificationPeriodId, student.classId) } - } - - @Test - fun timetableTest() { - runBlocking { mobile.getTimetable(of(2018, 4, 23), of(2018, 4, 24), student.classId, student.classificationPeriodId, student.id) } - } - - @Test - fun gradesTest() { - runBlocking { mobile.getGradesDetails(student.classId, student.classificationPeriodId, student.id) } - } - - @Test - fun examsTest() { - runBlocking { mobile.getExams(of(2018, 5, 28), of(2018, 6, 3), student.classId, student.classificationPeriodId, student.id) } - } - - @Test - fun notesTest() { - runBlocking { mobile.getNotes(student.classificationPeriodId, student.id) } - } - - @Test - fun attendanceTest() { - runBlocking { mobile.getAttendance(of(2018, 4, 23), of(2018, 4, 24), student.classId, student.classificationPeriodId, student.id) } - } - - @Test - fun homeworkTest() { - runBlocking { mobile.getHomework(of(2017, 10, 23), of(2017, 10, 27), student.classId, student.classificationPeriodId, student.id) } - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsTest.kt deleted file mode 100644 index 7981635e..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/exams/ExamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.exams - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.repository.MobileRepository -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import retrofit2.create -import java.time.LocalDate.of - -class ExamsTest : BaseLocalTest() { - - private val exams by lazy { MobileRepository(getRetrofit().create()) } - - @Test - fun getExams() { - server.enqueueAndStart("Sprawdziany.json") - - val items = runBlocking { exams.getExams(of(2020, 1, 16), of(2020, 1, 17), 1, 2, 3) } - - assertEquals(3, items.size) - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesTest.kt deleted file mode 100644 index 73bce3ca..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/grades/GradesTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.grades - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.repository.MobileRepository -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import retrofit2.create - -class GradesTest : BaseLocalTest() { - - private val grades by lazy { MobileRepository(getRetrofit().create()) } - - @Test - fun getGrades() { - server.enqueueAndStart("Oceny.json") - - val items = runBlocking { grades.getGradesDetails(0, 0, 0) } - - assertEquals(2, items.size) - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptorTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptorTest.kt deleted file mode 100644 index 1cbe6bfd..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/interceptor/ErrorInterceptorTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.interceptor - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.exception.InvalidSymbolException -import io.github.wulkanowy.sdk.mobile.repository.RegisterRepository -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertTrue -import org.junit.Test -import retrofit2.create -import java.io.IOException - -class ErrorInterceptorTest : BaseLocalTest() { - - @Test - fun unknownError() { - server.enqueueAndStart("bad-request.txt") - - val repo = RegisterRepository(getRetrofitBuilder().baseUrl("http://localhost:3030/").build().create()) - - try { - runBlocking { repo.getStudents() } - } catch (e: Throwable) { - assertTrue(e is IOException) - } - } - - @Test - fun invalidSymbol_diacritics() { - server.enqueueAndStart("invalid-symbol.html") - - val repo = RegisterRepository(getRetrofitBuilder().baseUrl("http://localhost:3030/").build().create()) - - try { - runBlocking { repo.getStudents() } - } catch (e: Throwable) { - assertTrue(e is InvalidSymbolException) - } - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/register/RegisterTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/register/RegisterTest.kt deleted file mode 100644 index cbbd1d93..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/register/RegisterTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.register - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.repository.RegisterRepository -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import retrofit2.create - -class RegisterTest : BaseLocalTest() { - - private val repo by lazy { RegisterRepository(getRetrofit().create()) } - - @Test - fun getStudents() { - server.enqueueAndStart("ListaUczniow.json") - - val students = runBlocking { repo.getStudents() } - assertEquals(2, students.size) - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepositoryTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepositoryTest.kt deleted file mode 100644 index a44c7436..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/repository/RoutingRulesRepositoryTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.repository - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.exception.InvalidTokenException -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test -import retrofit2.create - -class RoutingRulesRepositoryTest : BaseLocalTest() { - - @Test - fun getRouteByToken() { - server.enqueueAndStart("RoutingRules.txt") - - val repo = RoutingRulesRepository(getRetrofit().create()) - val route = runBlocking { repo.getRouteByToken("KA2000") } - - assertEquals("https://uonetplus-komunikacja-test.mcuw.katowice.eu", route) - } - - @Test - fun getRouteByToken_invalid() { - server.enqueueAndStart("RoutingRules.txt") - - val repo = RoutingRulesRepository(getRetrofit().create()) - - try { - runBlocking { repo.getRouteByToken("ERR00000") } - } catch (e: Throwable) { - assertTrue(e is InvalidTokenException) - } - } - - @Test - fun getRouteByToken_tooShort() { - server.enqueueAndStart("RoutingRules.txt") - - val repo = RoutingRulesRepository(getRetrofit().create()) - - // TODO: fix assert to run event if no exception thrown - try { - runBlocking { repo.getRouteByToken("ER") } - } catch (e: Throwable) { - assertTrue(e is InvalidTokenException) - } - } -} diff --git a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableTest.kt b/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableTest.kt deleted file mode 100644 index 7af3f08c..00000000 --- a/sdk-mobile/src/test/kotlin/io/github/wulkanowy/sdk/mobile/timetable/TimetableTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.wulkanowy.sdk.mobile.timetable - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.repository.MobileRepository -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import retrofit2.create -import java.time.LocalDate.of - -class TimetableTest : BaseLocalTest() { - - private val timetable by lazy { MobileRepository(getRetrofit().create()) } - - @Test - fun getTimetable() { - server.enqueueAndStart("PlanLekcji.json") - - val items = runBlocking { timetable.getTimetable(of(2020, 1, 10), of(2020, 2, 11), 1, 2, 3) } - - assertEquals(5, items.size) - } -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/Slowniki.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/Slowniki.json deleted file mode 100644 index 158acb82..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/Slowniki.json +++ /dev/null @@ -1,911 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1579118032, - "TimeValue": "Wed, 15 Jan 2020 19:53:51 GMT", - "RequestId": "38af6dfe-cd51-4b74-b7d3-52f764b48d85", - "DayOfWeek": 3, - "AppVersion": "17.09.0009.26859", - "Data": { - "TimeKey": 1579118032, - "Nauczyciele": [ - { - "Id": 1, - "Imie": "Karolina", - "Nazwisko": "Kowalska", - "Kod": "AN", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 100 - }, - { - "Id": 2, - "Imie": "Zofia", - "Nazwisko": "Czerwińska", - "Kod": "NA", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 101 - }, - { - "Id": 3, - "Imie": "Aleksandra", - "Nazwisko": "Krajewska", - "Kod": "AK", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 102 - }, - { - "Id": 4, - "Imie": "Stanisław", - "Nazwisko": "Krupa", - "Kod": "BS", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 103 - }, - { - "Id": 5, - "Imie": "Aleksandra", - "Nazwisko": "Wójtowicz", - "Kod": "AW", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 104 - }, - { - "Id": 6, - "Imie": "Sara", - "Nazwisko": "Wierzbicka", - "Kod": "KB", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 105 - }, - { - "Id": 7, - "Imie": "Mateusz", - "Nazwisko": "Kowal", - "Kod": "MK", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 106 - }, - { - "Id": 8, - "Imie": "Amelia", - "Nazwisko": "Mazur", - "Kod": "AM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 107 - }, - { - "Id": 9, - "Imie": "Barbara", - "Nazwisko": "Markowska", - "Kod": "BM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 108 - }, - { - "Id": 10, - "Imie": "Michał", - "Nazwisko": "Mazur", - "Kod": "MM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 109 - } - ], - "Pracownicy": [ - { - "Id": 1, - "Imie": "Karolina", - "Nazwisko": "Kowalska", - "Kod": "AN", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 100 - }, - { - "Id": 2, - "Imie": "Zofia", - "Nazwisko": "Czerwińska", - "Kod": "NA", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 101 - }, - { - "Id": 3, - "Imie": "Aleksandra", - "Nazwisko": "Krajewska", - "Kod": "AK", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 102 - }, - { - "Id": 4, - "Imie": "Stanisław", - "Nazwisko": "Krupa", - "Kod": "BS", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 103 - }, - { - "Id": 5, - "Imie": "Aleksandra", - "Nazwisko": "Wójtowicz", - "Kod": "AW", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 104 - }, - { - "Id": 6, - "Imie": "Sara", - "Nazwisko": "Wierzbicka", - "Kod": "KB", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 105 - }, - { - "Id": 7, - "Imie": "Mateusz", - "Nazwisko": "Kowal", - "Kod": "MK", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 106 - }, - { - "Id": 8, - "Imie": "Amelia", - "Nazwisko": "Mazur", - "Kod": "AM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 107 - }, - { - "Id": 9, - "Imie": "Barbara", - "Nazwisko": "Markowska", - "Kod": "BM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 108 - }, - { - "Id": 10, - "Imie": "Michał", - "Nazwisko": "Mazur", - "Kod": "MM", - "Aktywny": true, - "Nauczyciel": true, - "LoginId": 109 - } - ], - "Przedmioty": [ - { - "Id": 300, - "Nazwa": "Zajęcia z wychowawcą", - "Kod": "godz.wych", - "Aktywny": true, - "Pozycja": 0 - }, - { - "Id": 301, - "Nazwa": "Język polski", - "Kod": "j. polski", - "Aktywny": true, - "Pozycja": 3 - }, - { - "Id": 302, - "Nazwa": "Historia", - "Kod": "historia", - "Aktywny": true, - "Pozycja": 1 - }, - { - "Id": 303, - "Nazwa": "Etyka", - "Kod": "etyka", - "Aktywny": true, - "Pozycja": 2 - }, - { - "Id": 304, - "Nazwa": "Język angielski", - "Kod": "j. angielski", - "Aktywny": true, - "Pozycja": 4 - }, - { - "Id": 305, - "Nazwa": "Język niemiecki", - "Kod": "j. niemiecki", - "Aktywny": true, - "Pozycja": 5 - }, - { - "Id": 306, - "Nazwa": "Metodologia programowania", - "Kod": "metod.programowania", - "Aktywny": true, - "Pozycja": 6 - }, - { - "Id": 307, - "Nazwa": "Matematyka", - "Kod": "matematyka", - "Aktywny": true, - "Pozycja": 7 - }, - { - "Id": 308, - "Nazwa": "Fizyka", - "Kod": "fizyka", - "Aktywny": true, - "Pozycja": 8 - }, - { - "Id": 309, - "Nazwa": "Chemia", - "Kod": "chemia", - "Aktywny": true, - "Pozycja": 9 - }, - { - "Id": 310, - "Nazwa": "Biologia", - "Kod": "biologia", - "Aktywny": true, - "Pozycja": 10 - }, - { - "Id": 311, - "Nazwa": "Geografia", - "Kod": "geografia", - "Aktywny": true, - "Pozycja": 11 - }, - { - "Id": 312, - "Nazwa": "Informatyka", - "Kod": "informatyka", - "Aktywny": true, - "Pozycja": 12 - }, - { - "Id": 313, - "Nazwa": "Religia", - "Kod": "religia", - "Aktywny": true, - "Pozycja": 13 - } - ], - "PoryLekcji": [ - { - "Id": 76, - "Numer": 1, - "Poczatek": 25200, - "PoczatekTekst": "08:00", - "Koniec": 27900, - "KoniecTekst": "08:45" - }, - { - "Id": 77, - "Numer": 2, - "Poczatek": 28500, - "PoczatekTekst": "08:55", - "Koniec": 31200, - "KoniecTekst": "09:40" - }, - { - "Id": 78, - "Numer": 3, - "Poczatek": 31800, - "PoczatekTekst": "09:50", - "Koniec": 34500, - "KoniecTekst": "10:35" - }, - { - "Id": 79, - "Numer": 4, - "Poczatek": 35100, - "PoczatekTekst": "10:45", - "Koniec": 37800, - "KoniecTekst": "11:30" - }, - { - "Id": 80, - "Numer": 5, - "Poczatek": 38400, - "PoczatekTekst": "11:40", - "Koniec": 41100, - "KoniecTekst": "12:25" - }, - { - "Id": 81, - "Numer": 6, - "Poczatek": 42300, - "PoczatekTekst": "12:45", - "Koniec": 45000, - "KoniecTekst": "13:30" - }, - { - "Id": 82, - "Numer": 7, - "Poczatek": 45600, - "PoczatekTekst": "13:40", - "Koniec": 48300, - "KoniecTekst": "14:25" - }, - { - "Id": 83, - "Numer": 8, - "Poczatek": 48600, - "PoczatekTekst": "14:30", - "Koniec": 51300, - "KoniecTekst": "15:15" - }, - { - "Id": 84, - "Numer": 9, - "Poczatek": 51600, - "PoczatekTekst": "15:20", - "Koniec": 54300, - "KoniecTekst": "16:05" - }, - { - "Id": 85, - "Numer": 10, - "Poczatek": 54600, - "PoczatekTekst": "16:10", - "Koniec": 57300, - "KoniecTekst": "16:55" - }, - { - "Id": 86, - "Numer": 11, - "Poczatek": 57600, - "PoczatekTekst": "17:00", - "Koniec": 60300, - "KoniecTekst": "17:45" - }, - { - "Id": 87, - "Numer": 12, - "Poczatek": 60600, - "PoczatekTekst": "17:50", - "Koniec": 63300, - "KoniecTekst": "18:35" - } - ], - "KategorieOcen": [ - { - "Id": 26, - "Kod": "Akt", - "Nazwa": "A - aktywność (czarny)" - }, - { - "Id": 27, - "Kod": "Bież", - "Nazwa": "B - bieżące (fiol)" - }, - { - "Id": 28, - "Kod": "Kart", - "Nazwa": "K - kartkówka (zielony)" - }, - { - "Id": 29, - "Kod": "Spr", - "Nazwa": "S - sprawdzian (czerwony)" - }, - { - "Id": 30, - "Kod": "Z.dom", - "Nazwa": "Zd - zadanie domowe (czarny)" - }, - { - "Id": 65, - "Kod": "odp", - "Nazwa": "OD - odpowiedź ustna (nieb)" - }, - { - "Id": 67, - "Kod": "ref", - "Nazwa": "Referat" - }, - { - "Id": 68, - "Kod": "zewn", - "Nazwa": "Sprawdzian zewnętrzny" - }, - { - "Id": 69, - "Kod": "tsm", - "Nazwa": "Test sprawności motorycznej" - }, - { - "Id": 70, - "Kod": "tu", - "Nazwa": "Test umiejętności" - }, - { - "Id": 71, - "Kod": "zs", - "Nazwa": "Zawody sportowe" - }, - { - "Id": 72, - "Kod": "bs", - "Nazwa": "Brak stroju" - }, - { - "Id": 73, - "Kod": "r", - "Nazwa": "Rozgrzewka" - }, - { - "Id": 74, - "Kod": "pr_dł", - "Nazwa": "Praca długoterminowa" - }, - { - "Id": 75, - "Kod": "ze_ćwi", - "Nazwa": "Zeszyt ćwiczeń" - }, - { - "Id": 76, - "Kod": "Inne", - "Nazwa": "Inne" - }, - { - "Id": 77, - "Kod": "popspr", - "Nazwa": "Poprawa sprawdzianu" - }, - { - "Id": 78, - "Kod": "PK", - "Nazwa": "Praca klasowa" - }, - { - "Id": 79, - "Kod": "Re", - "Nazwa": "Recytacja" - }, - { - "Id": 80, - "Kod": "dyk", - "Nazwa": "Dyktando" - }, - { - "Id": 81, - "Kod": "lek", - "Nazwa": "Lektura" - }, - { - "Id": 82, - "Kod": "sp_wiedzy", - "Nazwa": "Sprawdzian wiedzy" - }, - { - "Id": 83, - "Kod": "egz_próbny", - "Nazwa": "Egzamin próbny" - } - ], - "KategorieUwag": [ - { - "Id": 46, - "Nazwa": "Wypełnianie obowiązków ucznia", - "Aktywny": false - }, - { - "Id": 47, - "Nazwa": "Zaangażowanie społeczne", - "Aktywny": false - }, - { - "Id": 48, - "Nazwa": "Kultura języka", - "Aktywny": false - }, - { - "Id": 49, - "Nazwa": "Kultura osobista", - "Aktywny": false - }, - { - "Id": 50, - "Nazwa": "Dbałość o bezpieczeństwo i zdrowie", - "Aktywny": false - }, - { - "Id": 51, - "Nazwa": "Szacunek dla innych osób", - "Aktywny": false - }, - { - "Id": 52, - "Nazwa": "Zachowanie norm etycznych", - "Aktywny": false - }, - { - "Id": 53, - "Nazwa": "Reprezentowanie szkoły", - "Aktywny": false - }, - { - "Id": 54, - "Nazwa": "Zachowanie na lekcji", - "Aktywny": false - }, - { - "Id": 58, - "Nazwa": "Inne (informacja bez punktów)", - "Aktywny": true - }, - { - "Id": 59, - "Nazwa": "Udział w konkursie szkolnym +20 pkt", - "Aktywny": false - }, - { - "Id": 61, - "Nazwa": "Przeszkadzanie na lekcjach -5 pkt", - "Aktywny": false - }, - { - "Id": 66, - "Nazwa": "+ Udział w olimpiadzie przedmiotowej i konkursach pozaszk. (rza w sem. 20-30-50)", - "Aktywny": true - }, - { - "Id": 67, - "Nazwa": "+ Udział w konkursie szkolnym (0-20)", - "Aktywny": true - }, - { - "Id": 68, - "Nazwa": "+ Funkcja w szkole (0-20)", - "Aktywny": true - }, - { - "Id": 69, - "Nazwa": "+ Funkcja w klasie (0-30)", - "Aktywny": true - }, - { - "Id": 70, - "Nazwa": "+ Reprezentowanie szkoły w rozgrywkach sport.( raz w sem. 0-100)", - "Aktywny": true - }, - { - "Id": 71, - "Nazwa": "+ Pomoc podczas imprezy szkolnej (0-10)", - "Aktywny": false - }, - { - "Id": 72, - "Nazwa": "+ Praca na rzecz klasy (0-20)", - "Aktywny": true - }, - { - "Id": 73, - "Nazwa": "+ Praca na rzecz szkoły (0-20)", - "Aktywny": true - }, - { - "Id": 74, - "Nazwa": "+ Punktualność (0-20)", - "Aktywny": true - }, - { - "Id": 75, - "Nazwa": "+ Pomoc kolegom (0-10)", - "Aktywny": true - }, - { - "Id": 76, - "Nazwa": "+ Kulturalne zachowanie się w szkole i poza nią (0-50)", - "Aktywny": false - }, - { - "Id": 77, - "Nazwa": "+ Przeciwstawianie się przejawom agresji i wulgarności (0-20)", - "Aktywny": false - }, - { - "Id": 79, - "Nazwa": "+ Do dyspozycji wychowawcy (0-50)", - "Aktywny": true - }, - { - "Id": 80, - "Nazwa": "+ Realizacja projektu edukacyjnego (0-50)", - "Aktywny": true - }, - { - "Id": 81, - "Nazwa": "- Przeszkadzanie na lekcjach -5p.", - "Aktywny": true - }, - { - "Id": 82, - "Nazwa": "- Okłamywanie i oszukiwanie nauczyciela 20p.", - "Aktywny": true - }, - { - "Id": 83, - "Nazwa": "- Niewykonywanie poleceń nauczyciela (10-20)", - "Aktywny": true - }, - { - "Id": 84, - "Nazwa": "- Aroganckie zachowanie wobec nauczyciela lub pracownika szkoły -50p.", - "Aktywny": true - }, - { - "Id": 85, - "Nazwa": "- Ubliżanie kolegom/koleżankom (10-30)", - "Aktywny": true - }, - { - "Id": 86, - "Nazwa": "- Przemoc fizyczna (10-30)", - "Aktywny": true - }, - { - "Id": 87, - "Nazwa": "- Wulgarne słownictwo (10-30)", - "Aktywny": true - }, - { - "Id": 88, - "Nazwa": "- Opuszczanie terenu szkoły w czasie zajęć -10p.", - "Aktywny": true - }, - { - "Id": 89, - "Nazwa": "- Niszczenie mienia (10-30)", - "Aktywny": true - }, - { - "Id": 90, - "Nazwa": "- Zaśmiecanie otoczenia (5-10)", - "Aktywny": true - }, - { - "Id": 91, - "Nazwa": "- Strój i wygląd niezgodny z regulaminem ucznia (2-20)", - "Aktywny": true - }, - { - "Id": 92, - "Nazwa": "- Spóźnienia się na lekcję do 10 min. (3p.)", - "Aktywny": true - }, - { - "Id": 93, - "Nazwa": "- Niewykonywanie zobowiązania (10-20)", - "Aktywny": true - }, - { - "Id": 94, - "Nazwa": "- Nieusprawiedliwiona nieobecność (5p.)", - "Aktywny": true - }, - { - "Id": 95, - "Nazwa": "- Wyłudzanie pieniędzy (50p.)", - "Aktywny": true - }, - { - "Id": 96, - "Nazwa": "- Kradzież (50p.)", - "Aktywny": true - }, - { - "Id": 97, - "Nazwa": "- Palenie papierosów (50p.)", - "Aktywny": true - }, - { - "Id": 98, - "Nazwa": "- Picie alkoholu (50p.)", - "Aktywny": true - }, - { - "Id": 99, - "Nazwa": "- Stosowanie środków odurzających (50p.)", - "Aktywny": true - }, - { - "Id": 100, - "Nazwa": "- Korzystanie z tel. kom. i urz. elek. niezgodnie z regulaminem (5-20)", - "Aktywny": true - }, - { - "Id": 101, - "Nazwa": "- Drastyczne naruszenie ogólnie przyjętych norm społ. (100-250)", - "Aktywny": true - } - ], - "KategorieFrekwencji": [ - { - "Id": 1, - "Nazwa": "obecność", - "Pozycja": 1000, - "Obecnosc": true, - "Nieobecnosc": false, - "Zwolnienie": false, - "Spoznienie": false, - "Usprawiedliwione": false, - "Usuniete": false - }, - { - "Id": 2, - "Nazwa": "nieobecność nieusprawiedliwiona", - "Pozycja": 1000, - "Obecnosc": false, - "Nieobecnosc": true, - "Zwolnienie": false, - "Spoznienie": false, - "Usprawiedliwione": false, - "Usuniete": false - }, - { - "Id": 3, - "Nazwa": "nieobecność usprawiedliwiona", - "Pozycja": 1000, - "Obecnosc": false, - "Nieobecnosc": true, - "Zwolnienie": false, - "Spoznienie": false, - "Usprawiedliwione": true, - "Usuniete": false - }, - { - "Id": 4, - "Nazwa": "spóźnienie nieusprawiedliwione", - "Pozycja": 1000, - "Obecnosc": true, - "Nieobecnosc": false, - "Zwolnienie": false, - "Spoznienie": true, - "Usprawiedliwione": false, - "Usuniete": false - }, - { - "Id": 5, - "Nazwa": "spóźnienie usprawiedliwione", - "Pozycja": 1000, - "Obecnosc": true, - "Nieobecnosc": false, - "Zwolnienie": false, - "Spoznienie": true, - "Usprawiedliwione": true, - "Usuniete": false - }, - { - "Id": 6, - "Nazwa": "nieobecny z przyczyn szkolnych", - "Pozycja": 1000, - "Obecnosc": true, - "Nieobecnosc": false, - "Zwolnienie": false, - "Spoznienie": false, - "Usprawiedliwione": false, - "Usuniete": false - }, - { - "Id": 7, - "Nazwa": "zwolniony", - "Pozycja": 1000, - "Obecnosc": false, - "Nieobecnosc": false, - "Zwolnienie": true, - "Spoznienie": false, - "Usprawiedliwione": false, - "Usuniete": false - }, - { - "Id": 8, - "Nazwa": "usunięty wpis", - "Pozycja": 1000, - "Obecnosc": false, - "Nieobecnosc": false, - "Zwolnienie": false, - "Spoznienie": false, - "Usprawiedliwione": false, - "Usuniete": true - } - ], - "TypyFrekwencji": [ - { - "Id": 40, - "Symbol": "●", - "Nazwa": "obecność", - "Aktywny": true, - "WpisDomyslny": true, - "IdKategoriaFrek": 1 - }, - { - "Id": 41, - "Symbol": "—", - "Nazwa": "nieobecność", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 2 - }, - { - "Id": 42, - "Symbol": "u", - "Nazwa": "nieob. uspraw.", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 3 - }, - { - "Id": 43, - "Symbol": "s", - "Nazwa": "spóźnienie", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 4 - }, - { - "Id": 44, - "Symbol": "su", - "Nazwa": "spóźn. uspr.", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 5 - }, - { - "Id": 45, - "Symbol": "ns", - "Nazwa": "nieob. uspr. p.s.", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 6 - }, - { - "Id": 46, - "Symbol": "z", - "Nazwa": "zwolniony", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 7 - }, - { - "Id": 47, - "Symbol": "", - "Nazwa": "usunięty wpis", - "Aktywny": true, - "WpisDomyslny": false, - "IdKategoriaFrek": 8 - }, - { - "Id": 55, - "Symbol": "zr", - "Nazwa": "zwolniony przez rodzica", - "Aktywny": false, - "WpisDomyslny": false, - "IdKategoriaFrek": 3 - } - ] - } -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/exams/Sprawdziany.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/exams/Sprawdziany.json deleted file mode 100644 index 0e572375..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/exams/Sprawdziany.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1579113877, - "TimeValue": "Wed, 15 Jan 2020 18:44:36 GMT", - "RequestId": "79ff96b3-5c63-4b03-9922-b5e22ed3ba6f", - "DayOfWeek": 3, - "AppVersion": "17.09.0009.26859", - "Data": [ - { - "Id": 2740, - "IdPrzedmiot": 118, - "IdPracownik": 94, - "IdOddzial": 52, - "IdPodzial": null, - "PodzialNazwa": null, - "PodzialSkrot": null, - "Rodzaj": true, - "RodzajNumer": 1, - "Opis": "Bajki - Ignacy Krasicki", - "Data": 1579215600, - "DataTekst": "2020-01-17" - }, - { - "Id": 2741, - "IdPrzedmiot": 118, - "IdPracownik": 94, - "IdOddzial": 52, - "IdPodzial": null, - "PodzialNazwa": null, - "PodzialSkrot": null, - "Rodzaj": false, - "RodzajNumer": 2, - "Opis": "Epopeja - Pan Tadeusz", - "Data": 1579215600, - "DataTekst": "2020-01-17" - }, - { - "Id": 2742, - "IdPrzedmiot": 118, - "IdPracownik": 94, - "IdOddzial": 52, - "IdPodzial": null, - "PodzialNazwa": null, - "PodzialSkrot": null, - "Rodzaj": false, - "RodzajNumer": 3, - "Opis": "Wielki Poeta - Słowacki", - "Data": 1579215600, - "DataTekst": "2020-01-17" - } - ] -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/Oceny.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/Oceny.json deleted file mode 100644 index 49a460c4..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/Oceny.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1580410527, - "TimeValue": "Thu, 30 Jan 2020 18:55:27 GMT", - "RequestId": "090cdefc-64a7-4a06-908c-d12703a5f465", - "DayOfWeek": 4, - "AppVersion": "17.09.0009.26859", - "Data": [ - { - "Id": 1000, - "Pozycja": 1, - "PrzedmiotPozycja": 1, - "IdPrzedmiot": 300, - "IdKategoria": 26, - "Wpis": "3", - "Wartosc": 3, - "WagaModyfikatora": null, - "WagaOceny": 5, - "Licznik": null, - "Mianownik": null, - "Komentarz": null, - "Waga": "5,00", - "Opis": "Aktywność", - "DataUtworzenia": 1536883200, - "DataUtworzeniaTekst": "2018-09-14", - "DataModyfikacji": 1536883200, - "DataModyfikacjiTekst": "2018-09-14", - "IdPracownikD": 1, - "IdPracownikM": 1 - }, - { - "Id": 1001, - "Pozycja": 3, - "PrzedmiotPozycja": 8, - "IdPrzedmiot": 300, - "IdKategoria": 26, - "Wpis": "4", - "Wartosc": 4, - "WagaModyfikatora": null, - "WagaOceny": 5, - "Licznik": null, - "Mianownik": null, - "Komentarz": null, - "Waga": "5,00", - "Opis": "Aktywność", - "DataUtworzenia": 1538179200, - "DataUtworzeniaTekst": "2018-09-29", - "DataModyfikacji": 1538179200, - "DataModyfikacjiTekst": "2018-09-29", - "IdPracownikD": 1, - "IdPracownikM": 1 - } - ] -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/OcenyPodsumowanie.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/OcenyPodsumowanie.json deleted file mode 100644 index f8e31c69..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/grades/OcenyPodsumowanie.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1680906858, - "TimeValue": "Fri, 07 Apr 2023 22:34:17 GMT", - "RequestId": "e749eca7-65e7-4998-98d2-c2de3e7e6fc5", - "DayOfWeek": 5, - "AppVersion": "17.09.0009.26859", - "Data": { - "OcenyPrzewidywane": [ - { - "IdPrzedmiot": 300, - "Wpis": "4" - }, - { - "IdPrzedmiot": 301, - "Wpis": "3" - }, - { - "IdPrzedmiot": 302, - "Wpis": "4" - }, - { - "IdPrzedmiot": 303, - "Wpis": "4" - } - ], - "OcenyKlasyfikacyjne": [ - { - "IdPrzedmiot": 300, - "Wpis": "4+" - }, - { - "IdPrzedmiot": 301, - "Wpis": "5" - }, - { - "IdPrzedmiot": 302, - "Wpis": "2+" - }, - { - "IdPrzedmiot": 303, - "Wpis": "3" - } - ], - "SrednieOcen": [ - { - "IdPrzedmiot": 300, - "SredniaOcen": "4,13", - "SumaPunktow": "123/200 (61,5%)" - }, - { - "IdPrzedmiot": 301, - "SredniaOcen": "4,1", - "SumaPunktow": "234/300 (78%)" - }, - { - "IdPrzedmiot": 302, - "SredniaOcen": "1,99", - "SumaPunktow": "345/400 (86,25%)" - }, - { - "IdPrzedmiot": 303, - "SredniaOcen": "4", - "SumaPunktow": "456/500 (91,2%)" - } - ] - } -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/bad-request.txt b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/bad-request.txt deleted file mode 100644 index b232c3b3..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/bad-request.txt +++ /dev/null @@ -1 +0,0 @@ -Bad Request \ No newline at end of file diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/invalid-symbol.html b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/invalid-symbol.html deleted file mode 100644 index c4fbfb2a..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/interceptor/invalid-symbol.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - UONET+ dla urządzeń mobilnych - - - - - -
Witamy w systemie UONET+ dla urządzeń mobilnych
-
- -
- - -
-
-
Podany symbol grupujący jest nieprawidłowy
-
-
- -
- - - - - - - - diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow-2.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow-2.json deleted file mode 100644 index ec5a7e8b..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow-2.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1579185018, - "TimeValue": "Thu, 16 Jan 2020 14:30:18 GMT", - "RequestId": "1799be6b-7a60-4665-b75c-1bca504e8ebd", - "DayOfWeek": 4, - "AppVersion": "17.09.0009.26859", - "Data": [ - { - "IdOkresKlasyfikacyjny": 12, - "OkresPoziom": 4, - "OkresNumer": 1, - "OkresDataOd": 1567296000, - "OkresDataDo": 1580256000, - "OkresDataOdTekst": "2019-09-01", - "OkresDataDoTekst": "2020-01-29", - "IdJednostkaSprawozdawcza": 6, - "JednostkaSprawozdawczaSkrot": "Fake123456", - "JednostkaSprawozdawczaNazwa": "Fakelog public diary nr 1", - "JednostkaSprawozdawczaSymbol": "123456", - "IdJednostka": 0, - "JednostkaNazwa": "Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", - "JednostkaSkrot": "Fake123456", - "OddzialSymbol": "A", - "OddzialKod": "4A", - "UzytkownikRola": "uczeń", - "UzytkownikLogin": "jan@fakelog.cf", - "UzytkownikLoginId": 1, - "UzytkownikNazwa": "Jan Kowalski", - "Id": 1, - "IdOddzial": 1, - "Imie": "Jan", - "Imie2": "Marek", - "Nazwisko": "Kowalski", - "Pseudonim": "", - "UczenPlec": 1, - "Pozycja": 0, - "LoginId": null - } - ] -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow.json deleted file mode 100644 index faad7348..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/register/ListaUczniow.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1579185018, - "TimeValue": "Thu, 16 Jan 2020 14:30:18 GMT", - "RequestId": "1799be6b-7a60-4665-b75c-1bca504e8ebd", - "DayOfWeek": 4, - "AppVersion": "17.09.0009.26859", - "Data": [ - { - "IdOkresKlasyfikacyjny": 12, - "OkresPoziom": 4, - "OkresNumer": 2, - "OkresDataOd": 1580342400, - "OkresDataDo": 1598832000, - "OkresDataOdTekst": "2020-01-30", - "OkresDataDoTekst": "2020-08-31", - "IdJednostkaSprawozdawcza": 6, - "JednostkaSprawozdawczaSkrot": "Fake123456", - "JednostkaSprawozdawczaNazwa": "Fakelog public diary nr 1", - "JednostkaSprawozdawczaSymbol": "123456", - "IdJednostka": 0, - "JednostkaNazwa": "Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", - "JednostkaSkrot": "Fake123456", - "OddzialSymbol": "A", - "OddzialKod": "4A", - "UzytkownikRola": "uczeń", - "UzytkownikLogin": "jan@fakelog.cf", - "UzytkownikLoginId": 2, - "UzytkownikNazwa": "Joanna Czerwińska", - "Id": 2, - "IdOddzial": 2, - "Imie": "Joanna", - "Imie2": "Maria", - "Nazwisko": "Czerwińska", - "Pseudonim": "", - "UczenPlec": 0, - "Pozycja": 0, - "LoginId": null - }, - { - "IdOkresKlasyfikacyjny": 12, - "OkresPoziom": 4, - "OkresNumer": 2, - "OkresDataOd": 1580342400, - "OkresDataDo": 1598832000, - "OkresDataOdTekst": "2020-01-30", - "OkresDataDoTekst": "2020-08-31", - "IdJednostkaSprawozdawcza": 6, - "JednostkaSprawozdawczaSkrot": "Fake123456", - "JednostkaSprawozdawczaNazwa": "Fakelog public diary nr 1", - "JednostkaSprawozdawczaSymbol": "123456", - "IdJednostka": 0, - "JednostkaNazwa": "Publiczna szkoła Wulkanowego nr 1 w fakelog.cf", - "JednostkaSkrot": "Fake123456", - "OddzialSymbol": "A", - "OddzialKod": "4A", - "UzytkownikRola": "uczeń", - "UzytkownikLogin": "jan@fakelog.cf", - "UzytkownikLoginId": 1, - "UzytkownikNazwa": "Jan Kowalski", - "Id": 1, - "IdOddzial": 1, - "Imie": "Jan", - "Imie2": "Marek", - "Nazwisko": "Kowalski", - "Pseudonim": "", - "UczenPlec": 1, - "Pozycja": 0, - "LoginId": null - } - ] -} diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/repository/RoutingRules.txt b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/repository/RoutingRules.txt deleted file mode 100644 index 1a88cf02..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/repository/RoutingRules.txt +++ /dev/null @@ -1,14 +0,0 @@ -3S1,https://lekcjaplus.vulcan.net.pl -TA1,https://uonetplus-komunikacja.umt.tarnow.pl -OP1,https://uonetplus-komunikacja.eszkola.opolskie.pl -RZ1,https://uonetplus-komunikacja.resman.pl -GD1,https://uonetplus-komunikacja.edu.gdansk.pl -KA1,https://uonetplus-komunikacja.mcuw.katowice.eu -KA2,https://uonetplus-komunikacja-test.mcuw.katowice.eu -LU1,https://uonetplus-komunikacja.edu.lublin.eu -LU2,https://test-uonetplus-komunikacja.edu.lublin.eu -P03,https://efeb-komunikacja-pro-efebmobile.pro.vulcan.pl -P01,http://efeb-komunikacja.pro-hudson.win.vulcan.pl -P02,http://efeb-komunikacja.pro-hudsonrc.win.vulcan.pl -P90,http://efeb-komunikacja-pro-mwujakowska.neo.win.vulcan.pl -KO1,https://uonetplus-komunikacja.eduportal.koszalin.pl diff --git a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/timetable/PlanLekcji.json b/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/timetable/PlanLekcji.json deleted file mode 100644 index b136bd74..00000000 --- a/sdk-mobile/src/test/resources/io/github/wulkanowy/sdk/mobile/timetable/PlanLekcji.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "Status": "Ok", - "TimeKey": 1581205518, - "TimeValue": "Sat, 08 Feb 2020 23:45:17 GMT", - "RequestId": "8f8b7d7f-cd4b-4fa5-b662-c5be2a82af54", - "DayOfWeek": 6, - "AppVersion": "17.09.0009.26859", - "Data": [ - { - "Dzien": 1580688000, - "DzienTekst": "2020-02-03", - "NumerLekcji": 1, - "IdPoraLekcji": 76, - "IdPrzedmiot": 308, - "PrzedmiotNazwa": "Fizyka", - "PodzialSkrot": null, - "Sala": "213", - "IdPracownik": 1, - "IdPracownikWspomagajacy": null, - "IdPracownikOld": null, - "IdPracownikWspomagajacyOld": null, - "IdPlanLekcji": 23, - "AdnotacjaOZmianie": "", - "PrzekreslonaNazwa": false, - "PogrubionaNazwa": false, - "PlanUcznia": true - }, - { - "Dzien": 1580688000, - "DzienTekst": "2020-02-03", - "NumerLekcji": 2, - "IdPoraLekcji": 77, - "IdPrzedmiot": 300, - "PrzedmiotNazwa": "Sieci komputerowe", - "PodzialSkrot": "t.infor", - "Sala": "G1", - "IdPracownik": 4, - "IdPracownikWspomagajacy": null, - "IdPracownikOld": null, - "IdPracownikWspomagajacyOld": null, - "IdPlanLekcji": 4, - "AdnotacjaOZmianie": "(przeniesiona z lekcji 1, 10.02.2020)", - "PrzekreslonaNazwa": false, - "PogrubionaNazwa": true, - "PlanUcznia": true - }, - { - "Dzien": 1580688000, - "DzienTekst": "2020-02-03", - "NumerLekcji": 2, - "IdPoraLekcji": 77, - "IdPrzedmiot": 499, - "PrzedmiotNazwa": "Wychowanie fizyczne", - "PodzialSkrot": "wf_grupa_2", - "Sala": "S4", - "IdPracownik": 7, - "IdPracownikWspomagajacy": null, - "IdPracownikOld": 5, - "IdPracownikWspomagajacyOld": null, - "IdPlanLekcji": 46, - "AdnotacjaOZmianie": "(zastępstwo: Anon Gałecki, sala S4)", - "PrzekreslonaNazwa": true, - "PogrubionaNazwa": false, - "PlanUcznia": true - }, - { - "Dzien": 1580688000, - "DzienTekst": "2020-02-03", - "NumerLekcji": 3, - "IdPoraLekcji": 78, - "IdPrzedmiot": 499, - "PrzedmiotNazwa": "Wychowanie fizyczne", - "PodzialSkrot": "wf_grupa_2", - "Sala": "S4", - "IdPracownik": 7, - "IdPracownikWspomagajacy": null, - "IdPracownikOld": 5, - "IdPracownikWspomagajacyOld": null, - "IdPlanLekcji": 47, - "AdnotacjaOZmianie": "(zastępstwo: Anon Gałecki, sala S4)", - "PrzekreslonaNazwa": false, - "PogrubionaNazwa": false, - "PlanUcznia": true - }, - { - "Dzien": 1582239600, - "DzienTekst": "2020-02-03", - "NumerLekcji": 4, - "IdPoraLekcji": 79, - "IdPrzedmiot": 311, - "PrzedmiotNazwa": "Geografia", - "PodzialSkrot": null, - "Sala": "A215", - "IdPracownik": 10, - "IdPracownikWspomagajacy": null, - "IdPracownikOld": 5, - "IdPracownikWspomagajacyOld": null, - "IdPlanLekcji": 42, - "AdnotacjaOZmianie": "(nieobecny oddział - Zwiedzanie Muzeum II Wojny Światowej w Gdańsku.)", - "PrzekreslonaNazwa": true, - "PogrubionaNazwa": false, - "PlanUcznia": true - } - ] -} diff --git a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseTest.kt b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseTest.kt index bb8f1987..135e887b 100644 --- a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseTest.kt +++ b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseTest.kt @@ -13,7 +13,7 @@ open class BaseTest { return LocalDateTime.of(year, month, day, hour, minute, second) } - fun getDate(year: Int, month: Int, day: Int, hour: Int = 0, minute: Int = 0, second: Int = 0, mili: Int = 0): LocalDateTime { + fun getDate(year: Int, month: Int, day: Int, hour: Int = 0, minute: Int = 0, second: Int = 0): LocalDateTime { return LocalDateTime.of(year, month, day, hour, minute, second) } } diff --git a/sdk/build.gradle b/sdk/build.gradle index 71d93f6a..3d4e4e3d 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -4,17 +4,5 @@ plugins { } dependencies { - implementation project(":sdk-mobile") implementation project(":sdk-scrapper") - - testImplementation files(this.project(':sdk-mobile').sourceSets.test.output) - testImplementation files(this.project(':sdk-mobile').sourceSets.test.runtimeClasspath) -} - -sourceSets { - test { - resources { - srcDir '../sdk-mobile/src/test/resources' - } - } } diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/Sdk.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/Sdk.kt index d27943e2..cca36dd4 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/Sdk.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/Sdk.kt @@ -1,6 +1,5 @@ package io.github.wulkanowy.sdk -import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException import io.github.wulkanowy.sdk.mapper.mapAttendance import io.github.wulkanowy.sdk.mapper.mapAttendanceSummary import io.github.wulkanowy.sdk.mapper.mapCompletedLessons @@ -8,13 +7,10 @@ import io.github.wulkanowy.sdk.mapper.mapConferences import io.github.wulkanowy.sdk.mapper.mapDevices import io.github.wulkanowy.sdk.mapper.mapDirectorInformation import io.github.wulkanowy.sdk.mapper.mapExams -import io.github.wulkanowy.sdk.mapper.mapFromRecipientsToMobile import io.github.wulkanowy.sdk.mapper.mapGradePointsStatistics import io.github.wulkanowy.sdk.mapper.mapGradeStatistics import io.github.wulkanowy.sdk.mapper.mapGrades -import io.github.wulkanowy.sdk.mapper.mapGradesDetails import io.github.wulkanowy.sdk.mapper.mapGradesSemesterStatistics -import io.github.wulkanowy.sdk.mapper.mapGradesSummary import io.github.wulkanowy.sdk.mapper.mapHomework import io.github.wulkanowy.sdk.mapper.mapLuckyNumbers import io.github.wulkanowy.sdk.mapper.mapMailboxes @@ -33,7 +29,6 @@ import io.github.wulkanowy.sdk.mapper.mapTimetableFull import io.github.wulkanowy.sdk.mapper.mapToScrapperAbsent 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 @@ -73,13 +68,11 @@ import okhttp3.Interceptor import okhttp3.logging.HttpLoggingInterceptor import org.slf4j.LoggerFactory import java.time.LocalDate -import java.time.LocalDateTime import java.time.ZoneId class Sdk { enum class Mode { - API, SCRAPPER, HYBRID, } @@ -94,32 +87,12 @@ class Sdk { ADFSLightCufs, } - private val mobile = Mobile() - private val scrapper = Scrapper() private val registerTimeZone = ZoneId.of("Europe/Warsaw") var mode = Mode.HYBRID - var mobileBaseUrl = "" - set(value) { - field = value - mobile.baseUrl = value - } - - var certKey = "" - set(value) { - field = value - mobile.certKey = value - } - - var privateKey = "" - set(value) { - field = value - mobile.privateKey = privateKey - } - var scrapperBaseUrl = "" set(value) { field = value @@ -142,27 +115,18 @@ class Sdk { set(value) { field = value scrapper.schoolSymbol = value - mobile.schoolSymbol = value } var classId = 0 set(value) { field = value scrapper.classId = value - mobile.classId = value } var studentId = 0 set(value) { field = value scrapper.studentId = value - mobile.studentId = value - } - - var loginId = 0 - set(value) { - field = value - mobile.loginId = value } var diaryId = 0 @@ -199,7 +163,6 @@ class Sdk { set(value) { field = value scrapper.logLevel = value - mobile.logLevel = value } var userAgentTemplate = "" @@ -243,7 +206,6 @@ class Sdk { fun addInterceptor(interceptor: Interceptor, network: Boolean = false) { scrapper.addInterceptor(interceptor, network) - mobile.setInterceptor(interceptor, network) interceptors.add(interceptor to network) } @@ -263,10 +225,6 @@ class Sdk { scrapper.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode) } - suspend fun getStudentsFromMobileApi(token: String, pin: String, symbol: String, firebaseToken: String, apiKey: String = ""): List = 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"): List = withContext(Dispatchers.IO) { scrapper.let { it.baseUrl = scrapperBaseUrl @@ -287,197 +245,135 @@ class Sdk { } } - suspend fun getStudentsHybrid( - email: String, - password: String, - scrapperBaseUrl: String, - firebaseToken: String, - startSymbol: String = "Default", - apiKey: String = "", - ) = withContext(Dispatchers.IO) { - getStudentsFromScrapper(email, password, scrapperBaseUrl, startSymbol) - .distinctBy { it.symbol } - .map { scrapperStudent -> - scrapper.let { - it.symbol = scrapperStudent.symbol - it.schoolSymbol = scrapperStudent.schoolSymbol - it.studentId = scrapperStudent.studentId - it.diaryId = -1 - it.classId = scrapperStudent.classId - it.loginType = Scrapper.LoginType.valueOf(scrapperStudent.loginType.name) - } - val token = scrapper.getToken() - getStudentsFromMobileApi(token.token, token.pin, token.symbol, firebaseToken, apiKey).map { student -> - student.copy( - loginMode = Mode.HYBRID, - loginType = scrapperStudent.loginType, - scrapperBaseUrl = scrapperStudent.scrapperBaseUrl, - ) - } - }.toList().flatten() - } - suspend fun getSemesters(): List = 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): List = withContext(Dispatchers.IO) { + suspend fun getAttendance(startDate: LocalDate, endDate: LocalDate): List = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getAttendance(startDate, endDate).mapAttendance() - Mode.HYBRID, Mode.API -> mobile.getAttendance(startDate, endDate, semesterId).mapAttendance(mobile.getDictionaries()) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getAttendance(startDate, endDate).mapAttendance() } } suspend fun getAttendanceSummary(subjectId: Int? = -1): List = 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, 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(): List = 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): List = withContext(Dispatchers.IO) { + suspend fun getExams(start: LocalDate, end: LocalDate): List = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getExams(start, end).mapExams() - Mode.HYBRID, Mode.API -> mobile.getExams(start, end, semesterId).mapExams(mobile.getDictionaries()) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getExams(start, end).mapExams() } } suspend fun getGrades(semesterId: Int): Grades = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getGrades(semesterId).mapGrades() - Mode.API -> mobile.getGrades(semesterId).let { (grades, summaries) -> - val dict = mobile.getDictionaries() - Grades( - details = grades.mapGradesDetails(dict), - summary = summaries.mapGradesSummary(dict), - isAverage = false, - isPoints = false, - isForAdults = false, - type = 0, - ) - } } } suspend fun getGradesSemesterStatistics(semesterId: Int): List = 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): List = 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): List = 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): List = withContext(Dispatchers.IO) { + suspend fun getHomework(start: LocalDate, end: LocalDate): List = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getHomework(start, end).mapHomework() - Mode.HYBRID, Mode.API -> mobile.getHomework(start, end, semesterId).mapHomework(mobile.getDictionaries()) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getHomework(start, end).mapHomework() } } - suspend fun getNotes(semesterId: Int): List = withContext(Dispatchers.IO) { + suspend fun getNotes(): List = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getNotes().mapNotes() - Mode.HYBRID, Mode.API -> mobile.getNotes(semesterId).mapNotes(mobile.getDictionaries()) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getNotes().mapNotes() } } suspend fun getConferences(): List = 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(): List = 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(): 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): 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): List = withContext(Dispatchers.IO) { + suspend fun getTeachers(): List = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getTeachers().mapTeachers() - Mode.HYBRID, Mode.API -> mobile.getTeachers(studentId, semesterId).mapTeachers(mobile.getDictionaries()) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getTeachers().mapTeachers() } } 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(): 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(): 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 getMailboxes(): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getMailboxes().mapMailboxes() - Mode.API -> TODO() } } suspend fun getRecipients(mailboxKey: String): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getRecipients(mailboxKey).mapRecipients() - Mode.API -> mobile.getDictionaries().teachers.mapRecipients(-1) } } @@ -492,68 +388,54 @@ class Sdk { suspend fun getReceivedMessages(mailboxKey: String? = null): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getReceivedMessages(mailboxKey).mapMessages(registerTimeZone, Folder.RECEIVED) - Mode.API -> mobile.getMessages(LocalDateTime.now(), LocalDateTime.now()).mapMessages(registerTimeZone) } } suspend fun getSentMessages(mailboxKey: String? = null): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSentMessages(mailboxKey).mapMessages(registerTimeZone, Folder.SENT) - Mode.API -> mobile.getMessagesSent(LocalDateTime.now(), LocalDateTime.now()).mapMessages(registerTimeZone) } } suspend fun getDeletedMessages(mailboxKey: String? = null): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getDeletedMessages(mailboxKey).mapMessages(registerTimeZone, Folder.TRASHED) - Mode.API -> mobile.getMessagesDeleted(LocalDateTime.now(), LocalDateTime.now()).mapMessages(registerTimeZone) } } suspend fun getMessageReplayDetails(messageKey: String): MessageReplayDetails = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getMessageReplayDetails(messageKey).mapScrapperMessage() - Mode.API -> TODO() } } suspend fun getMessageDetails(messageKey: String, markAsRead: Boolean = true): MessageDetails = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getMessageDetails(messageKey, markAsRead).mapScrapperMessage() - Mode.API -> { - mobile.changeMessageStatus(messageKey, "", "Widoczna") - TODO() - } } } suspend fun sendMessage(subject: String, content: String, recipients: List, mailboxId: String) = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.sendMessage(subject, content, recipients.map { it.mailboxGlobalKey }, mailboxId) - Mode.API -> mobile.sendMessage(subject, content, recipients.mapFromRecipientsToMobile()) } } suspend fun deleteMessages(messages: List, removeForever: Boolean = false) = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.deleteMessages(messages, removeForever) - Mode.HYBRID, Mode.API -> messages.map { messageId -> - mobile.changeMessageStatus(messageId, "", "Usunieta") - } + Mode.HYBRID, Mode.SCRAPPER -> scrapper.deleteMessages(messages, removeForever) } } suspend fun getTimetable(start: LocalDate, end: LocalDate): Timetable = withContext(Dispatchers.IO) { when (mode) { - Mode.SCRAPPER -> scrapper.getTimetable(start, end).mapTimetableFull(registerTimeZone) - Mode.HYBRID, Mode.API -> mobile.getTimetable(start, end, 0).mapTimetableFull(mobile.getDictionaries(), registerTimeZone) + Mode.HYBRID, Mode.SCRAPPER -> scrapper.getTimetable(start, end).mapTimetableFull(registerTimeZone) } } suspend fun getCompletedLessons(start: LocalDate, end: LocalDate? = null, subjectId: Int = -1): List = 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") } } @@ -582,77 +464,66 @@ class Sdk { suspend fun getDirectorInformation(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = 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(): List = withContext(Dispatchers.IO) { when (mode) { Mode.HYBRID, Mode.SCRAPPER -> scrapper.getLastStudentLessons() - Mode.API -> throw FeatureNotAvailableException("Last student lesson is not available in API mode") } } } diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapper.kt index c8d507de..1c85a5e5 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapper.kt @@ -1,6 +1,5 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.Absent import io.github.wulkanowy.sdk.pojo.Attendance import io.github.wulkanowy.sdk.pojo.AttendanceSummary @@ -11,34 +10,10 @@ import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.EXCUSED_LA import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.EXEMPTION import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.PRESENCE import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.UNEXCUSED_LATENESS -import io.github.wulkanowy.sdk.scrapper.capitalise -import io.github.wulkanowy.sdk.scrapper.toLocalDate -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.mobile.attendance.Attendance as ApiAttendance import io.github.wulkanowy.sdk.scrapper.attendance.Absent as ScrapperAbsent import io.github.wulkanowy.sdk.scrapper.attendance.Attendance as ScrapperAttendance import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceSummary as ScrapperAttendanceSummary -fun List.mapAttendance(dictionaries: Dictionaries) = map { - val category = dictionaries.attendanceCategories.singleOrNull { cat -> cat.id == it.categoryId } - Attendance( - number = it.number, - name = category?.name?.capitalise() ?: "Nieznany", - subject = it.subjectName, - date = it.date.toLocalDate(), - timeId = -1, - absence = category?.absence ?: false, - categoryId = it.categoryId, - presence = category?.presence ?: false, - lateness = category?.lateness ?: false, - exemption = category?.exemption ?: false, - excused = category?.excused ?: false, - excusable = false, // - deleted = category?.deleted ?: false, - excuseStatus = null, - ) -} - fun List.mapAttendance() = map { Attendance( number = it.number, diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapper.kt index 8916f080..ce4acce7 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapper.kt @@ -1,28 +1,8 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.Exam -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.mobile.exams.Exam as ApiExam import io.github.wulkanowy.sdk.scrapper.exams.Exam as ScrapperExam -fun List.mapExams(dict: Dictionaries) = map { exam -> - Exam( - date = exam.date.toLocalDate(), - entryDate = exam.date.toLocalDate(), - description = exam.description, - teacher = dict.teachers.singleOrNull { it.id == exam.employeeId }?.run { "$name $surname" }.orEmpty(), - subject = dict.subjects.singleOrNull { it.id == exam.subjectId }?.name.orEmpty(), - teacherSymbol = dict.teachers.singleOrNull { it.id == exam.employeeId }?.code.orEmpty(), - type = when (exam.typeNumber) { - 1 -> "Sprawdzian" - 2 -> "Kartkówka" - 3 -> "Praca klasowa" - else -> "Nieznany" - }, - ) -} - fun List.mapExams() = map { Exam( date = it.date.toLocalDate(), diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt index 50d12ced..a85fdd0c 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapper.kt @@ -1,34 +1,12 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries -import io.github.wulkanowy.sdk.mobile.grades.GradesSummaryResponse import io.github.wulkanowy.sdk.pojo.Grade import io.github.wulkanowy.sdk.pojo.GradeSummary import io.github.wulkanowy.sdk.pojo.Grades -import io.github.wulkanowy.sdk.scrapper.grades.isGradeValid -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.mobile.grades.Grade as ApiGrade import io.github.wulkanowy.sdk.scrapper.grades.Grade as ScrapperGrade import io.github.wulkanowy.sdk.scrapper.grades.GradeSummary as ScrapperGradeSummary import io.github.wulkanowy.sdk.scrapper.grades.Grades as ScrapperGrades -fun List.mapGradesDetails(dict: Dictionaries) = map { grade -> - Grade( - subject = dict.subjects.singleOrNull { it.id == grade.subjectId }?.name.orEmpty(), - description = grade.description, - symbol = dict.gradeCategories.singleOrNull { it.id == grade.categoryId }?.code.orEmpty(), - comment = grade.comment.orEmpty(), - date = grade.creationDate.toLocalDate(), - teacher = dict.teachers.singleOrNull { it.id == grade.employeeIdD }?.let { "${it.name} ${it.surname}" }.orEmpty(), - entry = grade.entry.ifBlank { "..." }, - weightValue = if (isGradeValid(grade.entry)) grade.gradeWeight else .0, - modifier = grade.modificationWeight ?: .0, - value = grade.value, - weight = grade.weight, - color = "0", - ) -} - fun List.mapGradesDetails() = map { Grade( subject = it.subject, @@ -46,21 +24,6 @@ fun List.mapGradesDetails() = map { ) } -fun GradesSummaryResponse.mapGradesSummary(dict: Dictionaries) = average - .union(predicted) - .union(evaluative) - .map { it.subjectId }.distinct().sorted().map { subjectId -> - GradeSummary( - name = dict.subjects.singleOrNull { it.id == subjectId }?.name.orEmpty(), - predicted = predicted.singleOrNull { it.subjectId == subjectId }?.entry.orEmpty(), - final = evaluative.singleOrNull { it.subjectId == subjectId }?.entry.orEmpty(), - average = (average.singleOrNull { it.subjectId == subjectId }?.average ?: "0").replace(",", ".").takeIf { it.isNotBlank() }?.toDouble() ?: 0.0, - pointsSum = average.singleOrNull { it.subjectId == subjectId }?.pointsSum.orEmpty(), - proposedPoints = "", - finalPoints = "", - ) - } - fun List.mapGradesSummary() = map { GradeSummary( name = it.name, @@ -81,7 +44,3 @@ fun ScrapperGrades.mapGrades() = Grades( isForAdults = isForAdults, type = type, ) - -fun Pair, List>.mapGrades() = first.mapGradesDetails() to second.mapGradesSummary() - -fun Pair, GradesSummaryResponse>.mapGrades(dict: Dictionaries) = first.mapGradesDetails(dict) to second.mapGradesSummary(dict) diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/HomeworkMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/HomeworkMapper.kt index e407fbe1..e591f333 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/HomeworkMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/HomeworkMapper.kt @@ -1,26 +1,9 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.Homework import io.github.wulkanowy.sdk.pojo.HomeworkAttachment -import io.github.wulkanowy.sdk.scrapper.toLocalDate -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.mobile.homework.Homework as ApiHomework import io.github.wulkanowy.sdk.scrapper.homework.Homework as ScrapperHomework -fun List.mapHomework(dictionaries: Dictionaries) = map { - val employee = dictionaries.employees.singleOrNull { employee -> employee.id == it.employeeId } - Homework( - date = it.date.toLocalDate(), - entryDate = it.date.toLocalDate(), - subject = dictionaries.subjects.singleOrNull { subject -> subject.id == it.subjectId }?.name.orEmpty(), - content = it.content, - teacherSymbol = employee?.code.orEmpty(), - teacher = employee?.run { "$name $surname" }.orEmpty(), - attachments = emptyList(), - ) -} - fun List.mapHomework() = map { Homework( date = it.date.toLocalDate(), diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/MessagesMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/MessagesMapper.kt index 05634e60..b09f7385 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/MessagesMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/MessagesMapper.kt @@ -1,41 +1,15 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.normalizeRecipient import io.github.wulkanowy.sdk.pojo.Folder import io.github.wulkanowy.sdk.pojo.Message import io.github.wulkanowy.sdk.pojo.MessageAttachment import io.github.wulkanowy.sdk.pojo.MessageDetails import io.github.wulkanowy.sdk.pojo.MessageReplayDetails -import io.github.wulkanowy.sdk.toLocalDateTime import java.time.ZoneId -import io.github.wulkanowy.sdk.mobile.messages.Message as ApiMessage import io.github.wulkanowy.sdk.scrapper.messages.MessageDetails as ScrapperDetailsMessage import io.github.wulkanowy.sdk.scrapper.messages.MessageMeta as ScrapperMessageMeta import io.github.wulkanowy.sdk.scrapper.messages.MessageReplayDetails as ScrapperReplayDetailsMessage -@JvmName("mapApiMessages") -fun List.mapMessages(zoneId: ZoneId) = map { - Message( - globalKey = it.messageId.toString(), - id = it.messageId, - readBy = it.read?.toInt(), - unreadBy = it.unread?.toInt(), - unread = it.folder == "Odebrane" && it.readDateTime == null, - recipients = it.recipients?.map { recipient -> recipient.copy(name = recipient.name.normalizeRecipient()) }?.mapFromMobileToRecipients().orEmpty(), - correspondents = "", - mailbox = "", - folderId = when (it.folder) { - "Odebrane" -> 1 - "Wyslane" -> 2 - else -> 1 - }, - content = it.content, - date = it.sentDateTime.toLocalDateTime().atZone(zoneId), - subject = it.subject, - hasAttachments = false, - ) -} - fun List.mapMessages(zoneId: ZoneId, folderId: Folder) = map { Message( globalKey = it.apiGlobalKey, diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/NotesMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/NotesMapper.kt index abcfc4cb..e8dbb32c 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/NotesMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/NotesMapper.kt @@ -1,26 +1,9 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.Note import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory -import io.github.wulkanowy.sdk.scrapper.toLocalDate -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.mobile.notes.Note as ApiNote import io.github.wulkanowy.sdk.scrapper.notes.Note as ScrapperNote -fun List.mapNotes(dictionaries: Dictionaries) = map { - Note( - date = it.entryDate.toLocalDate(), - content = it.content, - teacherSymbol = dictionaries.teachers.singleOrNull { teacher -> teacher.id == it.employeeId }?.code.orEmpty(), - teacher = "${it.employeeName} ${it.employeeSurname}", - category = dictionaries.noteCategories.singleOrNull { cat -> cat.id == it.noteCategoryId }?.name.orEmpty(), - categoryType = NoteCategory.UNKNOWN, - showPoints = false, - points = 0, - ) -} - fun List.mapNotes() = map { Note( date = it.date.toLocalDate(), diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/RecipientMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/RecipientMapper.kt index 724b603d..e51dde72 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/RecipientMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/RecipientMapper.kt @@ -1,9 +1,7 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Teacher import io.github.wulkanowy.sdk.pojo.MailboxType import io.github.wulkanowy.sdk.pojo.Recipient -import io.github.wulkanowy.sdk.mobile.messages.Recipient as MobileRecipient import io.github.wulkanowy.sdk.scrapper.messages.Recipient as ScrapperRecipient fun List.mapRecipients() = map { @@ -18,32 +16,3 @@ fun ScrapperRecipient.mapToRecipient() = Recipient( schoolNameShort = schoolNameShort, type = MailboxType.fromLetter(type.letter), ) - -fun List.mapFromRecipientsToMobile() = map { - MobileRecipient( - loginId = it.mailboxGlobalKey.toInt(), - name = it.userName, - ) -} - -fun List.mapFromMobileToRecipients() = map { - Recipient( - mailboxGlobalKey = it.loginId.toString(), - fullName = it.name, - userName = it.name, - studentName = "", - schoolNameShort = "", - type = MailboxType.UNKNOWN, - ) -} - -fun List.mapRecipients(reportingUnitId: Int) = map { - Recipient( - mailboxGlobalKey = reportingUnitId.toString(), - fullName = "${it.name} ${it.surname}", - userName = "${it.name} ${it.surname}", - studentName = "", - schoolNameShort = "", - type = MailboxType.UNKNOWN, - ) -} diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapper.kt index 0815204d..4584a7ee 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapper.kt @@ -1,11 +1,6 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.exception.VulcanException -import io.github.wulkanowy.sdk.mobile.register.Student import io.github.wulkanowy.sdk.pojo.Semester -import io.github.wulkanowy.sdk.toLocalDate -import java.time.LocalDate.of -import java.time.Month import io.github.wulkanowy.sdk.scrapper.register.Semester as ScrapperSemester @JvmName("mapScrapperSemesters") @@ -23,30 +18,3 @@ fun List.mapSemesters() = map { unitId = it.unitId, ) } - -fun List.mapSemesters(studentId: Int) = filter { it.id == studentId }.map { - Semester( - diaryId = 0, - kindergartenDiaryId = 0, - diaryName = it.classSymbol, - schoolYear = it.periodDateFrom.toLocalDate().let { start -> if (start.month == Month.SEPTEMBER) start.year else start.year - 1 }, - semesterId = it.classificationPeriodId, - semesterNumber = it.periodNumber, - start = it.periodDateFrom.toLocalDate(), - end = it.periodDateTo.toLocalDate(), - classId = it.classId, - unitId = it.reportingUnitId, - ) -}.mockSecondSemester() - -private fun List.mockSecondSemester(): List { - if (size != 1) throw VulcanException("Expected semester list size 1, get $size") - val semester = single() - val secondSemester = semester.copy( - semesterNumber = if (semester.semesterNumber == 1) 2 else 1, - semesterId = if (semester.semesterNumber == 1) semester.semesterId + 1 else semester.semesterId - 1, - start = if (semester.semesterNumber == 1) semester.end.plusDays(1) else of(semester.schoolYear, 9, 1), - end = if (semester.semesterNumber == 1) of(semester.schoolYear + 1, 8, 31) else semester.start.minusDays(1), - ) - return (this + secondSemester) -} diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentMapper.kt index 40b1f5b1..5af60663 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentMapper.kt @@ -4,7 +4,6 @@ import io.github.wulkanowy.sdk.pojo.StudentGender import io.github.wulkanowy.sdk.pojo.StudentGuardian import io.github.wulkanowy.sdk.pojo.StudentInfo import io.github.wulkanowy.sdk.pojo.StudentPhoto -import io.github.wulkanowy.sdk.scrapper.toLocalDate import io.github.wulkanowy.sdk.scrapper.student.StudentGuardian as ScrapperStudentGuardian import io.github.wulkanowy.sdk.scrapper.student.StudentInfo as ScrapperStudentInfo import io.github.wulkanowy.sdk.scrapper.student.StudentPhoto as ScrapperStudentPhoto diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentsMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentsMapper.kt index fde7faf8..4a1fc853 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentsMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/StudentsMapper.kt @@ -2,35 +2,8 @@ package io.github.wulkanowy.sdk.mapper import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.pojo.Student -import io.github.wulkanowy.sdk.mobile.register.Student as ApiStudent import io.github.wulkanowy.sdk.scrapper.register.Student as ScrapperStudent -fun List.mapStudents(symbol: String) = map { - Student( - email = it.userLogin, - userName = it.userName, - userLogin = it.userLogin, - userLoginId = it.userLoginId, - isParent = it.userRole != "uczeń", - symbol = symbol, - studentId = it.id, - classId = it.classId, - className = it.classCode.orEmpty(), - studentName = it.name, - studentSurname = it.surname, - schoolSymbol = it.reportingUnitSymbol, - schoolShortName = it.reportingUnitShortcut, - schoolName = it.reportingUnitName, - loginType = Sdk.ScrapperLoginType.STANDARD, - loginMode = Sdk.Mode.API, - scrapperBaseUrl = "", - mobileBaseUrl = it.mobileBaseUrl, - privateKey = it.privateKey, - certificateKey = it.certificateKey, - semesters = mapSemesters(it.id), - ) -} - fun List.mapStudents() = map { Student( email = it.email, diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapper.kt index 60663f90..1e96f538 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapper.kt @@ -1,17 +1,8 @@ package io.github.wulkanowy.sdk.mapper import io.github.wulkanowy.sdk.pojo.Subject -import io.github.wulkanowy.sdk.mobile.dictionaries.Subject as ApiSubject import io.github.wulkanowy.sdk.scrapper.attendance.Subject as ScrapperSubject -@JvmName("mapApiSubjects") -fun List.mapSubjects() = listOf(Subject(-1, "Wszystkie")) + filter { it.active }.map { - Subject( - id = it.id, - name = it.name, - ) -} - fun List.mapSubjects() = map { Subject( id = it.value, diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TeacherMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TeacherMapper.kt index a4ff8c9d..79237c7f 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TeacherMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TeacherMapper.kt @@ -1,20 +1,8 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.Teacher -import io.github.wulkanowy.sdk.mobile.school.Teacher as ApiTeacher import io.github.wulkanowy.sdk.scrapper.school.Teacher as ScrapperTeacher -fun List.mapTeachers(dictionaries: Dictionaries) = mapNotNull { teacher -> - val item = dictionaries.employees.singleOrNull { it.id == teacher.employeeId } - if (item?.name == null) return@mapNotNull null - Teacher( - name = "${item.name} ${item.surname}", - short = item.code, - subject = dictionaries.subjects.singleOrNull { it.id == teacher.subjectId }?.name ?: teacher.role, - ) -} - fun List.mapTeachers() = map { Teacher( name = it.name, diff --git a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TimetableMapper.kt b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TimetableMapper.kt index c690899a..ff7ccf7e 100644 --- a/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TimetableMapper.kt +++ b/sdk/src/main/kotlin/io/github/wulkanowy/sdk/mapper/TimetableMapper.kt @@ -1,61 +1,16 @@ package io.github.wulkanowy.sdk.mapper -import io.github.wulkanowy.sdk.mobile.dictionaries.Dictionaries import io.github.wulkanowy.sdk.pojo.CompletedLesson import io.github.wulkanowy.sdk.pojo.Lesson import io.github.wulkanowy.sdk.pojo.LessonAdditional -import io.github.wulkanowy.sdk.pojo.TimetableDayHeader import io.github.wulkanowy.sdk.pojo.Timetable -import io.github.wulkanowy.sdk.toLocalDate -import io.github.wulkanowy.sdk.toLocalDateTime +import io.github.wulkanowy.sdk.pojo.TimetableDayHeader import java.time.ZoneId -import io.github.wulkanowy.sdk.mobile.timetable.Lesson as ApiTimetable import io.github.wulkanowy.sdk.scrapper.timetable.CompletedLesson as ScrapperCompletedLesson import io.github.wulkanowy.sdk.scrapper.timetable.Lesson as ScrapperTimetable import io.github.wulkanowy.sdk.scrapper.timetable.LessonAdditional as ScrapperTimetableAdditional -import io.github.wulkanowy.sdk.scrapper.timetable.TimetableDayHeader as ScrapperTimetableDayHeader import io.github.wulkanowy.sdk.scrapper.timetable.Timetable as ScrapperTimetableFull - -fun List.mapTimetableFull(dictionaries: Dictionaries, zoneId: ZoneId) = Timetable( - headers = emptyList(), - lessons = mapTimetable(dictionaries, zoneId), - additional = emptyList(), -) - -fun List.mapTimetable(dictionaries: Dictionaries, zoneId: ZoneId) = map { - val teacher = dictionaries.employees.singleOrNull { employee -> employee.id == it.employeeId } - val teacherOld = dictionaries.employees.singleOrNull { employee -> employee.id == it.employeeOldId } - val time = dictionaries.lessonTimes.single { time -> time.id == it.lessonTimeId } - val startDateTime = "${it.dayText} ${time.startText}".toLocalDateTime("yyyy-MM-dd HH:mm") - val endDateTime = "${it.dayText} ${time.endText}".toLocalDateTime("yyyy-MM-dd HH:mm") - Lesson( - canceled = it.overriddenName, - changes = it.boldName || (!it.annotationAboutChange.isNullOrBlank() && !it.overriddenName), - date = it.day.toLocalDate(), - start = startDateTime.atZone(zoneId), - end = endDateTime.atZone(zoneId), - group = it.divisionShort.orEmpty(), - info = it.annotationAboutChange?.substringAfter("(")?.substringBefore(")").orEmpty(), - number = it.lessonNumber, - room = it.room.orEmpty(), - roomOld = "", - subject = it.subjectName, - subjectOld = "", - studentPlan = it.studentPlan, - teacher = teacher?.run { "$name $surname" }.orEmpty(), - teacherOld = teacherOld?.run { "$name $surname" }.orEmpty(), - ) -}.groupBy { Triple(it.date, it.number, it.studentPlan) }.map { (_, lessons) -> - if (lessons.size > 1 && lessons.any { !it.canceled } && lessons.any { it.canceled }) { - val canceled = lessons.first { it.canceled } - val lesson = lessons.first { !it.canceled }.copy( - subjectOld = canceled.subject, - teacherOld = canceled.teacher, - roomOld = canceled.room, - ) - listOf(lesson) - } else lessons -}.flatten() +import io.github.wulkanowy.sdk.scrapper.timetable.TimetableDayHeader as ScrapperTimetableDayHeader fun ScrapperTimetableFull.mapTimetableFull(zoneId: ZoneId) = Timetable( headers = headers.mapTimetableDayHeaders(), diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/SdkRemoteTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/SdkRemoteTest.kt index be593272..d4609721 100644 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/SdkRemoteTest.kt +++ b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/SdkRemoteTest.kt @@ -1,13 +1,11 @@ package io.github.wulkanowy.sdk -import io.github.wulkanowy.sdk.pojo.Folder import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals import org.junit.Ignore import org.junit.Test -import java.time.LocalDate.of @Ignore @OptIn(ExperimentalCoroutinesApi::class) @@ -22,14 +20,6 @@ class SdkRemoteTest { "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCbF5Tt176EpB4cX5U+PZE0XytjJ9ABDZFaBFDkaexbkuNeuLOaARjQEOlUoBmpZQXxAF8HlYqeTvPiTcnSfQIS6EdqpICuQNdwvy6CHFAe2imkbbB0aHPsGep6zH8ZxHbssazkTCnGy0j2ZtGT2/iy1GEvc/p2bOkCVcR1H1GqFp+/XpfaMwi2SRCwc67K8Fu8TjSDKNvcRT9nuenGoPA1CWoOiOCxhQA6gnB8LULPel6TVDxeBVdYor/z2GxFe/m0pa7XAKzveuUDhH8k8NlNG65MjvZhgy9iFs+eBUq7lCZ0nuIsDzjnUrLSl4ciYKj9d94qrUyF8L8D9Rl+0WlAgMBAAECggEAQ6jg3rNmyxIg0rl0ZG/LjEF26RKR7P5KQLcpouESga3HfzHvsjMCq+OWZvciFhazRd4BQkdwZxGPnfa7ieGzmhtvs1pDu8zU/hE4UClV+EG6NpVpC2Q/sn5KZRijaZoY3eMGQUFatBzCBcLZxYspfbyR3ucLbu9DE+foNB1Fh4u9RCDj3bClTsqPcNBIaLMpYr3f/bM1fFbS9LrJ7AXZQtGg/2MH58WsvV67SiYAQqGCzld/Jp74gmod4Ii0w2XWZ7OeixdF2xr1j7TK0dUUlrrOrb1cgOWSOEXyy3RX/iF7R8uuLXiRfo1URh6VNPoOtrC6fHCrCp1iRBo08qOk4QKBgQDxqLrWA7gKcTr2yQeGfETXOAYi0xqbNj5A9eVC0XngxnFuwWc5zyg3Ps3c0UK2qTSSFv4SoeEHQM+U0+9LjYzIRSUH7zy4zBrBlLtTQCysSuuZ9QfgO55b3/QEYkyx6Hz/z/gg53jKHjsUKIftGMwJ6C1M2svbBNYCsWrUuYcsbQKBgQDN9gkVDABIeWUtKDHyB5HGcVbsg7Ji7GhMjdFA0GB+9kR0doKNctrzxKn65BI2uTWg+mxaw5V+UeJOIaeFsv2uClYJYn1F55VT7NIx3CLFv6zFRSiMSKz2W+NkwGjQqR7D3DeEyalpjeQeMdpHZg27LMbdVkzy/cK8EM9ZQlRLGQKBgQCpB2wn5dIE+85Sb6pj1ugP4Y/pK9+gUQCaT2RcqEingCY3Ye/h75QhkDxOB9CyEwhCZvKv9aqAeES5xMPMBOZD7plIQ34lhB3y6SVdxbV5ja3dshYgMZNCkBMOPfOHPSaxh7X2zfEe7qZEI1Vv8bhF9bA54ZBVUbyfhZlD0cFKwQKBgQC9BnXHb0BDQ8br7twH+ZJ8wkC4yRXLXJVMzUujZJtrarHhAXNIRoVU/MXUkcV1m/3wRGV119M4IAbHFnQdbO0N8kaMTmwS4DxYzh0LzbHMM+JpGtPgDENRx3unWD/aYZzuvQnnQP3O9n7Kh46BwNQRWUMamL3+tY8n83WZwhqC4QKBgBTUzHy0sEEZ3hYgwU2ygbzC0vPladw2KqtKy+0LdHtx5pqE4/pvhVMpRRTNBDiAvb5lZmMB/B3CzoiMQOwczuus8Xsx7bEci28DzQ+g2zt0/bC2Xl+992Ass5PP5NtOrP/9QiTNgoFSCrVnZnNzQqpjCrFsjfOD2fiuFLCD6zi6" } - @Test - fun getStudents_api() { - val sdk = Sdk() - sdk.setSimpleHttpLogger { println(it) } - val students = runBlocking { sdk.getStudentsFromMobileApi(token = "FK100000", pin = "999999", symbol = "powiatwulkanowy", apiKey = API_KEY, firebaseToken = "") } - assertEquals(2, students.size) - } - @Test fun getStudents_scrapper() { val sdk = Sdk().apply { @@ -41,68 +31,9 @@ class SdkRemoteTest { assertEquals(6, students.size) } - @Test - fun getStudents_hybrid() { - val sdk = Sdk().apply { - // mode = Sdk.Mode.HYBRID - } - - val students = runBlocking { - sdk.getStudentsHybrid( - email = "jan@fakelog.cf", - password = "jan123", - apiKey = API_KEY, - scrapperBaseUrl = "http://fakelog.cf", - startSymbol = "powiatwulkanowy", - firebaseToken = "", - ) - } - assertEquals(6, students.size) - } - - @Test - fun getSemesters_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 1 - classId = 14 - } - - val semesters = runBlocking { sdk.getSemesters() } - assertEquals(2, semesters.size) - } - - @Test - fun getGrades_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val grades = runBlocking { sdk.getGrades(1).details } - assertEquals(22, grades.size) - } - @Test fun getGrades_scrapper() = runTest { val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - userAgentTemplate = "custom UA %1\$s%2\$s%3\$s%4\$s" mode = Sdk.Mode.SCRAPPER symbol = "powiatwulkanowy" @@ -124,201 +55,4 @@ class SdkRemoteTest { assertEquals(22, grades.size) assertEquals(22, grades2.details.size) } - - @Test - fun getGradesSummary_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val grades = runBlocking { sdk.getGrades(1).summary } - assertEquals(4, grades.size) - } - - @Test - fun getAttendance_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val attendance = runBlocking { sdk.getAttendance(of(2018, 1, 1), of(2018, 1, 2), 1) } - assertEquals(24, attendance.size) - } - - @Test - fun getSubjects_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val subjects = runBlocking { sdk.getSubjects() } - assertEquals(14, subjects.size) - } - - @Test - fun getNotes_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val notes = runBlocking { sdk.getNotes(1) } - assertEquals(5, notes.size) - } - - @Test - fun getTeachers_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val teachers = runBlocking { sdk.getTeachers(1) } - assertEquals(9, teachers.size) - } - - @Test - fun getHomework_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val homework = runBlocking { sdk.getHomework(of(2018, 1, 1), of(2018, 1, 2)) } - assertEquals(4, homework.size) - } - - @Test - fun getTimetable_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val (timetable) = runBlocking { sdk.getTimetable(of(2018, 1, 1), of(2018, 1, 2)) } - assertEquals(24, timetable.size) - } - - @Test - fun getMessages_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - studentId = 15 - classId = 14 - } - - val messages = runBlocking { sdk.getMessages(Folder.RECEIVED) } - assertEquals(2, messages.size) - - val messagesSent = runBlocking { sdk.getMessages(Folder.SENT) } - assertEquals(1, messagesSent.size) - - val messagesTrashed = runBlocking { sdk.getMessages(Folder.TRASHED) } - assertEquals(1, messagesTrashed.size) - } - - @Test - fun readMessage_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - loginId = 16 - studentId = 15 - classId = 14 - } - - val message = runBlocking { sdk.getMessageDetails("asdf") } - assertEquals("Zmiana statusu wiadomości.", message.content) - } - - @Test - fun deleteMessage_api() { - val sdk = Sdk().apply { - privateKey = PRIVATE_KEY - certKey = CERT_KEY - - mobileBaseUrl = "https://api.fakelog.cf/powiatwulkanowy" - mode = Sdk.Mode.API - symbol = "powiatwulkanowy" - - schoolSymbol = "123456" - loginId = 16 - studentId = 15 - classId = 14 - } - - runBlocking { sdk.deleteMessages(listOf()) } - } } diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapperTest.kt deleted file mode 100644 index 79516e95..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/AttendanceMapperTest.kt +++ /dev/null @@ -1,118 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.scrapper.attendance.Attendance -import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test -import java.time.LocalDateTime - -class AttendanceMapperTest : BaseLocalTest() { - - @Test - fun getAttendance_presence() { - createAttendance(AttendanceCategory.PRESENCE).mapAttendance()[0].run { - assertTrue(presence) - assertFalse(excused) - - assertFalse(absence) - assertFalse(exemption) - assertFalse(lateness) - } - } - - @Test - fun getAttendance_absence() { - createAttendance(AttendanceCategory.ABSENCE_UNEXCUSED).mapAttendance()[0].run { - assertTrue(absence) - assertFalse(excused) - - assertFalse(exemption) - assertFalse(presence) - assertFalse(lateness) - } - } - - @Test - fun getAttendance_absenceExcused() { - createAttendance(AttendanceCategory.ABSENCE_EXCUSED).mapAttendance()[0].run { - assertTrue(absence) - assertTrue(excused) - - assertFalse(exemption) - assertFalse(presence) - assertFalse(lateness) - } - } - - @Test - fun getAttendance_lateness() { - createAttendance(AttendanceCategory.UNEXCUSED_LATENESS).mapAttendance()[0].run { - assertTrue(lateness) - assertFalse(excused) - - assertFalse(exemption) - assertFalse(presence) - assertFalse(absence) - } - } - - @Test - fun getAttendance_latenessExcused() { - createAttendance(AttendanceCategory.EXCUSED_LATENESS).mapAttendance()[0].run { - assertTrue(lateness) - assertTrue(excused) - - assertFalse(exemption) - assertFalse(presence) - assertFalse(absence) - } - } - - @Test - fun getAttendance_absenceForSchoolReason() { - createAttendance(AttendanceCategory.ABSENCE_FOR_SCHOOL_REASONS).mapAttendance()[0].run { - assertTrue(presence) - assertFalse(excused) - - assertFalse(lateness) - assertFalse(exemption) - assertFalse(absence) - } - } - - @Test - fun getAttendance_exemption() { - createAttendance(AttendanceCategory.EXEMPTION).mapAttendance()[0].run { - assertTrue(exemption) - assertFalse(excused) - - assertFalse(lateness) - assertFalse(presence) - assertFalse(absence) - } - } - - @Test - fun getAttendance_unknown() { - createAttendance(AttendanceCategory.UNKNOWN).mapAttendance()[0].run { - assertFalse(exemption) - assertFalse(excused) - - assertFalse(lateness) - assertFalse(presence) - assertFalse(absence) - } - } - - private fun createAttendance(cat: AttendanceCategory): List { - val item = Attendance(1, LocalDateTime.now(), "").apply { - number = 0 - category = cat - excusable = false - excuseStatus = null - } - return listOf(item) - } -} diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapperTest.kt deleted file mode 100644 index 0b28b798..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/ExamsMapperTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.Sdk -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.exams.ExamsTest -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import java.time.LocalDate.now - -class ExamsMapperTest : BaseLocalTest() { - - private val mobile by lazy { - Sdk().apply { - mode = Sdk.Mode.API - mobileBaseUrl = server.url("/").toString() - } - } - - @Test - fun getApiExams() { - server.enqueueAndStart("Sprawdziany.json", ExamsTest::class.java) - server.enqueue("Slowniki.json", BaseLocalTest::class.java) - - val exams = runBlocking { mobile.getExams(now(), now(), 1) } - assertEquals(3, exams.size) - - assertEquals("Sprawdzian", exams[0].type) - assertEquals("Kartkówka", exams[1].type) - assertEquals("Praca klasowa", exams[2].type) - } -} diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapperTest.kt deleted file mode 100644 index ed6290e8..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/GradesMapperTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.Sdk -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.grades.GradesTest -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test - -class GradesMapperTest : BaseLocalTest() { - - private val mobile by lazy { - Sdk().apply { - mode = Sdk.Mode.API - mobileBaseUrl = server.url("/").toString() - } - } - - @Test - fun getApiGrades() { - server.enqueueAndStart("Oceny.json", GradesTest::class.java) - server.enqueue("OcenyPodsumowanie.json", GradesTest::class.java) - server.enqueue("Slowniki.json", BaseLocalTest::class.java) - - val grades = runBlocking { mobile.getGrades(0).details } - assertEquals(2, grades.size) - - with(grades[0]) { - assertEquals("3", entry) - assertEquals("Akt", symbol) - assertEquals("Aktywność", description) - } - } -} diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/LessonMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/LessonMapperTest.kt deleted file mode 100644 index 38fc626d..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/LessonMapperTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.Sdk -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.timetable.TimetableTest -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import java.time.LocalDate.of -import java.time.LocalDateTime -import java.time.ZoneId -import java.time.ZonedDateTime - -class LessonMapperTest : BaseLocalTest() { - - private val mobile by lazy { - Sdk().apply { - mode = Sdk.Mode.API - mobileBaseUrl = server.url("/").toString() - } - } - - @Test - fun getApiTimetable() { - server.enqueueAndStart("PlanLekcji.json", TimetableTest::class.java) - server.enqueue("Slowniki.json", BaseLocalTest::class.java) - - val (_, lessons, _) = runBlocking { mobile.getTimetable(of(2020, 2, 3), of(2020, 2, 4)) } - assertEquals(4, lessons.size) - - with(lessons[1]) { - assertEquals(2, number) - assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 8, 55, 0), ZoneId.of("Europe/Warsaw")), start) - assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 9, 40, 0), ZoneId.of("Europe/Warsaw")), end) - - assertEquals("Sieci komputerowe", subject) - assertEquals("t.infor", group) - assertEquals("Stanisław Krupa", teacher) - assertEquals("G1", room) - assertEquals("przeniesiona z lekcji 1, 10.02.2020", info) - assertEquals("Wychowanie fizyczne", subjectOld) - assertEquals("Mateusz Kowal", teacherOld) - assertEquals("S4", roomOld) - - assertEquals(false, canceled) - assertEquals(true, changes) - } - } - - @Test - fun getApiTimetable_canceledWithInfoAboutChange() { - server.enqueueAndStart("PlanLekcji.json", TimetableTest::class.java) - server.enqueue("Slowniki.json", BaseLocalTest::class.java) - - val (_, lessons, _) = runBlocking { mobile.getTimetable(of(2020, 2, 3), of(2020, 2, 4)) } - - with(lessons[3]) { - assertEquals(4, number) - - assertEquals("nieobecny oddział - Zwiedzanie Muzeum II Wojny Światowej w Gdańsku.", info) - - assertEquals(true, canceled) - assertEquals(false, changes) - } - } -} diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapperTest.kt deleted file mode 100644 index cdfbd990..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SemesterMapperTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.Sdk -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import io.github.wulkanowy.sdk.mobile.register.RegisterTest -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test -import java.time.LocalDate.of - -class SemesterMapperTest : BaseLocalTest() { - - private val mobile by lazy { - Sdk().apply { - mode = Sdk.Mode.API - mobileBaseUrl = server.url("/").toString() - } - } - - @Test - fun getStudents_api2() { - server.enqueueAndStart("ListaUczniow.json", RegisterTest::class.java) - - mobile.studentId = 1 - val semesters = runBlocking { mobile.getSemesters() } - assertEquals(2, semesters.size) - - with(semesters[0]) { - assertEquals(2, semesterNumber) - assertEquals(of(2020, 1, 30), start) - } - with(semesters[1]) { - assertEquals(1, semesterNumber) - assertEquals(of(2019, 9, 1), start) - } - } - - @Test - fun getStudents_api1() { - server.enqueueAndStart("ListaUczniow-2.json", RegisterTest::class.java) - - mobile.studentId = 1 - val semesters = runBlocking { mobile.getSemesters() } - assertEquals(2, semesters.size) - - with(semesters[0]) { - assertEquals(1, semesterNumber) - assertEquals(of(2019, 9, 1), start) - } - with(semesters[1]) { - assertEquals(2, semesterNumber) - assertEquals(of(2020, 1, 30), start) - } - } -} diff --git a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapperTest.kt b/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapperTest.kt deleted file mode 100644 index d1805213..00000000 --- a/sdk/src/test/kotlin/io/github/wulkanowy/sdk/mapper/SubjectsMapperTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.wulkanowy.sdk.mapper - -import io.github.wulkanowy.sdk.Sdk -import io.github.wulkanowy.sdk.mobile.BaseLocalTest -import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Test - -class SubjectsMapperTest : BaseLocalTest() { - - private val mobile by lazy { - Sdk().apply { - mode = Sdk.Mode.API - mobileBaseUrl = server.url("/").toString() - } - } - - @Test - fun getApiSubjects() { - server.enqueueAndStart("Slowniki.json", BaseLocalTest::class.java) - - val subjects = runBlocking { mobile.getSubjects() } - assertEquals(15, subjects.size) - with(subjects[0]) { - assertEquals(-1, id) - assertEquals("Wszystkie", name) - } - } -} diff --git a/settings.gradle b/settings.gradle index 3ec56ff8..10614318 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ -include 'sdk-mobile' include 'sdk-scrapper' include 'sdk'