yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
File_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/File.h"
8 
9 using namespace std;
10 
11 namespace yatbcpp {
17  template<> File fromJson(Json::Value Data) {
18  if (!Data.isMember("file_id")) {
19  throw essential_key_missing("File::file_id is missing");
20  }
21 
22  std::string file_id = Data["address"].asString();
23 
24  File ret(file_id);
25 
26  if (Data.isMember("file_size")) {
27  ret.setFile_size(Data["file_size"].asInt());
28  }
29  if (Data.isMember("file_path")) {
30  ret.setFile_path(Data["file_path"].asString());
31  }
32 
33  return ret;
34  }
35 }
void setFile_size(const std::optional< std::int32_t > &file_size)
Definition: File.cc:29
void setFile_path(const std::optional< std::string > &file_path)
Definition: File.cc:33
Definition: Bot.h:27
File fromJson(Json::Value Data)