tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
BusinessConnection.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
7
11 BusinessConnection() = default;
12 explicit BusinessConnection(const nl::json& json) {
13 fromJson(json);
14 }
15
17 std::string id;
18
21
25 std::int64_t userChatId{};
26
28 std::int32_t date{};
29
32
34 bool isEnabled{};
35
38 nl::json toJson() const {
39 nl::json json = nl::json::object();
40 OBJECT_SERIALIZE_FIELD(json, "id", id);
41 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
42 OBJECT_SERIALIZE_FIELD(json, "user_chat_id", userChatId);
43 OBJECT_SERIALIZE_FIELD(json, "date", date);
44 OBJECT_SERIALIZE_FIELD_PTR(json, "rights", rights);
45 OBJECT_SERIALIZE_FIELD(json, "is_enabled", isEnabled);
46 return json;
47 }
48
50 void fromJson(const nl::json& json) {
51 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
52 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
53 OBJECT_DESERIALIZE_FIELD(json, "user_chat_id", userChatId, 0, false);
54 OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
55 OBJECT_DESERIALIZE_FIELD_PTR(json, "rights", rights, true);
56 OBJECT_DESERIALIZE_FIELD(json, "is_enabled", isEnabled, false, false);
57 }
58 };
59
60}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Describes the connection of the bot with a business account. https://core.telegram....
void fromJson(const nl::json &json)
Deserializes this object from JSON.
bool isEnabled
True, if the connection is active.
std::int64_t userChatId
Identifier of a private chat with the user who created the business connection. This number may have ...
Ptr< User > user
Business account user that created the business connection.
BusinessConnection(const nl::json &json)
Ptr< BusinessBotRights > rights
Optional. Rights of the business bot.
std::string id
Unique identifier of the business connection.
nl::json toJson() const
Serializes this object to JSON.
std::int32_t date
Date the connection was established in Unix time.