orotool/src/oro/api.hpp

66 lines
1.3 KiB
C++
Raw Normal View History

2020-06-20 01:27:47 +02:00
#pragma once
#include "ping.hpp"
#include <string>
#include <utility>
#include <memory>
namespace restc_cpp {
class RestClient;
} //namespace restc_cpp
namespace oro {
struct Header {
//Date: Fri, 19 Jun 2020 22:33:43 GMT
Timestamp date;
//Content-Type: application/json
//Content-Length: 89
//Connection: keep-alive
//Set-Cookie: __cfduid=dccdd965b47650be8b0107bb1292154981592606023; expires=Sun, 19-Jul-20 22:33:43 GMT; path=/; domain=.originsro.org; HttpOnly; SameSite=Lax
//X-RateLimit-Limit: 2
2020-06-20 02:02:43 +02:00
int rate_limit{};
2020-06-20 01:27:47 +02:00
//X-RateLimit-Remaining: 0
2020-06-20 02:02:43 +02:00
int rate_limit_remaining{};
2020-06-20 01:27:47 +02:00
//X-RateLimit-Reset: 1592606027
2020-06-20 02:02:43 +02:00
unsigned long rate_limit_reset{};
2020-06-20 01:27:47 +02:00
//Retry-After: 3
2020-06-20 02:02:43 +02:00
unsigned long retry_after{};
2020-06-20 01:27:47 +02:00
//CF-Cache-Status: DYNAMIC
//cf-request-id: 03705077e200000091668c6200000001
//Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
//Server: cloudflare
std::string server;
//CF-RAY: 5a60b69fdc270091-LHR
};
class Api {
public:
Api (
std::string&& root_address,
std::string&& client_name,
std::string&& client_purpose
);
~Api() noexcept;
std::pair<Header, Ping> ping();
private:
std::string m_prefix;
std::string m_client_name;
std::string m_client_purpose;
std::unique_ptr<restc_cpp::RestClient> m_client;
};
} //namespace oro