tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChatMemberUpdated.hpp
Go to the documentation of this file.
1 #pragma once
3 // TODO: circular include ? Chat and here
6 //
9 
10 namespace tgbotxx {
14  ChatMemberUpdated() = default;
15  explicit ChatMemberUpdated(const nl::json& json) {
16  fromJson(json);
17  }
18 
21 
24 
26  std::time_t date{};
27 
30 
33 
36 
39 
42  nl::json toJson() const {
43  nl::json json = nl::json::object();
44  OBJECT_SERIALIZE_FIELD_PTR(json, "chat", chat);
45  OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
46  OBJECT_SERIALIZE_FIELD(json, "date", date);
47  OBJECT_SERIALIZE_FIELD_PTR(json, "old_chat_member", oldChatMember);
48  OBJECT_SERIALIZE_FIELD_PTR(json, "new_chat_member", newChatMember);
49  OBJECT_SERIALIZE_FIELD_PTR(json, "invite_link", inviteLink);
50  OBJECT_SERIALIZE_FIELD(json, "via_chat_folder_invite_link", viaChatFolderInviteLink);
51  return json;
52  }
53 
55  void fromJson(const nl::json& json) {
56  OBJECT_DESERIALIZE_FIELD_PTR(json, "chat", chat, false);
57  OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
58  OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
59  OBJECT_DESERIALIZE_FIELD_PTR(json, "old_chat_member", oldChatMember, false);
60  OBJECT_DESERIALIZE_FIELD_PTR(json, "new_chat_member", newChatMember, false);
61  OBJECT_DESERIALIZE_FIELD_PTR(json, "invite_link", inviteLink, true);
62  OBJECT_DESERIALIZE_FIELD(json, "via_chat_folder_invite_link", viaChatFolderInviteLink, false, true);
63  }
64  };
65 }
#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:70
#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:44
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
This object represents changes in the status of a chat member. https://core.telegram....
Ptr< ChatInviteLink > inviteLink
Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link e...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
bool viaChatFolderInviteLink
Optional. True, if the user joined the chat via a chat folder invite link.
std::time_t date
Date the change was done in Unix time.
Ptr< ChatMember > oldChatMember
Previous information about the chat member.
Ptr< Chat > chat
Chat the user belongs to.
Ptr< ChatMember > newChatMember
New information about the chat member.
ChatMemberUpdated(const nl::json &json)
nl::json toJson() const
Serializes this object to JSON.
Ptr< User > from
Performer of the action, which resulted in the change.