tgbotxx  1.1.6.9
Telegram Bot C++ Library
VideoNote.hpp
Go to the documentation of this file.
1 #pragma once
4 
5 namespace tgbotxx {
8  struct VideoNote {
9  VideoNote() = default;
10  explicit VideoNote(const nl::json& json) {
11  fromJson(json);
12  }
13 
15  std::string fileId;
16 
19  std::string fileUniqueId;
20 
22  std::int32_t length{};
23 
25  std::int32_t duration{};
26 
29 
33  std::int64_t fileSize{};
34 
37  nl::json toJson() const {
38  nl::json json = nl::json::object();
39  OBJECT_SERIALIZE_FIELD(json, "file_id", fileId);
40  OBJECT_SERIALIZE_FIELD(json, "file_unique_id", fileUniqueId);
41  OBJECT_SERIALIZE_FIELD(json, "duration", duration);
42  OBJECT_SERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail);
43  OBJECT_SERIALIZE_FIELD(json, "file_size", fileSize);
44  return json;
45  }
46 
48  void fromJson(const nl::json& json) {
49  OBJECT_DESERIALIZE_FIELD(json, "file_id", fileId, "", false);
50  OBJECT_DESERIALIZE_FIELD(json, "file_unique_id", fileUniqueId, "", false);
51  OBJECT_DESERIALIZE_FIELD(json, "duration", duration, 0, false);
52  OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
53  OBJECT_DESERIALIZE_FIELD(json, "file_size", fileSize, 0, true);
54  }
55  };
56 }
#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
This object represents a video message (available in Telegram apps as of v.4.0). https://core....
Definition: VideoNote.hpp:8
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: VideoNote.hpp:48
VideoNote(const nl::json &json)
Definition: VideoNote.hpp:10
std::int32_t duration
Duration of the video in seconds as defined by sender.
Definition: VideoNote.hpp:25
Ptr< PhotoSize > thumbnail
Optional. Video thumbnail.
Definition: VideoNote.hpp:28
std::string fileUniqueId
Unique identifier for this file, which is supposed to be the same over time and for different bots....
Definition: VideoNote.hpp:19
std::int32_t length
Video width and height (diameter of the video message) as defined by sender.
Definition: VideoNote.hpp:22
nl::json toJson() const
Serializes this object to JSON.
Definition: VideoNote.hpp:37
std::string fileId
Identifier for this file, which can be used to download or reuse the file.
Definition: VideoNote.hpp:15
std::int64_t fileSize
Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have diff...
Definition: VideoNote.hpp:33