#pragma once

#include "api.h"

#include <string>
#include <map>
#include <utility>

class Okapi : public Api {
private:
	std::string url;
	std::string key;

	std::string service;

	static size_t write_cb(char* ptr, size_t size, size_t nmemb, void* userdata);
	std::string curl_post(const std::string& url, const std::string& post) const;
	std::string get_user_caches_json(const std::string& uuid, int count = 0, int offset = 0) const;
	// 	std::string get_cache_json(std::string code) const;
	std::string get_caches_json(const std::string& codes) const;

	const static int MAX_LOGS = 1000;
	const static int MAX_CACHES = 500;

public:
	Okapi(const std::string& server_url, const std::string& consumer_key);

	// 	Cache get_cache(std::string code);
	Caches get_caches(const std::vector<std::string>& codes) const;
	Caches get_user_caches(const std::string& uuid, int count = 0) const override;
	std::string get_changelog_json(int revision) const;

	std::string get_uuid(const std::string& username) const;
	std::string get_profile_url(const std::string& uuid) const;
};
