tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
LinkPreviewOptions.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
8 LinkPreviewOptions() = default;
9 explicit LinkPreviewOptions(const nl::json& json) {
10 fromJson(json);
11 }
12
14 bool isDisabled{};
15
17 std::string url;
18
22
26
30
31
34 nl::json toJson() const {
35 nl::json json = nl::json::object();
36 OBJECT_SERIALIZE_FIELD(json, "is_disabled", isDisabled);
37 OBJECT_SERIALIZE_FIELD(json, "url", url);
38 OBJECT_SERIALIZE_FIELD(json, "prefer_small_media", preferSmallMedia);
39 OBJECT_SERIALIZE_FIELD(json, "prefer_large_media", preferLargeMedia);
40 OBJECT_SERIALIZE_FIELD(json, "show_above_text", showAboveText);
41 return json;
42 }
43
45 void fromJson(const nl::json& json) {
46 OBJECT_DESERIALIZE_FIELD(json, "is_disabled", isDisabled, false, true);
47 OBJECT_DESERIALIZE_FIELD(json, "url", url, "", true);
48 OBJECT_DESERIALIZE_FIELD(json, "prefer_small_media", preferSmallMedia, false, true);
49 OBJECT_DESERIALIZE_FIELD(json, "prefer_large_media", preferLargeMedia, false, true);
50 OBJECT_DESERIALIZE_FIELD(json, "show_above_text", showAboveText, false, true);
51 }
52 };
53}
#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:46