#include "HttpOrderService.h" #include namespace nxl::autostore::infrastructure { HttpOrderService::HttpOrderService(ILoggerPtr logger) : log{std::move(logger)} {} void HttpOrderService::orderItem(const domain::Item& item) { if (item.orderUrl.empty()) { throw std::runtime_error("Order URL is empty for item: " + item.name); } std::string payload = R"({"itemName": ")" + item.name + R"(", "itemId": ")" + item.id + "\"}"; sendPostRequest(item.orderUrl, payload); } void HttpOrderService::sendPostRequest(std::string_view url, std::string_view payload) { // In a real implementation, this would use an HTTP client library // For now, we'll simulate the HTTP call log->i("POST request to: %s", url); log->v(1, "Payload: %s", payload); // Simulate HTTP error handling if (url.find("error") != std::string::npos) { throw std::runtime_error("Failed to send order request to: " + std::string(url)); } } } // namespace nxl::autostore::infrastructure