package cz.senslog.connector.fetch.alapans;

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

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.TimeZone;

public class AlapansConfig {
    private final String baseUrl;
    private final TimeZone timeZone;
    private final LocalDate startDate;
    private final int period;

    private final LocalTime newDataExecutionTime;
    private final AlapansSessionProxyConfig sessionProxyConfig;
    public AlapansConfig(DefaultConfig defaultConfig) {
        this.baseUrl = defaultConfig.getStringProperty("baseUrl");
        this.sessionProxyConfig = defaultConfig.containsProperty("sessionProxy") ?
                new AlapansSessionProxyConfig(defaultConfig.getPropertyConfig("sessionProxy")) : null;
        this.timeZone = TimeZone.getTimeZone(defaultConfig.getStringProperty("timeZone"));
        this.startDate = defaultConfig.getLocalDateProperty("startDate");
        this.newDataExecutionTime = defaultConfig.getLocalTimeProperty("newDataExecutionTime");
        this.period = defaultConfig.getIntegerProperty("period");
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public AlapansSessionProxyConfig getSessionProxy() {
        return sessionProxyConfig;
    }

    public TimeZone getTimeZone() {
        return timeZone;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public int getPeriod() {
        return period;
    }

    public LocalTime getNewDataExecutionTime() {
        return newDataExecutionTime;
    }
}
