#ifndef INTERFACE_AUTHOR_HPP_
#define INTERFACE_AUTHOR_HPP_
#include <includes.hpp>
#include <network.hpp>
class Author {
private:
    const nlohmann::json& data;
    WebSocket& web;
    NetworkManager& req;
public:
    _deprecated_t("requires update")
        struct Channel {
        std::string channel_id;
        std::string global_name;
        std::string id;
        std::string content;
        std::string avatar;
        std::string guild_id;
        std::string discriminator;
        std::string message_id;
        bool isPinned;
        bool isBot;
    } authorData;
    const std::string channel_id, global_name, id, content, avatar, guild_id, discriminator, message_id;
    bool isPinned, isBot;
    Author(const nlohmann::json& data)
        : data(data),
        web(WebSocket::getInstance()),
        req(NetworkManager::getInstance()),
        channel_id(functions::testValue<std::string>(data, { "d", "channel_id" }).value_or("")),
        global_name(functions::testValue<std::string>(data, { "d", "author", "global_name" }).value_or("")),
        id(functions::testValue<std::string>(data, { "d", "author", "id" }).value_or("")),
        content(functions::testValue<std::string>(data, { "d", "content" }).value_or("")),
        avatar(functions::testValue<std::string>(data, { "d", "author", "avatar" }).value_or("")),
        guild_id(functions::testValue<std::string>(data, { "d", "guild_id" }).value_or("")),
        discriminator(functions::testValue<std::string>(data, { "d", "author", "discriminator" }).value_or("")),
        message_id(functions::testValue<std::string>(data, { "d", "id" }).value_or("")),
        isPinned(functions::testValue<bool>(data, { "d", "pinned" }).value_or(false)),
        isBot(functions::testValue<bool>(data, { "d", "author", "bot" }).value_or(false)) {
    }
    auto send(const nlohmann::json& msg) -> std::string {
        return req.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/" + data["d"]["channel_id"].get<std::string>() + "/messages", msg.dump());
    }
};
#endif