#pragma once

#ifdef _WIN32
#include <windows.h>
#include <winhttp.h>
#endif

#include <string>
#include <vector>
#include <map>
#include <optional>

namespace secondvoice {

struct HttpResponse {
    int statusCode;
    std::string body;
};

class WinHttpClient {
public:
    WinHttpClient();
    ~WinHttpClient();

    // POST JSON request
    std::optional<HttpResponse> postJson(
        const std::string& host,
        const std::string& path,
        const std::string& jsonBody,
        const std::map<std::string, std::string>& headers
    );

    // POST multipart form data
    std::optional<HttpResponse> postMultipart(
        const std::string& host,
        const std::string& path,
        const std::map<std::string, std::string>& fields,
        const std::string& fileFieldName,
        const std::string& fileName,
        const std::string& fileContentType,
        const std::vector<char>& fileData,
        const std::map<std::string, std::string>& headers
    );

private:
#ifdef _WIN32
    HINTERNET hSession_;
#endif
    std::string generateBoundary();
};

} // namespace secondvoice
