// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2026 Pionix GmbH and Contributors to EVerest
#ifndef EVSE_MANAGER_CONSUMER_API_HPP
#define EVSE_MANAGER_CONSUMER_API_HPP

//
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
// template version 2
//

#include "ld-ev.hpp"

// headers for provided interface implementations
#include <generated/interfaces/generic_error/Implementation.hpp>

// headers for required interface implementations
#include <generated/interfaces/evse_board_support/Interface.hpp>
#include <generated/interfaces/evse_manager/Interface.hpp>
#include <generated/interfaces/isolation_monitor/Interface.hpp>
#include <generated/interfaces/power_supply_DC/Interface.hpp>
#include <generated/interfaces/slac/Interface.hpp>
#include <generated/interfaces/uk_random_delay/Interface.hpp>

// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
// insert your custom include headers here
#include <everest/util/async/monitor.hpp>
#include <everest_api_module_helpers/ApiHelper.hpp>
#include <everest_api_types/entrypoint/API.hpp>

#include "session_info.hpp"

namespace ev_API = everest::lib::API;
namespace API_types = ev_API::V1_0::types;
namespace API_types_entry = API_types::entrypoint;
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1

namespace module {

struct Conf {
    int cfg_communication_check_to_s;
    int cfg_heartbeat_interval_ms;
    int cfg_request_reply_to_s;
};

class evse_manager_consumer_API : public Everest::ModuleBase {
public:
    evse_manager_consumer_API() = delete;
    evse_manager_consumer_API(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider,
                              std::unique_ptr<generic_errorImplBase> p_main,
                              std::unique_ptr<evse_managerIntf> r_evse_manager,
                              std::vector<std::unique_ptr<evse_board_supportIntf>> r_evse_bsp,
                              std::vector<std::unique_ptr<slacIntf>> r_slac,
                              std::vector<std::unique_ptr<isolation_monitorIntf>> r_imd,
                              std::vector<std::unique_ptr<power_supply_DCIntf>> r_ps_dc,
                              std::vector<std::unique_ptr<uk_random_delayIntf>> r_random_delay, Conf& config) :
        ModuleBase(info),
        mqtt(mqtt_provider),
        p_main(std::move(p_main)),
        r_evse_manager(std::move(r_evse_manager)),
        r_evse_bsp(std::move(r_evse_bsp)),
        r_slac(std::move(r_slac)),
        r_imd(std::move(r_imd)),
        r_ps_dc(std::move(r_ps_dc)),
        r_random_delay(std::move(r_random_delay)),
        config(config){};

    Everest::MqttProvider& mqtt;
    const std::unique_ptr<generic_errorImplBase> p_main;
    const std::unique_ptr<evse_managerIntf> r_evse_manager;
    const std::vector<std::unique_ptr<evse_board_supportIntf>> r_evse_bsp;
    const std::vector<std::unique_ptr<slacIntf>> r_slac;
    const std::vector<std::unique_ptr<isolation_monitorIntf>> r_imd;
    const std::vector<std::unique_ptr<power_supply_DCIntf>> r_ps_dc;
    const std::vector<std::unique_ptr<uk_random_delayIntf>> r_random_delay;
    const Conf& config;

    // ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
    // insert your public definitions here
    ev_API::Mqtt::ValidatingMqttProxy mqtt_v{mqtt};
    ev_API::ApiHelper helper{info, mqtt_v, {{"evse_manager_consumer", 1}}, get_config_service_client()};
    // ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1

protected:
    // ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1
    // insert your protected definitions here
    // ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1

private:
    friend class LdEverest;
    void init();
    void ready();

    // ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
    // insert your private definitions here
    auto forward_api_var(std::string const& var);

    void generate_api_cmd_get_evse();
    void generate_api_cmd_enable_disable();
    void generate_api_cmd_pause_charging();
    void generate_api_cmd_resume_charging();
    void generate_api_cmd_stop_transaction();
    void generate_api_cmd_force_unlock();
    void generate_api_cmd_random_delay_enable();
    void generate_api_cmd_random_delay_disable();
    void generate_api_cmd_random_delay_cancel();
    void generate_api_cmd_random_delay_set_duration_s();

    void generate_api_var_session_event();
    void generate_api_var_hlc_session_failed();
    void generate_api_var_session_info();
    void generate_api_var_ev_info();
    void generate_api_var_powermeter();
    void generate_api_var_evse_id();
    void generate_api_var_hw_capabilities();
    void generate_api_var_enforced_limits();
    void generate_api_var_selected_protocol();
    void generate_api_var_powermeter_public_key_ocmf();
    void generate_api_var_supported_energy_transfer_modes();

    void generate_api_var_ac_nr_of_phases_available();
    void generate_api_var_ac_pp_ampacity();
    void generate_api_var_dlink_ready();
    void generate_api_var_isolation_measurement();
    void generate_api_var_dc_voltage_current();
    void generate_api_var_dc_mode();
    void generate_api_var_dc_capabilities();
    void generate_api_var_random_delay_countdown();

    ev_API::CommCheckHandler<generic_errorImplBase> comm_check{"generic/CommunicationFault",
                                                               ev_API::bridge_connection_lost_message, p_main};
    everest::lib::util::monitor<SessionInfo> session_info;
    // ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};

// ev@087e516b-124c-48df-94fb-109508c7cda9:v1
// insert other definitions here
// ev@087e516b-124c-48df-94fb-109508c7cda9:v1

} // namespace module

#endif // EVSE_MANAGER_CONSUMER_API_HPP
