package ru.fincode.tsudesk.feature.schedule.data.remote

import ru.fincode.tsudesk.core.network.model.NetworkResult
import ru.fincode.tsudesk.core.network.apiCall
import ru.fincode.tsudesk.feature.schedule.data.datasource.ScheduleRemoteDataSource
import ru.fincode.tsudesk.feature.schedule.data.remote.api.ScheduleApi
import ru.fincode.tsudesk.feature.schedule.data.remote.dto.ScheduleDto
import javax.inject.Inject

class ScheduleRemoteDataSourceImpl @Inject constructor(
    private val api: ScheduleApi
) : ScheduleRemoteDataSource {

    override suspend fun loadScheduleByGroup(number: String): NetworkResult<ScheduleDto> =
        apiCall {
            api.getSchedule(
                searchField = ScheduleApiContract.Query.FIELD_GROUP,
                searchValue = number
            )
        }

    override suspend fun loadScheduleByTeacher(name: String): NetworkResult<ScheduleDto> =
        apiCall {
            api.getSchedule(
                searchField = ScheduleApiContract.Query.FIELD_TEACHER,
                searchValue = name
            )
        }
}