tgbotxx
1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Contact.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <
tgbotxx/objects/Object.hpp
>
3
4
namespace
tgbotxx
{
7
struct
Contact
{
8
Contact
() =
default
;
9
explicit
Contact
(
const
nl::json&
json
) {
10
fromJson
(
json
);
11
}
12
14
std::string
phoneNumber
;
15
17
std::string
firstName
;
18
20
std::string
lastName
;
21
26
std::int64_t
userId
{};
27
30
std::string
vcard
;
31
32
35
nl::json
toJson
()
const
{
36
nl::json
json
= nl::json::object();
37
OBJECT_SERIALIZE_FIELD
(
json
,
"phone_number"
,
phoneNumber
);
38
OBJECT_SERIALIZE_FIELD
(
json
,
"first_name"
,
firstName
);
39
OBJECT_SERIALIZE_FIELD
(
json
,
"last_name"
,
lastName
);
40
OBJECT_SERIALIZE_FIELD
(
json
,
"user_id"
,
userId
);
41
OBJECT_SERIALIZE_FIELD
(
json
,
"vcard"
,
vcard
);
42
return
json
;
43
}
44
46
void
fromJson
(
const
nl::json&
json
) {
47
OBJECT_DESERIALIZE_FIELD
(
json
,
"phone_number"
,
phoneNumber
,
""
,
false
);
48
OBJECT_DESERIALIZE_FIELD
(
json
,
"first_name"
,
firstName
,
""
,
false
);
49
OBJECT_DESERIALIZE_FIELD
(
json
,
"last_name"
,
lastName
,
""
,
true
);
50
OBJECT_DESERIALIZE_FIELD
(
json
,
"user_id"
,
userId
, 0,
true
);
51
OBJECT_DESERIALIZE_FIELD
(
json
,
"vcard"
,
vcard
,
""
,
true
);
52
}
53
};
54
}
Object.hpp
OBJECT_SERIALIZE_FIELD
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition
Object.hpp:27
OBJECT_DESERIALIZE_FIELD
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition
Object.hpp:64
tgbotxx
Definition
Api.hpp:11
tgbotxx::Ptr
std::shared_ptr< T > Ptr
Definition
Ptr.hpp:6
tgbotxx::Contact
This object represents a phone contact. https://core.telegram.org/bots/api#contact.
Definition
Contact.hpp:7
tgbotxx::Contact::lastName
std::string lastName
Optional. Contact's last name.
Definition
Contact.hpp:20
tgbotxx::Contact::toJson
nl::json toJson() const
Serializes this object to JSON.
Definition
Contact.hpp:35
tgbotxx::Contact::phoneNumber
std::string phoneNumber
Contact's phone number.
Definition
Contact.hpp:14
tgbotxx::Contact::firstName
std::string firstName
Contact's first name.
Definition
Contact.hpp:17
tgbotxx::Contact::fromJson
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition
Contact.hpp:46
tgbotxx::Contact::Contact
Contact(const nl::json &json)
Definition
Contact.hpp:9
tgbotxx::Contact::vcard
std::string vcard
Optional. Additional data about the contact in the form of a vCard https://en.wikipedia....
Definition
Contact.hpp:30
tgbotxx::Contact::userId
std::int64_t userId
Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits a...
Definition
Contact.hpp:26
tgbotxx::Contact::Contact
Contact()=default
include
tgbotxx
objects
Contact.hpp
Generated on Sun Mar 22 2026 21:33:30 for tgbotxx by
1.9.8