Add basic method to fetch exams from hebe

This commit is contained in:
Mikołaj Pich 2023-04-29 17:19:35 +02:00
parent a18fe84ce7
commit efd332d4f3
9 changed files with 382 additions and 8 deletions

View file

@ -4,6 +4,7 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
public static synthetic fun addInterceptor$default (Lio/github/wulkanowy/sdk/hebe/Hebe;Lokhttp3/Interceptor;ZILjava/lang/Object;)V
public final fun getBaseUrl ()Ljava/lang/String;
public final fun getDeviceModel ()Ljava/lang/String;
public final fun getExams (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGrades (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGradesAverage (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGradesSummary (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -40,6 +41,230 @@ public final class io/github/wulkanowy/sdk/hebe/exception/UnknownTokenException
public fun <init> (Ljava/lang/String;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$Companion;
public synthetic fun <init> (ILjava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;ILjava/lang/String;ILio/github/wulkanowy/sdk/hebe/models/Exam$Subject;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;ILjava/lang/String;ILio/github/wulkanowy/sdk/hebe/models/Exam$Subject;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun component10 ()Ljava/lang/String;
public final fun component2 ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;
public final fun component3 ()Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;
public final fun component4 ()Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;
public final fun component5 ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;
public final fun component6 ()I
public final fun component7 ()Ljava/lang/String;
public final fun component8 ()I
public final fun component9 ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;
public final fun copy (Ljava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;ILjava/lang/String;ILio/github/wulkanowy/sdk/hebe/models/Exam$Subject;Ljava/lang/String;)Lio/github/wulkanowy/sdk/hebe/models/Exam;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam;Ljava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;ILjava/lang/String;ILio/github/wulkanowy/sdk/hebe/models/Exam$Subject;Ljava/lang/String;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam;
public fun equals (Ljava/lang/Object;)Z
public final fun getContent ()Ljava/lang/String;
public final fun getCreator ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;
public final fun getDateCreated ()Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;
public final fun getDateModify ()Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;
public final fun getDeadline ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;
public final fun getId ()I
public final fun getKey ()Ljava/lang/String;
public final fun getPupilId ()I
public final fun getSubject ()Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;
public final fun getType ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Creator {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator$Companion;
public synthetic fun <init> (ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()I
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;
public fun equals (Ljava/lang/Object;)Z
public final fun getDisplayName ()Ljava/lang/String;
public final fun getId ()I
public final fun getName ()Ljava/lang/String;
public final fun getSurname ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Creator$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam$Creator;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Creator$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateCreated {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated$Companion;
public synthetic fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()J
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;
public fun equals (Ljava/lang/Object;)Z
public final fun getDate ()Ljava/lang/String;
public final fun getDateDisplay ()Ljava/lang/String;
public final fun getTime ()Ljava/lang/String;
public final fun getTimestamp ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateCreated$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateCreated;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateCreated$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateModify {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify$Companion;
public synthetic fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()J
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;
public fun equals (Ljava/lang/Object;)Z
public final fun getDate ()Ljava/lang/String;
public final fun getDateDisplay ()Ljava/lang/String;
public final fun getTime ()Ljava/lang/String;
public final fun getTimestamp ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateModify$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam$DateModify;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$DateModify$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Deadline {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline$Companion;
public synthetic fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()J
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;
public fun equals (Ljava/lang/Object;)Z
public final fun getDate ()Ljava/lang/String;
public final fun getDateDisplay ()Ljava/lang/String;
public final fun getTime ()Ljava/lang/String;
public final fun getTimestamp ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Deadline$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam$Deadline;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Deadline$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Subject {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject$Companion;
public synthetic fun <init> (IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
public final fun component1 ()I
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()I
public final fun copy (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;
public fun equals (Ljava/lang/Object;)Z
public final fun getId ()I
public final fun getKey ()Ljava/lang/String;
public final fun getKod ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getPosition ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Subject$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/Exam$Subject;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Exam$Subject$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/Grade {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Grade$Companion;
public synthetic fun <init> (ILio/github/wulkanowy/sdk/hebe/models/Grade$Column;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Grade$Creator;Lio/github/wulkanowy/sdk/hebe/models/Grade$DateCreated;Lio/github/wulkanowy/sdk/hebe/models/Grade$DateModify;ILjava/lang/String;Lio/github/wulkanowy/sdk/hebe/models/Grade$Modifier;ILjava/lang/Double;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V

View file

@ -1,5 +1,6 @@
package io.github.wulkanowy.sdk.hebe
import io.github.wulkanowy.sdk.hebe.models.Exam
import io.github.wulkanowy.sdk.hebe.models.Grade
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
@ -138,4 +139,10 @@ class Hebe {
periodId = periodId,
)
}
suspend fun getExams(): List<Exam> {
return studentRepository.getExams(
pupilId = pupilId,
)
}
}

View file

@ -0,0 +1,91 @@
package io.github.wulkanowy.sdk.hebe.models
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class Exam(
@SerialName("Content")
val content: String,
@SerialName("Creator")
val creator: Creator,
@SerialName("DateCreated")
val dateCreated: DateCreated,
@SerialName("DateModify")
val dateModify: DateModify,
@SerialName("Deadline")
val deadline: Deadline,
@SerialName("Id")
val id: Int,
@SerialName("Key")
val key: String,
@SerialName("PupilId")
val pupilId: Int,
@SerialName("Subject")
val subject: Subject,
@SerialName("Type")
val type: String,
) {
@Serializable
data class Creator(
@SerialName("DisplayName")
val displayName: String,
@SerialName("Id")
val id: Int,
@SerialName("Name")
val name: String,
@SerialName("Surname")
val surname: String,
)
@Serializable
data class DateCreated(
@SerialName("Date")
val date: String,
@SerialName("DateDisplay")
val dateDisplay: String,
@SerialName("Time")
val time: String,
@SerialName("Timestamp")
val timestamp: Long,
)
@Serializable
data class DateModify(
@SerialName("Date")
val date: String,
@SerialName("DateDisplay")
val dateDisplay: String,
@SerialName("Time")
val time: String,
@SerialName("Timestamp")
val timestamp: Long,
)
@Serializable
data class Deadline(
@SerialName("Date")
val date: String,
@SerialName("DateDisplay")
val dateDisplay: String,
@SerialName("Time")
val time: String,
@SerialName("Timestamp")
val timestamp: Long,
)
@Serializable
data class Subject(
@SerialName("Id")
val id: Int,
@SerialName("Key")
val key: String,
@SerialName("Kod")
val kod: String,
@SerialName("Name")
val name: String,
@SerialName("Position")
val position: Int,
)
}

View file

@ -1,6 +1,7 @@
package io.github.wulkanowy.sdk.hebe.repository
import io.github.wulkanowy.sdk.hebe.getEnvelopeOrThrowError
import io.github.wulkanowy.sdk.hebe.models.Exam
import io.github.wulkanowy.sdk.hebe.models.Grade
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
@ -28,4 +29,20 @@ internal class StudentRepository(private val studentService: StudentService) {
periodId = periodId,
).getEnvelopeOrThrowError().orEmpty()
}
suspend fun getExams(pupilId: Int): List<Exam> {
return studentService.getExams(
createQueryMap(pupilId = pupilId),
).getEnvelopeOrThrowError().orEmpty()
}
private fun createQueryMap(pupilId: Int, periodId: Int? = null): Map<String, Any?> {
return mapOf(
"pupilId" to pupilId,
"periodId" to periodId,
"lastSyncDate" to "1970-01-01 01:00:00",
"lastId" to Int.MIN_VALUE,
"pageSize" to 500,
)
}
}

View file

@ -1,12 +1,15 @@
package io.github.wulkanowy.sdk.hebe.service
import io.github.wulkanowy.sdk.hebe.ApiResponse
import io.github.wulkanowy.sdk.hebe.models.Exam
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 retrofit2.http.GET
import retrofit2.http.Query
import retrofit2.http.QueryMap
@JvmSuppressWildcards
internal interface StudentService {
@GET("api/mobile/grade/byPupil")
@ -18,7 +21,7 @@ internal interface StudentService {
@Query("pageSize") pageSize: Int = 500,
): ApiResponse<List<Grade>>
@GET("api/mobile/grade/average/byPupil")
@GET("api/mobile/grade/summary/byPupil")
suspend fun getGradesSummary(
@Query("pupilId") pupilId: Int,
@Query("periodId") periodId: Int,
@ -35,4 +38,7 @@ internal interface StudentService {
@Query("lastId") lastId: Int = Int.MIN_VALUE,
@Query("pageSize") pageSize: Int = 500,
): ApiResponse<List<GradeAverage>>
@GET("api/mobile/exam/byPupil")
suspend fun getExams(@QueryMap query: Map<String, Any?>): ApiResponse<List<Exam>>
}

View file

@ -30,12 +30,18 @@ class HebeRemoteTest {
@Test
fun `register device`() = runTest {
val res = hebe.register(
firebaseToken = "###",
token = "FK11234",
pin = "12334",
symbol = "powiatwulkanowy",
firebaseToken = "",
token = "3S1JDDR",
pin = "212343",
symbol = "gminanowosolna",
)
println(res)
assertTrue(res.privatePem.isNotEmpty())
}
@Test
fun `get students`() = runTest {
val res = hebe.getStudents(hebe.baseUrl)
assertTrue(res.isNotEmpty())
}
@Test
@ -49,4 +55,10 @@ class HebeRemoteTest {
val summaries = hebe.getGradesSummary(559)
assertTrue(summaries.isNotEmpty())
}
@Test
fun `get exams`() = runTest {
val exams = hebe.getExams()
assertTrue(exams.isNotEmpty())
}
}

View file

@ -364,7 +364,7 @@ class Sdk {
suspend fun getExams(start: LocalDate, end: LocalDate): List<Exam> = withContext(Dispatchers.IO) {
when (mode) {
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getExams(start, end).mapExams()
Mode.HEBE -> throw NotImplementedError("Not available in HEBE mode")
Mode.HEBE -> hebe.getExams().mapExams()
}
}

View file

@ -1,8 +1,11 @@
package io.github.wulkanowy.sdk.mapper
import io.github.wulkanowy.sdk.pojo.Exam
import io.github.wulkanowy.sdk.toLocalDate
import io.github.wulkanowy.sdk.scrapper.exams.Exam as ScrapperExam
import io.github.wulkanowy.sdk.hebe.models.Exam as HebeExam
@JvmName("mapScrapperExams")
internal fun List<ScrapperExam>.mapExams() = map {
Exam(
date = it.date.toLocalDate(),
@ -14,3 +17,16 @@ internal fun List<ScrapperExam>.mapExams() = map {
type = it.typeName,
)
}
@JvmName("mapHebeExams")
internal fun List<HebeExam>.mapExams() = map {
Exam(
date = it.dateCreated.timestamp.toLocalDate(),
entryDate = it.deadline.timestamp.toLocalDate(),
description = it.content,
subject = it.subject.name,
teacher = it.creator.displayName,
teacherSymbol = "",
type = it.type,
)
}

View file

@ -80,7 +80,7 @@ internal fun Triple<List<HebeGrade>, List<HebeGradeSummary>, List<HebeGradeAvera
finalPoints = "",
)
},
isAverage = false,
isAverage = third.isNotEmpty(),
isPoints = false,
isForAdults = false,
type = 0,