Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
contact.hpp
1 #ifndef CPPGRAM_CONTACT_HPP
2 #define CPPGRAM_CONTACT_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 Contact
21 {
24  public:
26  std::string phone_number,
27 
29  first_name;
30 
32  std::experimental::optional<std::string> last_name;
33 
35  std::experimental::optional<int_fast32_t> user_id;
36 
37  Contact( Json::Value &json_contact )
38  : phone_number( json_contact["phone_number"].asString() )
39  , first_name( json_contact["first_name"].asString() )
40  {
41  if ( !json_contact["last_name"].isNull() )
42  {
43  last_name.emplace( json_contact["last_name"].asString() );
44  }
45 
46  if ( !json_contact["user_id"].isNull() )
47  {
48  user_id.emplace( json_contact["user_id"].asUInt() );
49  }
50  }
51 };
52 }
53 }
54 
55 #endif
std::string phone_number
Contact&#39;s phone number.
Definition: contact.hpp:26
std::experimental::optional< int_fast32_t > user_id
Optional. Contact&#39;s user identifier in Telegram
Definition: contact.hpp:35
std::experimental::optional< std::string > last_name
Optional. Contact&#39;s last name
Definition: contact.hpp:32
Contact send by a user.
Definition: contact.hpp:20
main namespace for Cppgram
std::string first_name
Contact&#39;s first name.
Definition: contact.hpp:26