tgbotxx  1.1.6.9
Telegram Bot C++ Library
PassportFile.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
8  struct PassportFile {
9  PassportFile() = default;
10  explicit PassportFile(const nl::json& json) {
11  fromJson(json);
12  }
13 
15  std::string fileId;
16 
19  std::string fileUniqueId;
20 
22  std::int64_t fileSize{};
23 
25  std::time_t fileDate{};
26 
29  nl::json toJson() const {
30  nl::json json = nl::json::object();
31  OBJECT_SERIALIZE_FIELD(json, "file_id", fileId);
32  OBJECT_SERIALIZE_FIELD(json, "file_unique_id", fileUniqueId);
33  OBJECT_SERIALIZE_FIELD(json, "file_size", fileSize);
34  OBJECT_SERIALIZE_FIELD(json, "file_date", fileDate);
35  return json;
36  }
37 
39  void fromJson(const nl::json& json) {
40  OBJECT_DESERIALIZE_FIELD(json, "file_id", fileId, "", false);
41  OBJECT_DESERIALIZE_FIELD(json, "file_unique_id", fileUniqueId, "", false);
42  OBJECT_DESERIALIZE_FIELD(json, "file_size", fileSize, 0, false);
43  OBJECT_DESERIALIZE_FIELD(json, "file_date", fileDate, 0, false);
44  }
45  };
46 }
#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 a file uploaded to Telegram Passport. Currently all Telegram Passport files ar...
Definition: PassportFile.hpp:8
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.
std::string fileUniqueId
Unique identifier for this file, which is supposed to be the same over time and for different bots....
std::int64_t fileSize
File size in bytes.
std::string fileId
Identifier for this file, which can be used to download or reuse the file.
std::time_t fileDate
Unix time when the file was uploaded.
PassportFile(const nl::json &json)