Add notes api

This commit is contained in:
Mikołaj Pich 2018-07-11 14:23:28 +02:00
parent 8e9e927219
commit ee5d7d3db8
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
5 changed files with 80 additions and 0 deletions

View file

@ -8,6 +8,8 @@ import io.github.wulkanowy.sdk.exams.Exam
import io.github.wulkanowy.sdk.exams.ExamsRequest
import io.github.wulkanowy.sdk.grades.Grade
import io.github.wulkanowy.sdk.grades.GradesRequest
import io.github.wulkanowy.sdk.notes.Note
import io.github.wulkanowy.sdk.notes.NotesReequest
import io.github.wulkanowy.sdk.timetable.Lesson
import io.github.wulkanowy.sdk.timetable.TimetableRequest
import retrofit2.http.Body
@ -30,4 +32,7 @@ interface MobileApi {
@POST("Sprawdziany")
fun getExams(@Body examsRequest: ExamsRequest): Observable<ApiResponse<List<Exam>>>
@POST("UwagiUcznia")
fun getNotes(@Body notesReequest: NotesReequest): Observable<ApiResponse<List<Note>>>
}

View file

@ -0,0 +1,48 @@
package io.github.wulkanowy.sdk.notes
import com.google.gson.annotations.SerializedName
data class Note(
@SerializedName("Id")
val id: Int,
@SerializedName("IdKategoriaUwag")
val noteCategoryId: Int,
@SerializedName("IdUczen")
val studentId: Int,
@SerializedName("UczenImie")
val studentName: String,
@SerializedName("UczenNazwisko")
val studentSurname: String,
@SerializedName("IdPracownik")
val employeeId: Int,
@SerializedName("PracownikImie")
val employeeName: String,
@SerializedName("PracownikNazwisko")
val employeeSurname: String,
@SerializedName("DataWpisu")
val entryDate: String,
@SerializedName("DataWpisuTekst")
val entryDateText: String,
@SerializedName("DataModyfikacji")
val modificationDate: Long?,
@SerializedName("DataModyfikacjiTekst")
val modificationDateText: String?,
@SerializedName("UwagaKey")
val noteKey: String,
@SerializedName("TrescUwagi")
val content: String
)

View file

@ -0,0 +1,13 @@
package io.github.wulkanowy.sdk.notes
import com.google.gson.annotations.SerializedName
import io.github.wulkanowy.sdk.base.ApiRequest
data class NotesReequest(
@SerializedName("IdOkresKlasyfikacyjny")
val classificationPeriodId: Int,
@SerializedName("IdUczen")
val studentId: Int
) : ApiRequest()

View file

@ -10,6 +10,8 @@ import io.github.wulkanowy.sdk.grades.Grade
import io.github.wulkanowy.sdk.grades.GradesRequest
import io.github.wulkanowy.sdk.interceptor.SignInterceptor
import io.github.wulkanowy.sdk.interfaces.MobileApi
import io.github.wulkanowy.sdk.notes.Note
import io.github.wulkanowy.sdk.notes.NotesReequest
import io.github.wulkanowy.sdk.timetable.Lesson
import io.github.wulkanowy.sdk.timetable.TimetableRequest
import okhttp3.OkHttpClient
@ -41,6 +43,10 @@ class MobileRepository(private val host: String, private val symbol: String, pri
return getMobileApi().getExams(ExamsRequest(startDate, endDate, classId, classificationPeriodId, studentId))
}
fun getNotes(classificationPeriodId: Int, studentId: Int): Observable<ApiResponse<List<Note>>> {
return getMobileApi().getNotes(NotesReequest(classificationPeriodId, studentId))
}
private fun getMobileApi(): MobileApi {
return Retrofit.Builder()
.baseUrl("$host/$symbol/$reportingUnitSymbol/mobile-api/Uczen.v3.Uczen/")

View file

@ -4,6 +4,7 @@ import io.github.wulkanowy.sdk.base.ApiResponse
import io.github.wulkanowy.sdk.dictionaries.Dictionaries
import io.github.wulkanowy.sdk.exams.Exam
import io.github.wulkanowy.sdk.grades.Grade
import io.github.wulkanowy.sdk.notes.Note
import io.github.wulkanowy.sdk.register.CertificateResponse
import io.github.wulkanowy.sdk.register.Student
import io.github.wulkanowy.sdk.repository.MobileRepository
@ -84,5 +85,12 @@ class UonetTest {
examsSubscriber.assertCompleted()
examsSubscriber.assertNoErrors()
assertEquals("Ok", examsSubscriber.onNextEvents[0].status)
val notes = mobile.getNotes(student.classificationPeriodId, student.id)
val notesSubscriber = TestSubscriber<ApiResponse<List<Note>>>()
notes.subscribe(notesSubscriber)
notesSubscriber.assertCompleted()
notesSubscriber.assertNoErrors()
assertEquals("Ok", notesSubscriber.onNextEvents[0].status)
}
}