#ifndef API_AUTHOR_HPP_
#define API_AUTHOR_HPP_
#include <includes.h>
#include <net.h>
class Author {
private:
    nlohmann::json data;
    const nlohmann::json &d;
    WebSocket& web;
    NetworkManager& req;
public:
    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),
        d(data["d"]),
        web(WebSocket::getInstance()),
        req(NetworkManager::getInstance()),
        channel_id(functions::isNull(d["channel_id"])),
        global_name(functions::isNull(d["author"]["global_name"])),
        id(d["author"]["id"]),
        content(d["content"]),
        avatar(d["author"]["avatar"]),
        guild_id(d["guild_id"]),
        discriminator(d["author"]["discriminator"]),
        message_id(d["id"]),
        isPinned(d["pinned"]),
        isBot(d["author"].contains("bot") ? d["author"]["bot"].get<bool>() : false) {};
    std::string send(const nlohmann::json& msg) {
        return req.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/" + d["channel_id"].get<std::string>() + "/messages", msg.dump());
    }
};
#endif