Hebe: Add support for fetching conferences
This commit is contained in:
parent
f21f09ad5c
commit
73941729f0
7 changed files with 46 additions and 4 deletions
|
@ -11,6 +11,7 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
|
|||
public final fun getKeyId ()Ljava/lang/String;
|
||||
public final fun getLogLevel ()Lokhttp3/logging/HttpLoggingInterceptor$Level;
|
||||
public final fun getMailboxes (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getMeetings (ILjava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getMessages (Ljava/lang/String;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getPeriods (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getPrivatePem ()Ljava/lang/String;
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.github.wulkanowy.sdk.hebe.models.Grade
|
|||
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
|
||||
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
|
||||
import io.github.wulkanowy.sdk.hebe.models.Mailbox
|
||||
import io.github.wulkanowy.sdk.hebe.models.Meeting
|
||||
import io.github.wulkanowy.sdk.hebe.models.Message
|
||||
import io.github.wulkanowy.sdk.hebe.models.Teacher
|
||||
import io.github.wulkanowy.sdk.hebe.register.RegisterDevice
|
||||
|
@ -162,6 +163,11 @@ class Hebe {
|
|||
|
||||
suspend fun getRecipients(mailboxKey: String) = studentRepository.getRecipients(mailboxKey)
|
||||
|
||||
suspend fun getMeetings(pupilId: Int, startDate: LocalDate): List<Meeting> = studentRepository.getMeetings(
|
||||
pupilId = pupilId,
|
||||
startDate = startDate,
|
||||
)
|
||||
|
||||
suspend fun setMessageStatus(pupilId: Int?, boxKey: String, messageKey: String, status: Int): Boolean? = studentRepository.setMessageStatus(
|
||||
pupilId = pupilId,
|
||||
boxKey = boxKey,
|
||||
|
|
|
@ -73,6 +73,18 @@ internal class StudentRepository(
|
|||
).getEnvelopeOrThrowError()
|
||||
.orEmpty()
|
||||
|
||||
suspend fun getMeetings(pupilId: Int, startDate: LocalDate) = studentService
|
||||
.getMeetings(
|
||||
mapOf(
|
||||
"pupilId" to pupilId,
|
||||
"lastSyncDate" to "1970-01-01 01:00:00",
|
||||
"lastId" to Int.MIN_VALUE,
|
||||
"pageSize" to 500,
|
||||
"from" to startDate.format(DateTimeFormatter.ISO_DATE),
|
||||
),
|
||||
).getEnvelopeOrThrowError()
|
||||
.orEmpty()
|
||||
|
||||
suspend fun setMessageStatus(pupilId: Int?, boxKey: String, messageKey: String, status: Int) = studentService
|
||||
.setStatus(
|
||||
ApiRequest(
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.github.wulkanowy.sdk.hebe.models.Grade
|
|||
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
|
||||
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
|
||||
import io.github.wulkanowy.sdk.hebe.models.Mailbox
|
||||
import io.github.wulkanowy.sdk.hebe.models.Meeting
|
||||
import io.github.wulkanowy.sdk.hebe.models.Message
|
||||
import io.github.wulkanowy.sdk.hebe.models.Recipient
|
||||
import io.github.wulkanowy.sdk.hebe.models.SetMessageStatusRequest
|
||||
|
@ -43,6 +44,9 @@ internal interface StudentService {
|
|||
@GET("api/mobile/addressbook")
|
||||
suspend fun getRecipients(@QueryMap query: Map<String, Any?>): ApiResponse<List<Recipient>>
|
||||
|
||||
@GET("api/mobile/meetings/byPupil")
|
||||
suspend fun getMeetings(@QueryMap query: Map<String, Any?>): ApiResponse<List<Meeting>>
|
||||
|
||||
@POST("api/mobile/messages/statuses")
|
||||
suspend fun setStatus(@Body request: ApiRequest<List<SetMessageStatusRequest>>): ApiResponse<Boolean>
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ public final class io/github/wulkanowy/sdk/Sdk {
|
|||
public final fun getClassId ()I
|
||||
public final fun getCompletedLessons (Ljava/time/LocalDate;Ljava/time/LocalDate;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun getCompletedLessons$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/time/LocalDate;Ljava/time/LocalDate;ILkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public final fun getConferences (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getConferences (ILjava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun getConferences$default (Lio/github/wulkanowy/sdk/Sdk;ILjava/time/LocalDate;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public final fun getCurrentStudent (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getDeletedMessages (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun getDeletedMessages$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
|
|
|
@ -515,10 +515,10 @@ class Sdk {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getConferences(): List<Conference> = withContext(Dispatchers.IO) {
|
||||
suspend fun getConferences(pupilId: Int = 0, startDate: LocalDate = LocalDate.of(1970, 1, 1)): List<Conference> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getConferences().mapConferences(registerTimeZone)
|
||||
Mode.HEBE -> throw NotImplementedError("Not available in HEBE mode")
|
||||
Mode.SCRAPPER -> scrapper.getConferences().mapConferences(registerTimeZone)
|
||||
Mode.HYBRID, Mode.HEBE -> hebe.getMeetings(pupilId, startDate).mapConferences(registerTimeZone)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package io.github.wulkanowy.sdk.mapper
|
||||
|
||||
import io.github.wulkanowy.sdk.pojo.Conference
|
||||
import io.github.wulkanowy.sdk.toLocalDateTime
|
||||
import java.time.ZoneId
|
||||
import io.github.wulkanowy.sdk.hebe.models.Meeting as HebeConference
|
||||
import io.github.wulkanowy.sdk.scrapper.conferences.Conference as ScrapperConference
|
||||
|
||||
@JvmName("ScrapperConferenceMapper")
|
||||
internal fun List<ScrapperConference>.mapConferences(zoneId: ZoneId) = map {
|
||||
Conference(
|
||||
place = it.place,
|
||||
|
@ -15,3 +18,18 @@ internal fun List<ScrapperConference>.mapConferences(zoneId: ZoneId) = map {
|
|||
id = it.id,
|
||||
)
|
||||
}
|
||||
|
||||
@JvmName("HebeConferenceMapper")
|
||||
internal fun List<HebeConference>.mapConferences(zoneId: ZoneId) = map {
|
||||
Conference(
|
||||
place = it.where,
|
||||
topic = it.why,
|
||||
agenda = it.agenda,
|
||||
presentOnConference = "",
|
||||
online = it.online,
|
||||
date = it.`when`.timestamp
|
||||
.toLocalDateTime()
|
||||
.atZone(zoneId),
|
||||
id = it.id,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue