Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
document.hpp
1 #ifndef CPPGRAM_DOCUMENT_HPP
2 #define CPPGRAM_DOCUMENT_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 {
22 class Document
23 {
26  public:
28  std::string file_id;
29 
31  std::experimental::optional<PhotoSize> thumb;
32 
34  std::experimental::optional<std::string> file_name,
35 
37  mime_type;
38 
40  std::experimental::optional<int_fast32_t> file_size;
41 
42  Document( Json::Value &json_document )
43  : file_id( json_document["file_id"].asString() )
44  {
45  if ( !json_document["thumb"].isNull() )
46  {
47  thumb.emplace( PhotoSize( json_document["thumb"] ) );
48  }
49 
50  if ( !json_document["file_name"].isNull() )
51  {
52  file_name.emplace( json_document["file_name"].asString() );
53  }
54 
55  if ( !json_document["mime_type"].isNull() )
56  {
57  mime_type.emplace( json_document["mime_type"].asString() );
58  }
59 
60  if ( !json_document["file_size"].isNull() )
61  {
62  file_size.emplace( json_document["file_size"].asUInt() );
63  }
64  }
65 };
66 }
67 }
68 
69 #endif
std::string file_id
Unique file identifier.
Definition: document.hpp:28
A photo or thumbnail.
Definition: photo_size.hpp:20
std::experimental::optional< std::string > mime_type
Optional. MIME type of the file as defined by sender
Definition: document.hpp:34
std::experimental::optional< int_fast32_t > file_size
Optional. File size
Definition: document.hpp:40
A document send by a user.
Definition: document.hpp:22
std::experimental::optional< PhotoSize > thumb
Optional. Document thumbnail as defined by sender
Definition: document.hpp:31
main namespace for Cppgram
std::experimental::optional< std::string > file_name
Optional. Original filename as defined by sender
Definition: document.hpp:34