123456789101112131415161718 |
- package com.ted.weather.data.server
- import com.ted.weather.data.db.ForecastDb
- import com.ted.weather.domain.datasource.ForecastDataSource
- import com.ted.weather.domain.model.ForecastList
- class ForecastServer(val dataMapper: ServerDataMapper = ServerDataMapper(),
- val forecastDb: ForecastDb = ForecastDb()) : ForecastDataSource {
- override fun requestForecastByZipCode(zipCode: Long, date: Long): ForecastList? {
- val result = ForecastByZipCodeRequest(zipCode).execute()
- val converted = dataMapper.convertToDomain(zipCode, result)
- forecastDb.saveForecast(converted)
- return forecastDb.requestForecastByZipCode(zipCode, date)
- }
- override fun requestDayForecast(id: Long) = throw UnsupportedOperationException()
- }
|