//
//  WdtWeatherCode.swift
//  1Weather
//
//  Created by Demid Merzlyakov on 19.02.2021.
//

import Foundation

enum WdtWeatherCode: String, Codable {
    // "ic_static_smoke"
    case smoke = "3"
    // "ic_static_hazy"
    case haze = "5"
    // "ic_static_sandstorm"
    case blowingDust = "7"
    case duststorm = "31"
    case severeDuststorm = "34"
    // "ic_static_fog"
    case lightFog = "10"
    case patchyFog = "41"
    case fog = "45"
    // "ic_static_snow_moderate"
    case squall = "18"
    case driftingSnow = "36"
    case blowingSnow = "38"
    // "ic_static_ice_fog"
    case freezingFog = "49"
    // "ic_static_mild_rain"
    case lightDrizzle = "51"
    case drizzle = "53"
    case heavyDrizzle = "55"
    case lightRain = "61"
    case lightRainShower = "80"
    // "ic_static_freezing_rain"
    case freezingDrizzle = "57"
    case lightFreezingRain = "66"
    case lightRainAndSnow = "68"
    case rainAndSnow = "69"
    case lightRainAndSnowShower = "83"
    case rainAndSnowShower = "84"
    case freezingRain = "67"
    case sleet = "79"
    // "ic_static_moderate_rain"
    case rain = "63"
    case rainShower = "81"
    // "ic_static_heavy_rain"
    case heavyRain = "65"
    // "ic_static_snow_flurry"
    case lightSnow = "71"
    case lightSnowShower = "85"
    // "ic_static_snow_moderate"
    case snow = "73"
    case snowShower = "86"
    // "ic_static_snowstorm"
    case heavySnow = "75"
    // "ic_static_hail"
    case lightHail = "89"
    case hail = "90"
    // "ic_static_severe_thunderstorms"
    case thunderstorm = "95"
    case heavyThunderstorm = "97"
    // isDay ? "ic_static_sunny" : "ic_static_clear_night"
    case clear = "100"
    // isDay ? "ic_static_partly_cloudy" : "ic_static_partly_cloudy_night"
    case mostlyClear = "101"
    case partlyCloudy = "102"
    // isDay ? "ic_static_heavy_cloudy" : "ic_static_heavy_cloudy_night"
    case mostlyCloudy = "103"
    case overcast = "104"
    // "ic_static_no_report"
    
    public func toAppModel() -> WeatherType {
        switch self {
        case .smoke:
            return .smoke
        case .haze:
            return .haze
        case .blowingDust, .duststorm, .severeDuststorm:
            return .blowingDust
        case .lightFog, .patchyFog, .fog:
            return .lightFog
        case .squall, .driftingSnow, .blowingSnow:
            return .snowy
        case .freezingFog:
            return .freezingFog
        case .lightDrizzle, .drizzle, .heavyDrizzle, .lightRain, .lightRainShower:
            return .lightDrizzle
        case .freezingDrizzle, .lightFreezingRain, .lightRainAndSnow, .rainAndSnow, .lightRainAndSnowShower, .rainAndSnowShower, .freezingRain, .sleet:
            return .freezingRain
        case .rain, .rainShower:
            // TODO: no light rain here?
            return .heavyRain
        case .heavyRain:
            return .heavyRain
        case .lightSnow, .lightSnowShower:
            return .lightSnow
        case .snow, .snowShower:
            return .snowy
        case .heavySnow:
            return .heavySnow
        case .lightHail, .hail:
            return .lightHail
        case .thunderstorm, .heavyThunderstorm:
            return .thunderstorm
        case .clear:
            return .clear
        case .mostlyClear, .partlyCloudy:
            return .partlyCloudy
        case .mostlyCloudy, .overcast:
            return .mostlyCloudy
        }
    }
}
