added RequestCDDC::from_json

This commit is contained in:
gulliver 2022-11-15 12:42:35 +01:00
parent 1696e6a88d
commit b044d1883e
2 changed files with 15 additions and 3 deletions

View File

@ -97,7 +97,6 @@ crow::json::wvalue MintKeyCert::to_json() const {
return r;
}
crow::json::wvalue ResponseCDDC::to_json() const
{
crow::json::wvalue r;
@ -109,6 +108,18 @@ crow::json::wvalue ResponseCDDC::to_json() const
r["type"]= "response cddc";
return r;
}
std::optional<RequestCDDC> RequestCDDC::from_json(const crow::json::rvalue & json) {
if (json.has("cdd_serial")&&json.has("message_reference")) {
auto r = std::make_optional<RequestCDDC>();
r->cdd_serial=json["cdd_serial"].u();
r->message_reference= json["message_reference"].u();
return r;
}
else {
return std::nullopt;
}
}
/** blafasel */
class DefaultModel : public Model {
@ -122,7 +133,7 @@ private:
CDDC m_cddc;
};
std::unique_ptr<Model> Model::getModel(const std::string& backend_name)
std::unique_ptr<Model> Model::getModel(const std::string& /*backend_name*/)
{
//:wq
//if (backend_name=="default")

View File

@ -4,6 +4,7 @@
#include <memory>
#include <string>
#include <chrono>
#include <optional>
#include "crow/json.h"