yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
InlineQuery_fromJson.cc
Go to the documentation of this file.
1 // From JSON Specialication //
4 #include <jsoncpp/json/json.h>
5 #include "types/telegram_type.h"
7 #include "types/InlineQuery.h"
8 namespace yatbcpp {
9 
15  template<>
16  InlineQuery fromJson(Json::Value Data) {
17  if(!Data.isMember("id")) {
18  throw essential_key_missing("Audio::id is missing");
19  }
20  if(!Data.isMember("from")) {
21  throw essential_key_missing("Audio::from is missing");
22  }
23  if(!Data.isMember("from")) {
24  throw essential_key_missing("Audio::from is missing");
25  }
26 
27  std::string id = Data["id"].asString();
28  User from = fromJson<User>(Data["from"]);
29  std::string query = Data["query"].asString();
30  std::string offset = Data["offset"].asString();
31 
32  InlineQuery ret(id, from, query,offset);
33 
34  if(Data.isMember("location")){
35  ret.setLocation(fromJson<Location>(Data["location"]));
36  }
37 
38 
39  return ret;
40  }
41 }
T fromJson(Json::Value Data)
Definition: Bot.h:27
void setLocation(const std::optional< Location > &location)
Definition: InlineQuery.cc:30
User fromJson< User >(Json::Value Data)