mmcs-quotes-bridge/vk.h
2024-11-15 23:25:05 +03:00

40 lines
1.0 KiB
C++

#pragma once
#include "http.h"
#include "spdlog/logger.h"
#include "uv.h"
#include <memory>
#include <optional>
#include <string>
#include <variant>
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<Post> 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<long, std::string> wall, int offset, int count, std::function<void(std::optional<WallChunk>, int)> callback);
private:
HttpClient m_httpClient;
std::optional<std::string> m_serviceApiKey;
std::shared_ptr<spdlog::logger> m_logger;
};
}