26 #include <oatpp/network/tcp/client/ConnectionProvider.hpp>
27 #include <oatpp/parser/json/mapping/ObjectMapper.hpp>
28 #include <oatpp/web/client/HttpRequestExecutor.hpp>
33 Client::Client(
const oatpp::network::Address &address) :
34 oatpp::web::client::ApiClient(
35 oatpp::web::client::HttpRequestExecutor::createShared(
36 oatpp::network::tcp::client::ConnectionProvider::createShared(
38 oatpp::parser::json::mapping::ObjectMapper::createShared())
41 std::shared_ptr<oatpp::web::protocol::http::incoming::Response> Client::put(
42 const std::string &path,
43 const oatpp::Void &body,
44 const std::unordered_map<oatpp::String, oatpp::String> &pathParams)
46 oatpp::data::share::StringTemplate pathTemplate = parsePathTemplate(
47 "put", oatpp::String(path));
48 oatpp::web::client::ApiClient::Headers headers;
49 std::unordered_map<oatpp::String, oatpp::String> queryParams;
50 std::shared_ptr<oatpp::web::protocol::http::outgoing::Body> bodyVoid;
53 bodyVoid = oatpp::web::protocol::http::outgoing::BufferBody::createShared(
54 m_objectMapper->writeToString(body),
55 m_objectMapper->getInfo().http_content_type);
57 return executeRequest(
"PUT", pathTemplate, headers, pathParams, queryParams,
61 std::shared_ptr<oatpp::web::protocol::http::incoming::Response> Client::post(
62 const std::string &path,
63 const oatpp::Void &body,
64 const std::unordered_map<oatpp::String, oatpp::String> &pathParams)
66 oatpp::data::share::StringTemplate pathTemplate = parsePathTemplate(
67 "post", oatpp::String(path));
68 oatpp::web::client::ApiClient::Headers headers;
69 std::unordered_map<oatpp::String, oatpp::String> queryParams;
70 std::shared_ptr<oatpp::web::protocol::http::outgoing::Body> bodyVoid;
73 bodyVoid = oatpp::web::protocol::http::outgoing::BufferBody::createShared(
74 m_objectMapper->writeToString(body),
75 m_objectMapper->getInfo().http_content_type);
77 return executeRequest(
"POST", pathTemplate, headers, pathParams,
78 queryParams, bodyVoid);
81 std::shared_ptr<oatpp::web::protocol::http::incoming::Response> Client::get(
82 const std::string &path,
83 const std::unordered_map<oatpp::String, oatpp::String> &queryParams,
84 const std::unordered_map<oatpp::String, oatpp::String> &pathParams)
86 oatpp::data::share::StringTemplate pathTemplate = parsePathTemplate(
87 "get", oatpp::String(path));
88 oatpp::web::client::ApiClient::Headers headers;
89 std::shared_ptr<oatpp::web::protocol::http::outgoing::Body> body;
90 return executeRequest(
"GET", pathTemplate, headers, pathParams, queryParams,
94 std::shared_ptr<oatpp::web::protocol::http::incoming::Response> Client::del(
95 const std::string &path,
96 const std::unordered_map<oatpp::String, oatpp::String> &queryParams,
97 const std::unordered_map<oatpp::String, oatpp::String> &pathParams)
99 oatpp::data::share::StringTemplate pathTemplate = parsePathTemplate(
100 "delete", oatpp::String(path));
101 oatpp::web::client::ApiClient::Headers headers;
102 std::shared_ptr<oatpp::web::protocol::http::outgoing::Body> body;
103 return executeRequest(
"DELETE", pathTemplate, headers, pathParams,
main motion-lib namespace