tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Video.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
8 struct Video {
9 Video() = default;
10 explicit Video(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string fileId;
16
19 std::string fileUniqueId;
20
22 std::int32_t width{};
23
25 std::int32_t height{};
26
28 std::int32_t duration{};
29
32
34 std::string fileName;
35
37 std::string mimeType;
38
42 std::int64_t fileSize{};
43
46 nl::json toJson() const {
47 nl::json json = nl::json::object();
48 OBJECT_SERIALIZE_FIELD(json, "file_id", fileId);
49 OBJECT_SERIALIZE_FIELD(json, "file_unique_id", fileUniqueId);
50 OBJECT_SERIALIZE_FIELD(json, "width", width);
51 OBJECT_SERIALIZE_FIELD(json, "height", height);
52 OBJECT_SERIALIZE_FIELD(json, "duration", duration);
53 OBJECT_SERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail);
54 OBJECT_SERIALIZE_FIELD(json, "file_name", fileName);
55 OBJECT_SERIALIZE_FIELD(json, "mime_type", mimeType);
56 OBJECT_SERIALIZE_FIELD(json, "file_size", fileSize);
57 return json;
58 }
59
61 void fromJson(const nl::json& json) {
62 OBJECT_DESERIALIZE_FIELD(json, "file_id", fileId, "", false);
63 OBJECT_DESERIALIZE_FIELD(json, "file_unique_id", fileUniqueId, "", false);
64 OBJECT_DESERIALIZE_FIELD(json, "width", width, 0, false);
65 OBJECT_DESERIALIZE_FIELD(json, "height", height, 0, false);
66 OBJECT_DESERIALIZE_FIELD(json, "duration", duration, 0, false);
67 OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
68 OBJECT_DESERIALIZE_FIELD(json, "file_name", fileName, "", true);
69 OBJECT_DESERIALIZE_FIELD(json, "mime_type", mimeType, "", true);
70 OBJECT_DESERIALIZE_FIELD(json, "file_size", fileSize, 0, true);
71 }
72 };
73}
#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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object represents a video file. https://core.telegram.org/bots/api#video.
Definition Video.hpp:8
Video()=default
std::string fileId
Identifier for this file, which can be used to download or reuse the file.
Definition Video.hpp:15
std::string fileName
Optional. Original filename as defined by sender.
Definition Video.hpp:34
std::string mimeType
Optional. MIME type of the file as defined by sender.
Definition Video.hpp:37
std::int32_t duration
Duration of the video in seconds as defined by sender.
Definition Video.hpp:28
std::int32_t width
Video width as defined by sender.
Definition Video.hpp:22
Video(const nl::json &json)
Definition Video.hpp:10
std::int64_t fileSize
Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have diff...
Definition Video.hpp:42
nl::json toJson() const
Serializes this object to JSON.
Definition Video.hpp:46
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Video.hpp:61
Ptr< PhotoSize > thumbnail
Optional. Video thumbnail.
Definition Video.hpp:31
std::int32_t height
Video height as defined by sender.
Definition Video.hpp:25
std::string fileUniqueId
Unique identifier for this file, which is supposed to be the same over time and for different bots....
Definition Video.hpp:19