All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.wulkanowy.sdk.scrapper.school.SchoolMapper.kt Maven / Gradle / Ivy

Go to download

Unified way of retrieving data from the UONET+ register through mobile api and scraping api

There is a newer version: 2.7.0
Show newest version
package io.github.wulkanowy.sdk.scrapper.school

import io.github.wulkanowy.sdk.scrapper.getEmptyIfDash

internal fun SchoolAndTeachersResponse.mapToSchool() = school.copy(
    name = school.name.trim('-'),
    address = school.address.trim('-'),
    contact = school.contact.trim('-'),
    headmaster = school.headmaster.trim('-'),
    pedagogue = school.pedagogue.trim('-'),
)

internal fun SchoolAndTeachersResponse.mapToTeachers() = teachers.map { item ->
    item.name.split(",").map { namePart ->
        item.copy(
            name = namePart.substringBefore(" [").getEmptyIfDash().trim(),
            subject = item.subject.trim(),
        ).apply {
            short = namePart.substringAfter("[").substringBefore("]").getEmptyIfDash()
        }
    }.asReversed()
}.flatten().sortedWith(compareBy({ it.subject }, { it.name }))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy