2019-09-08 16:42:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "api.h"
|
|
|
|
|
|
|
|
#include <string>
|
2020-01-28 03:49:11 +00:00
|
|
|
#include <map>
|
2019-11-05 19:39:33 +00:00
|
|
|
#include <utility>
|
2019-09-08 16:42:10 +00:00
|
|
|
|
2020-08-06 19:53:13 +00:00
|
|
|
typedef void CURL;
|
|
|
|
|
2019-10-03 22:43:39 +00:00
|
|
|
class Okapi : public Api {
|
2019-09-08 16:42:10 +00:00
|
|
|
private:
|
|
|
|
std::string url;
|
|
|
|
std::string key;
|
|
|
|
|
2020-01-25 15:49:32 +00:00
|
|
|
std::string service;
|
|
|
|
|
2020-08-06 19:53:13 +00:00
|
|
|
CURL* curl;
|
|
|
|
mutable std::string curl_output;
|
|
|
|
|
2019-09-08 16:42:10 +00:00
|
|
|
static size_t write_cb(char* ptr, size_t size, size_t nmemb, void* userdata);
|
2020-08-06 19:53:13 +00:00
|
|
|
void curl_post(const std::string& url, const std::string& post) const;
|
|
|
|
void get_user_caches_json(const std::string& uuid, int count = 0, int offset = 0) const;
|
2020-02-11 16:34:23 +00:00
|
|
|
// std::string get_cache_json(std::string code) const;
|
2020-08-06 19:53:13 +00:00
|
|
|
void get_caches_json(const std::string& codes) const;
|
2020-08-28 16:42:54 +00:00
|
|
|
void get_caches_ratings_json(const std::string& codes) const;
|
2019-09-08 16:42:10 +00:00
|
|
|
|
2020-02-29 01:18:01 +00:00
|
|
|
const static int MAX_LOGS = 1000;
|
|
|
|
const static int MAX_CACHES = 500;
|
|
|
|
|
2023-08-30 13:53:47 +00:00
|
|
|
constexpr static auto OKAPI_logs = "services/logs/userlogs";
|
|
|
|
constexpr static auto OKAPI_cache = "services/caches/geocache";
|
|
|
|
constexpr static auto OKAPI_caches = "services/caches/geocaches";
|
|
|
|
constexpr static auto OKAPI_username = "services/users/by_username";
|
|
|
|
constexpr static auto OKAPI_user = "services/users/user";
|
|
|
|
constexpr static auto OKAPI_changelog = "services/replicate/changelog";
|
|
|
|
|
2019-09-08 16:42:10 +00:00
|
|
|
public:
|
2020-02-11 16:34:23 +00:00
|
|
|
Okapi(const std::string& server_url, const std::string& consumer_key);
|
2020-08-06 19:53:13 +00:00
|
|
|
~Okapi();
|
2019-09-08 16:42:10 +00:00
|
|
|
|
|
|
|
// Cache get_cache(std::string code);
|
2020-02-29 22:05:11 +00:00
|
|
|
Caches get_caches(const std::set<std::string>& codes) const;
|
2020-02-11 16:37:01 +00:00
|
|
|
Caches get_user_caches(const std::string& uuid, int count = 0) const override;
|
2020-10-31 20:51:25 +00:00
|
|
|
int get_user_caches_no(const std::string& uuid) const;
|
2020-02-11 16:34:23 +00:00
|
|
|
std::string get_changelog_json(int revision) const;
|
2019-09-08 16:42:10 +00:00
|
|
|
|
2020-08-05 00:26:40 +00:00
|
|
|
void update_caches(Caches& cc) const;
|
2022-07-13 16:31:01 +00:00
|
|
|
// void update_caches_ratings(Caches& cc) const;
|
2022-07-13 16:30:26 +00:00
|
|
|
std::string get_uuid(const std::string& username, uint* id = nullptr) const;
|
2020-02-11 16:34:23 +00:00
|
|
|
std::string get_profile_url(const std::string& uuid) const;
|
2022-07-13 16:30:26 +00:00
|
|
|
void get_ftf(uint uid, Caches& cc) const;
|
2019-09-08 16:42:10 +00:00
|
|
|
};
|