Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
user.hpp
1 #ifndef CPPGRAM_USER_HPP
2 #define CPPGRAM_USER_HPP
3 
4 #include <experimental/optional>
5 #include <string>
6 
7 #include <json/json.h>
8 
9 namespace cppgram
10 {
11 namespace types
12 {
20 class User
21 {
24  public:
26  uint_fast32_t id;
27 
29  std::string first_name;
30 
32  std::experimental::optional<std::string> last_name,
33 
35  username;
36 
37  User( Json::Value &json_user )
38  : id( json_user["id"].asUInt() )
39  , first_name( json_user["first_name"].asString() )
40  {
41  if ( !json_user["last_name"].isNull() )
42  {
43  last_name.emplace( json_user["last_name"].asString() );
44  }
45 
46  if ( !json_user["username"].isNull() )
47  {
48  username.emplace( json_user["username"].asString() );
49  }
50  }
51 };
52 }
53 }
54 
55 #endif
std::experimental::optional< std::string > last_name
Optional. User‘s or bot’s last name
Definition: user.hpp:32
std::string first_name
User‘s or bot’s first name.
Definition: user.hpp:29
std::experimental::optional< std::string > username
Optional. User‘s or bot’s username
Definition: user.hpp:32
main namespace for Cppgram
uint_fast32_t id
Unique identifier for this user or bot.
Definition: user.hpp:26
User object.
Definition: user.hpp:20