geostat/okapi.h

61 wiersze
2.1 KiB
C

2019-09-08 16:42:10 +00:00
#pragma once
#include "api.h"
#include <string>
2023-08-30 14:40:12 +00:00
#include <set>
#include <utility>
2019-09-08 16:42:10 +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;
2023-08-30 14:40:12 +00:00
Service service;
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);
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;
// std::string get_cache_json(std::string code) const;
void get_caches_json(const std::string& codes) const;
2023-08-30 20:43:49 +00:00
// void get_caches_ratings_json(const std::string& codes) const;
2019-09-08 16:42:10 +00:00
const static int MAX_LOGS = 1000;
const static int MAX_CACHES = 500;
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";
2023-08-30 14:40:12 +00:00
constexpr static auto ocpl_url = "https://opencaching.pl/okapi/";
constexpr static auto ocde_url = "https://www.opencaching.de/okapi/";
constexpr static auto ocus_url = "http://www.opencaching.us/okapi/";
constexpr static auto ocnl_url = "http://www.opencaching.nl/okapi/";
constexpr static auto ocro_url = "http://www.opencaching.ro/okapi/";
constexpr static auto ocuk_url = "https://opencache.uk/okapi/";
2019-09-08 16:42:10 +00:00
public:
2023-08-30 20:43:49 +00:00
explicit Okapi(const Service serv);
~Okapi();
2019-09-08 16:42:10 +00:00
// Cache get_cache(std::string code);
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;
2023-08-30 14:40:12 +00:00
int get_user_hidden_caches_no(const std::string& uuid) const;
std::string get_changelog_json(int revision) const;
2019-09-08 16:42:10 +00:00
void update_caches(Caches& cc) const;
2023-09-25 16:49:30 +00:00
// void update_caches_ratings(Caches& cc) const;
std::string get_uuid(const std::string& username, uint* id = nullptr) const;
std::string get_profile_url(const std::string& uuid) const;
void get_ftf(uint uid, Caches& cc) const;
2019-09-08 16:42:10 +00:00
};