#include "Response.hpp" Response::json Response::simple_response(std::string const &text, std::string const &session, bool success) { std::vector reply_vec; reply_vec.emplace_back(create_text(text)); return create_response(std::move(reply_vec), session, success); } Response::json Response::create_annotation(Reply::AnnotationType annotationType, std::string const &extra) { json annotation(crow::json::type::Object); annotation["type"] = Reply::GetStringAnnotationType(annotationType); if (extra.empty()) { annotation["extra"] = json(crow::json::type::List); } else { annotation["extra"] = create_text(extra); } return annotation; } Response::json Response::create_annotation(Reply::AnnotationType annotationType, std::vector &&extra) { json annotation(crow::json::type::Object); annotation["type"] = Reply::GetStringAnnotationType(annotationType); annotation["extra"] = std::move(extra); return annotation; } Response::json Response::create_text(std::string const &text) { std::vector annotations; annotations.emplace_back(create_annotation()); return create_text(text, std::move(annotations)); } Response::json Response::create_text(std::string const &text, std::vector &&annotations) { json reply(crow::json::type::Object); reply["text"] = text; reply["annotations"] = std::move(annotations); return reply; } Response::json Response::create_response(std::vector &&reply, std::string const &session, bool success) { json response(crow::json::type::Object); response["success"] = success; response["session"] = session; response["reply"] = std::move(reply); return response; }