tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChatShared.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct ChatShared {
8  ChatShared() = default;
9  explicit ChatShared(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::int32_t requestId{};
15 
21  std::int64_t chatId{};
22 
25  nl::json toJson() const {
26  nl::json json = nl::json::object();
27  OBJECT_SERIALIZE_FIELD(json, "request_id", requestId);
28  OBJECT_SERIALIZE_FIELD(json, "chat_id", chatId);
29  return json;
30  }
31 
33  void fromJson(const nl::json& json) {
34  OBJECT_DESERIALIZE_FIELD(json, "request_id", requestId, 0, false);
35  OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, 0, false);
36  }
37  };
38 }
#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
This object contains information about the chat whose identifier was shared with the bot using a Keyb...
Definition: ChatShared.hpp:7
nl::json toJson() const
Serializes this object to JSON.
Definition: ChatShared.hpp:25
std::int32_t requestId
Identifier of the request.
Definition: ChatShared.hpp:14
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: ChatShared.hpp:33
ChatShared(const nl::json &json)
Definition: ChatShared.hpp:9
std::int64_t chatId
Identifier of the shared chat. This number may have more than 32 significant bits and some programmin...
Definition: ChatShared.hpp:21