Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
video.hpp
1 #ifndef CPPGRAM_VIDEO_HPP
2 #define CPPGRAM_VIDEO_HPP
3 
4 #include <experimental/optional>
5 #include <string>
6 
7 #include <json/json.h>
8 
9 #include "photo_size.hpp"
10 
11 namespace cppgram
12 {
13 namespace types
14 {
21 class Video
22 {
25  public:
27  std::string file_id;
28 
30  uint_fast32_t width,
31 
33  height,
34 
36  duration;
37 
39  std::experimental::optional<PhotoSize> thumb;
40 
42  std::experimental::optional<std::string> mime_type;
43 
45  std::experimental::optional<uint_fast32_t> file_size;
46 
47  Video( Json::Value &json_video )
48  : file_id( json_video["file_id"].asString() )
49  , width( json_video["width"].asUInt() )
50  , height( json_video["height"].asUInt() )
51  , duration( json_video["duration"].asUInt() )
52  {
53  if ( !json_video["thumb"].isNull() )
54  {
55  thumb.emplace( PhotoSize( json_video["thumb"] ) );
56  }
57 
58  if ( !json_video["mime_type"].isNull() )
59  {
60  mime_type.emplace( json_video["mime_type"].asString() );
61  }
62 
63  if ( !json_video["file_size"].isNull() )
64  {
65  file_size.emplace( json_video["file_size"].asUInt() );
66  }
67  }
68 };
69 }
70 }
71 
72 #endif
std::experimental::optional< uint_fast32_t > file_size
Optional. File size
Definition: video.hpp:45
std::experimental::optional< std::string > mime_type
Optional. Mime type of a file as defined by sender
Definition: video.hpp:42
uint_fast32_t duration
Duration of the video in seconds as defined by sender.
Definition: video.hpp:30
std::experimental::optional< PhotoSize > thumb
Optional. Video thumbnail
Definition: video.hpp:39
uint_fast32_t height
Video height as defined by sender.
Definition: video.hpp:30
A photo or thumbnail.
Definition: photo_size.hpp:20
A video sent by user.
Definition: video.hpp:21
std::string file_id
Unique identifier for this file.
Definition: video.hpp:27
main namespace for Cppgram
uint_fast32_t width
Video width as defined by sender.
Definition: video.hpp:30