import Accessor from "@arcgis/core/core/Accessor.js";
import { property } from "@arcgis/core/core/accessorSupport/decorators.js";

import WeatherCondition, { IWeatherCondition } from "./weather-condition";
import AirQuality, { IAirQuality } from "./air-quality";

export interface ICurrent extends IWeather{
    last_updated_epoch: number,
    last_updated: string,
    air_quality: IAirQuality
}

export interface IWeather {
 
    temp_c: number,
    temp_f: number,
    is_day: number,
    condition: IWeatherCondition,
    wind_mph: number,
    wind_kph: number,
    wind_degree: number,
    wind_dir: string,
    pressure_mb: number,
    pressure_in: number,
    precip_mm: number,
    precip_in: number,
    humidity: number,
    cloud: number,
    feelslike_c: number,
    feelslike_f: number,
    vis_km: number,
    vis_miles: number,
    uv: number,
    gust_mph: number,
    gust_kph: number,
   
}


export default class Weather extends Accessor implements ICurrent {
    @property()
    last_updated_epoch: number;
    @property()
    last_updated: string;
    @property()
    temp_c: number;
    @property()
    temp_f: number;
    @property()
    is_day: number;
    @property()
    condition: IWeatherCondition;
    @property()
    wind_mph: number;
    @property()
    wind_kph: number;
    @property()
    wind_degree: number;
    @property()
    wind_dir: string;
    @property()
    pressure_mb: number;
    @property()
    pressure_in: number;
    @property()
    precip_mm: number;
    @property()
    precip_in: number;
    @property()
    humidity: number;
    @property()
    cloud: number;
    @property()
    feelslike_c: number;
    @property()
    feelslike_f: number;
    @property()
    vis_km: number;
    @property()
    vis_miles: number;
    @property()
    uv: number;
    @property()
    gust_mph: number;
    @property()
    gust_kph: number;
    @property()
    air_quality: IAirQuality;

    constructor(currentWeather: ICurrent) {
        super();
        this.last_updated_epoch = currentWeather.last_updated_epoch;
        this.last_updated = currentWeather.last_updated;
        this.temp_c = currentWeather.temp_c;
        this.temp_f = currentWeather.temp_f;
        this.is_day = currentWeather.is_day;
        this.condition = new WeatherCondition(currentWeather.condition);
        this.wind_mph = currentWeather.wind_mph;
        this.wind_kph = currentWeather.wind_kph;
        this.wind_degree = currentWeather.wind_degree;
        this.wind_dir = currentWeather.wind_dir;
        this.pressure_mb = currentWeather.pressure_mb;
        this.pressure_in = currentWeather.pressure_in;
        this.precip_mm = currentWeather.precip_mm;
        this.precip_in = currentWeather.precip_in;
        this.humidity = currentWeather.humidity;
        this.cloud = currentWeather.cloud;
        this.feelslike_c = currentWeather.feelslike_c;
        this.feelslike_f = currentWeather.feelslike_f
        this.vis_km = currentWeather.vis_km;
        this.vis_miles = currentWeather.vis_miles;
        this.uv = currentWeather.uv;
        this.gust_mph = currentWeather.gust_mph;
        this.gust_kph = currentWeather.gust_kph;
        this.air_quality= new AirQuality(currentWeather.air_quality);

    }

}

