sparkle/libs/api/Message.hpp

25 lines
669 B
C++
Raw Normal View History

2024-12-31 02:20:56 +05:00
#ifndef API_MESSAGE_HPP_
#define API_MESSAGE_HPP_
#include <utils/json.hpp>
#include <string>
#include <exception>
#include <iostream>
#include <tls/network.hpp>
#include <gateway/websocket.hpp>
#include <utils/types.hpp>
using std::string;
using std::cout;
using std::endl;
using json = nlohmann::json;
class Message {
private:
json data;
WebSocket& web;
NetworkManager& req;
public:
2024-12-31 04:46:39 +05:00
Message(const json& data) : data(data), web(*WebSocket::getInstance()), req(*NetworkManager::getInstance()) {};
2024-12-31 02:20:56 +05:00
string send(const string& id, const json& msg) {
2024-12-31 05:58:15 +05:00
return req.request("POST", dapi + "/channels/" + id + "/messages", msg.dump());
2024-12-31 02:20:56 +05:00
}
};
#endif