#ifndef MQTT_PROPERTIES_H
#define MQTT_PROPERTIES_H
#include <string>
#include <vector>
#include "common/json_util.h"

namespace zsy
{
    struct MqttProperties
    {
        struct Subscribe
        {
            std::string topic;
            uint8_t qos{0};
        };

        std::string sn;
        std::string name;
        std::string server;
        uint16_t port{1883};
        std::string clientId;
        std::string username;
        std::string password;
        std::vector<Subscribe> subscribes;
    };

    inline void from_json(const nlohmann::json &j, MqttProperties::Subscribe &o)
    {
        PARSE_JSON(topic, o.topic);
        PARSE_JSON(qos, o.qos);
    }

    inline void from_json(const nlohmann::json &j, MqttProperties &o)
    {
        PARSE_JSON(sn, o.sn);
        PARSE_JSON(name, o.name);
        PARSE_JSON(server, o.server);
        PARSE_JSON(port, o.port);
        PARSE_JSON(clientId, o.clientId);
        PARSE_JSON(username, o.username);
        PARSE_JSON(password, o.password);
        PARSE_JSON(subscribes, o.subscribes);
    }
}


#endif //MQTT_PROPERTIES_H
