// Copyright (c) 2020 UWB & LESP.
// The UWB & LESP license this file to you under the MIT license.

package cz.senslog.connector.push.afarcloud;

import cz.senslog.connector.model.afarcloud.AFarCloudModel;
import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.push.api.ConnectorPushProvider;
import cz.senslog.connector.push.api.ConnectorPusher;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import static cz.senslog.connector.tools.http.HttpClient.newHttpSSLClient;

public class AFarCloudPushProvider implements ConnectorPushProvider {

    private static final Logger logger = LogManager.getLogger(AFarCloudPushProvider.class);

    @Override
    public ConnectorPusher<AFarCloudModel> createPusher(DefaultConfig defaultConfig) {
        logger.info("Initialization a new push provider {}.", AFarCloudPushProvider.class);

        logger.debug("Creating a new configuration.");
        AFarCloudConfig config = new AFarCloudConfig(defaultConfig);
        logger.info("Configuration for {} was created successfully.", AFarCloudPusher.class);

        logger.debug("Creating a new instance of {}.", AFarCloudPusher.class);
        AFarCloudPusher pusher = new AFarCloudPusher(config, newHttpSSLClient());
        logger.info("Pusher for {} was created successfully.", AFarCloudPusher.class);

        return pusher;
    }
}