aboutsummaryrefslogtreecommitdiffstats
path: root/src/Response.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Response.cpp')
-rw-r--r--src/Response.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Response.cpp b/src/Response.cpp
new file mode 100644
index 0000000..050a537
--- /dev/null
+++ b/src/Response.cpp
@@ -0,0 +1,36 @@
+#include "Response.hpp"
+
+Response::json Response::simple_response(std::string const &text, std::string const &session, bool success) {
+ std::vector<json> 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);
+ annotation["extra"] = extra;
+ return annotation;
+}
+
+Response::json Response::create_text(std::string const &text) {
+ std::vector<json> annotations;
+ annotations.emplace_back(create_annotation());
+ return create_text(text, std::move(annotations));
+}
+
+Response::json Response::create_text(std::string const &text, std::vector<json> &&annotations) {
+ json reply(crow::json::type::Object);
+ reply["text"] = text;
+ reply["annotations"] = std::move(annotations);
+ return reply;
+}
+
+Response::json Response::create_response(std::vector<json> &&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;
+} \ No newline at end of file