#include "zcurl.h"

#include <iostream>

namespace ZCURL{
int test() {
    try {
        ZCURL::RequestOptions opt;
        opt.query_params = {{"q", "C++20 libcurl"}};
        opt.headers = {"Accept: application/json"};
        opt.timeout_ms = 10000;
        opt.http_version = ZCURL::HttpVersion::V2TLS;

        auto res = ZCURL::get("https://httpbin.org/get", opt);
        std::cout << "curl: " << ZCURL::version() << "\n";
        std::cout << "status: " << res.status_code << "\n";
        std::cout << "ok: " << res.ok() << "\n";
        std::cout << res.body.substr(0, 300) << "\n";
        return 0;
    } catch (const std::exception &e) {
        std::cerr << "error: " << e.what() << "\n";
        return 1;
    }
}
}
