tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChatInviteLink.hpp
Go to the documentation of this file.
1 #pragma once
4 
5 namespace tgbotxx {
8  struct ChatInviteLink {
9  ChatInviteLink() = default;
10  explicit ChatInviteLink(const nl::json& json) {
11  fromJson(json);
12  }
13 
15  std::string inviteLink;
16 
19 
22 
24  bool isPrimary{};
25 
27  bool isRevoked{};
28 
30  std::string name;
31 
33  std::time_t expireDate{};
34 
36  std::int32_t memberLimit{};
37 
39  std::int32_t pendingJoinRequestCount{};
40 
41 
44  nl::json toJson() const {
45  nl::json json = nl::json::object();
46  OBJECT_SERIALIZE_FIELD(json, "invite_link", inviteLink);
47  OBJECT_SERIALIZE_FIELD_PTR(json, "creator", creator);
48  OBJECT_SERIALIZE_FIELD(json, "creates_join_request", createsJoinRequest);
49  OBJECT_SERIALIZE_FIELD(json, "is_primary", isPrimary);
50  OBJECT_SERIALIZE_FIELD(json, "is_revoked", isRevoked);
51  OBJECT_SERIALIZE_FIELD(json, "name", name);
52  OBJECT_SERIALIZE_FIELD(json, "expire_date", expireDate);
53  OBJECT_SERIALIZE_FIELD(json, "member_limit", memberLimit);
54  OBJECT_SERIALIZE_FIELD(json, "pending_join_request_count", pendingJoinRequestCount);
55  return json;
56  }
57 
59  void fromJson(const nl::json& json) {
60  OBJECT_DESERIALIZE_FIELD(json, "invite_link", inviteLink, "", false);
61  OBJECT_DESERIALIZE_FIELD_PTR(json, "creator", creator, false);
62  OBJECT_DESERIALIZE_FIELD(json, "creates_join_request", createsJoinRequest, false, false);
63  OBJECT_DESERIALIZE_FIELD(json, "is_primary", isPrimary, false, false);
64  OBJECT_DESERIALIZE_FIELD(json, "is_revoked", isRevoked, false, false);
65  OBJECT_DESERIALIZE_FIELD(json, "name", name, "", true);
66  OBJECT_DESERIALIZE_FIELD(json, "expire_date", expireDate, 0, true);
67  OBJECT_DESERIALIZE_FIELD(json, "member_limit", memberLimit, 0, true);
68  OBJECT_DESERIALIZE_FIELD(json, "pending_join_request_count", pendingJoinRequestCount, 0, true);
69  }
70  };
71 }
#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