tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChatJoinRequest.hpp
Go to the documentation of this file.
1 #pragma once
5 // TODO: circular include ? Chat ~ this
7 
8 namespace tgbotxx {
11  struct ChatJoinRequest {
12  ChatJoinRequest() = default;
13  explicit ChatJoinRequest(const nl::json& json) {
14  fromJson(json);
15  }
16 
19 
22 
27  std::int64_t userChatId{};
28 
30  std::time_t date{};
31 
33  std::string bio;
34 
37 
38 
41  nl::json toJson() const {
42  nl::json json = nl::json::object();
43  OBJECT_SERIALIZE_FIELD_PTR(json, "chat", chat);
44  OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
45  OBJECT_SERIALIZE_FIELD(json, "user_chat_id", userChatId);
46  OBJECT_SERIALIZE_FIELD(json, "date", date);
47  OBJECT_SERIALIZE_FIELD(json, "bio", bio);
48  OBJECT_SERIALIZE_FIELD_PTR(json, "invite_link", inviteLink);
49  return json;
50  }
51 
53  void fromJson(const nl::json& json) {
54  OBJECT_DESERIALIZE_FIELD_PTR(json, "chat", chat, false);
55  OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
56  OBJECT_DESERIALIZE_FIELD(json, "user_chat_id", userChatId, 0, false);
57  OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
58  OBJECT_DESERIALIZE_FIELD(json, "bio", bio, "", true);
59  OBJECT_DESERIALIZE_FIELD_PTR(json, "invite_link", inviteLink, true);
60  }
61  };
62 }
#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
Represents a join request sent to a chat. https://core.telegram.org/bots/api#chatjoinrequest.
std::int64_t userChatId
Identifier of a private chat with the user who sent the join request. This number may have more than ...
std::string bio
Optional. Bio of the user.
Ptr< User > from
User that sent the join request.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< ChatInviteLink > inviteLink
Optional. Chat invite link that was used by the user to send the join request.
ChatJoinRequest(const nl::json &json)
Ptr< Chat > chat
Chat to which the request was sent.
nl::json toJson() const
Serializes this object to JSON.
std::time_t date
Date the request was sent in Unix time.