tgbotxx  1.1.6.9
Telegram Bot C++ Library
PhotoSize.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct PhotoSize {
8  PhotoSize() = default;
9  explicit PhotoSize(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::string fileId;
15 
18  std::string fileUniqueId;
19 
21  std::int32_t width{};
22 
24  std::int32_t height{};
25 
27  std::int64_t fileSize{};
28 
31  nl::json toJson() const {
32  nl::json json = nl::json::object();
33  OBJECT_SERIALIZE_FIELD(json, "file_id", fileId);
34  OBJECT_SERIALIZE_FIELD(json, "file_unique_id", fileUniqueId);
35  OBJECT_SERIALIZE_FIELD(json, "width", width);
36  OBJECT_SERIALIZE_FIELD(json, "height", height);
37  OBJECT_SERIALIZE_FIELD(json, "file_size", fileSize);
38  return json;
39  }
40 
42  void fromJson(const nl::json& json) {
43  OBJECT_DESERIALIZE_FIELD(json, "file_id", fileId, "", false);
44  OBJECT_DESERIALIZE_FIELD(json, "file_unique_id", fileUniqueId, "", false);
45  OBJECT_DESERIALIZE_FIELD(json, "width", width, 0, false);
46  OBJECT_DESERIALIZE_FIELD(json, "height", height, 0, false);
47  OBJECT_DESERIALIZE_FIELD(json, "file_size", fileSize, 0, true);
48  }
49  };
50 }
#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 represents one size of a photo or a file / sticker thumbnail. https://core....
Definition: PhotoSize.hpp:7
std::int64_t fileSize
Optional. File size in bytes.
Definition: PhotoSize.hpp:27
nl::json toJson() const
Serializes this object to JSON.
Definition: PhotoSize.hpp:31
std::int32_t width
Photo width.
Definition: PhotoSize.hpp:21
std::string fileUniqueId
Unique identifier for this file, which is supposed to be the same over time and for different bots....
Definition: PhotoSize.hpp:18
std::string fileId
Identifier for this file, which can be used to download or reuse the file.
Definition: PhotoSize.hpp:14
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: PhotoSize.hpp:42
std::int32_t height
Photo height.
Definition: PhotoSize.hpp:24
PhotoSize(const nl::json &json)
Definition: PhotoSize.hpp:9