12345678910111213141516171819202122232425 |
- package com.ted.weather.data.db
- import com.ted.weather.domain.model.Forecast
- import com.ted.weather.domain.model.ForecastList
- class DbDataMapper {
- fun convertFromDomain(forecast: ForecastList) = with(forecast) {
- val daily = dailyForecast.map { convertDayFromDomain(id, it) }
- CityForecast(id, city, country, daily)
- }
- private fun convertDayFromDomain(cityId: Long, forecast: Forecast) = with(forecast) {
- DayForecast(date, description, high, low, iconUrl, cityId)
- }
- fun convertToDomain(forecast: CityForecast) = with(forecast) {
- val daily = dailyForecast.map { convertDayToDomain(it) }
- ForecastList(_id, city, country, daily)
- }
- fun convertDayToDomain(dayForecast: DayForecast) = with(dayForecast) {
- Forecast(_id, date, description, high, low, iconUrl)
- }
- }
|