#pragma once #include "http.h" #include "spdlog/logger.h" #include "uv.h" #include #include #include #include #include #include namespace vk { using namespace http; struct Post { inline Post(long id, long date, long editDate, long fromId, std::string postType, std::string text) : id(id), date(date), editDate(editDate), fromId(fromId), postType(postType), text(text) {} long id, date, editDate, fromId; std::string postType, text; }; struct WallChunk { int count; std::vector posts; }; class VKClient { public: VKClient(uv_loop_t *eventLoop); VKClient(VKClient&) = delete; VKClient(uv_loop_t *eventLoop, std::string serviceKey); void set_service_api_key(std::string key); void get_posts(std::variant wall, int offset, int count, std::function, int)> callback); void get_posts_now(std::variant wall, int offset, int count, std::function, int)> callback); private: uv_loop_t *m_eventLoop; HttpClient m_httpClient; std::optional m_serviceApiKey; std::shared_ptr m_logger; std::chrono::steady_clock::time_point m_lastCallTime; }; }