57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "NetworkTypes.hpp"
|
|
#include "Types.hpp"
|
|
#include <future>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Echoion::Api
|
|
{
|
|
|
|
// Network client interface
|
|
class INetworkClient
|
|
{
|
|
public:
|
|
|
|
virtual ~INetworkClient() = default;
|
|
|
|
// Initialize with optional proxy
|
|
virtual Result<void> initialize(
|
|
const std::optional<ProxyConfig>& proxy = std::nullopt) = 0;
|
|
virtual void shutdown() = 0;
|
|
|
|
// Synchronous requests
|
|
[[nodiscard]] virtual Result<HttpResponse>
|
|
get(std::string_view url,
|
|
const std::vector<HttpHeader>& headers = {}) = 0;
|
|
[[nodiscard]] virtual Result<HttpResponse>
|
|
post(std::string_view url, std::string_view body,
|
|
const std::vector<HttpHeader>& headers = {}) = 0;
|
|
[[nodiscard]] virtual Result<HttpResponse>
|
|
request(const HttpRequest& req) = 0;
|
|
|
|
// Asynchronous requests
|
|
[[nodiscard]] virtual std::future<Result<HttpResponse>>
|
|
getAsync(std::string_view url,
|
|
const std::vector<HttpHeader>& headers = {}) = 0;
|
|
[[nodiscard]] virtual std::future<Result<HttpResponse>>
|
|
postAsync(std::string_view url, std::string_view body,
|
|
const std::vector<HttpHeader>& headers = {}) = 0;
|
|
[[nodiscard]] virtual std::future<Result<HttpResponse>>
|
|
requestAsync(const HttpRequest& req) = 0;
|
|
|
|
// Proxy configuration
|
|
virtual void setProxy(const std::optional<ProxyConfig>& proxy) = 0;
|
|
[[nodiscard]] virtual std::optional<ProxyConfig>
|
|
getProxy() const = 0;
|
|
virtual void clearProxy() = 0;
|
|
|
|
// Retry configuration
|
|
virtual void setRetryConfig(const RetryConfig& config) = 0;
|
|
[[nodiscard]] virtual RetryConfig getRetryConfig() const = 0;
|
|
};
|
|
|
|
} // namespace Echoion::Api
|