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