package cz.senslog.connector.fetch.openmeteo;

import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.model.config.PropertyConfig;

import java.time.LocalDate;
import java.util.*;

public class OpenMeteoConfig {

    private final String url;
    private final TimeZone timeZone;
    private final LocalDate startDate;
    private final String allowedStationURL;
    private final List<String> hourly;
    private final String models;

    OpenMeteoConfig(DefaultConfig defaultConfig) {
        this.url = defaultConfig.getStringProperty("baseUrl");
        this.startDate = LocalDate.parse(defaultConfig.getStringProperty("startDate"));
        this.timeZone = TimeZone.getTimeZone(defaultConfig.getStringProperty("timeZone"));
        this.allowedStationURL = defaultConfig.containsProperty("allowedStationURL") ? defaultConfig.getStringProperty("allowedStationURL") : null;

        PropertyConfig params = defaultConfig.getPropertyConfig("allowedStationURLParams");
        this.hourly = params.getListProperty("hourly", String.class);
        this.models = params.getStringProperty("models");

    }

    public String getUrl() {
        return url;
    }

    public TimeZone getTimeZone() {
        return timeZone;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public String getAllowedStationURL() {
        return allowedStationURL;
    }

    public List<String> getHourly() {
        return hourly;
    }

    public String getModels() {
        return models;
    }
}
