Fix symbol and school id in register
This commit is contained in:
parent
1ffe318060
commit
a448cfa90c
3 changed files with 7 additions and 5 deletions
|
@ -36,10 +36,10 @@ class RegisterRepository(
|
|||
if (t is AccountPermissionException) Single.just(HomepageResponse())
|
||||
else Single.error(t)
|
||||
}
|
||||
.flatMapObservable { Observable.fromIterable(if (useNewStudent) it.studentSchools else it.oldStudentSchools) }
|
||||
.flatMapObservable { if (useNewStudent) Observable.fromIterable(it.studentSchools) else Observable.fromIterable(it.oldStudentSchools) }
|
||||
.flatMapSingle { schoolUrl ->
|
||||
getLoginType().flatMap { loginType ->
|
||||
getStudents(schoolUrl).map {
|
||||
getStudents(symbol.first, schoolUrl).map {
|
||||
it.map { pupil ->
|
||||
Pupil(
|
||||
email = email,
|
||||
|
@ -57,7 +57,9 @@ class RegisterRepository(
|
|||
}.toList().map { it.flatten() }
|
||||
}
|
||||
|
||||
private fun getStudents(schoolUrl: String): Single<List<StudentAndParentResponse.Pupil>> {
|
||||
private fun getStudents(symbol: String, schoolUrl: String): Single<List<StudentAndParentResponse.Pupil>> {
|
||||
url.schoolId = getExtractedSchoolSymbolFromUrl(schoolUrl)
|
||||
url.symbol = symbol
|
||||
return if (!useNewStudent) snp.getSchoolInfo(schoolUrl).map { it.students }
|
||||
else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get").map { diary -> diary.data?.distinctBy { it.studentId } }
|
||||
.map { diaries ->
|
||||
|
|
|
@ -134,7 +134,7 @@ class ServiceManager(
|
|||
}
|
||||
}
|
||||
|
||||
class UrlGenerator(private val schema: String, private val host: String, private val symbol: String, private val schoolId: String) {
|
||||
class UrlGenerator(private val schema: String, private val host: String, var symbol: String, var schoolId: String) {
|
||||
|
||||
enum class Site {
|
||||
LOGIN, SNP, STUDENT, MESSAGES
|
||||
|
|
|
@ -96,7 +96,7 @@ class ApiRemoteTest : BaseTest() {
|
|||
}
|
||||
|
||||
values[4].run {
|
||||
// assertEquals(15, diaryId)
|
||||
// assertEquals(15, diaryId)
|
||||
assertEquals("2A 2016", diaryName)
|
||||
assertEquals(12, semesterId)
|
||||
// assertEquals(2, semesterNumber)
|
||||
|
|
Loading…
Reference in a new issue