tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
StoryAreaType.hpp
Go to the documentation of this file.
1#pragma once
5#include <string>
6
7namespace tgbotxx {
8
12 StoryAreaType() = default;
13 explicit StoryAreaType(const nl::json& json) {
15 }
16 virtual ~StoryAreaType() = default;
17
19 std::string type;
20
21 [[nodiscard]] virtual nl::json toJson() const {
22 nl::json json = nl::json::object();
24 return json;
25 }
26
27 virtual void fromJson(const nl::json& json) {
28 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
29 }
30 };
31
35 type = "location";
36 }
37 explicit StoryAreaTypeLocation(const nl::json& json) {
39 }
40
41 float latitude{};
42 float longitude{};
44
45 [[nodiscard]] nl::json toJson() const override {
46 nl::json json = StoryAreaType::toJson();
50 return json;
51 }
52
53 void fromJson(const nl::json& json) override {
55 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
56 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
57 OBJECT_DESERIALIZE_FIELD_PTR(json, "address", address, true);
58 }
59 };
60
64 type = "suggested_reaction";
65 }
69
71 bool isDark{};
72 bool isFlipped{};
73
74 [[nodiscard]] nl::json toJson() const override {
75 nl::json json = StoryAreaType::toJson();
79 return json;
80 }
81
82 void fromJson(const nl::json& json) override {
84 OBJECT_DESERIALIZE_FIELD_PTR(json, "reaction_type", reactionType, false);
85 OBJECT_DESERIALIZE_FIELD(json, "is_dark", isDark, false, true);
86 OBJECT_DESERIALIZE_FIELD(json, "is_flipped", isFlipped, false, true);
87 }
88 };
89
93 type = "link";
94 }
95 explicit StoryAreaTypeLink(const nl::json& json) {
97 }
98
99 std::string url;
100
101 [[nodiscard]] nl::json toJson() const override {
102 nl::json json = StoryAreaType::toJson();
104 return json;
105 }
106
107 void fromJson(const nl::json& json) override {
109 OBJECT_DESERIALIZE_FIELD(json, "url", url, "", false);
110 }
111 };
112
116 type = "weather";
117 }
118 explicit StoryAreaTypeWeather(const nl::json& json) {
120 }
121
122 float temperature{};
123 std::string emoji;
124 std::int32_t backgroundColor{};
125
126 [[nodiscard]] nl::json toJson() const override {
127 nl::json json = StoryAreaType::toJson();
128 OBJECT_SERIALIZE_FIELD(json, "temperature", temperature);
130 OBJECT_SERIALIZE_FIELD(json, "background_color", backgroundColor);
131 return json;
132 }
133
134 void fromJson(const nl::json& json) override {
136 OBJECT_DESERIALIZE_FIELD(json, "temperature", temperature, 0.0f, false);
137 OBJECT_DESERIALIZE_FIELD(json, "emoji", emoji, "", false);
138 OBJECT_DESERIALIZE_FIELD(json, "background_color", backgroundColor, 0, false);
139 }
140 };
141
145 type = "unique_gift";
146 }
150
151 std::string name;
152
153 [[nodiscard]] nl::json toJson() const override {
154 nl::json json = StoryAreaType::toJson();
156 return json;
157 }
158
159 void fromJson(const nl::json& json) override {
161 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
162 }
163 };
164
165}
#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:72
#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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Base class for types of clickable areas on a story https://core.telegram.org/bots/api#storyareatype.
virtual void fromJson(const nl::json &json)
virtual ~StoryAreaType()=default
StoryAreaType()=default
StoryAreaType(const nl::json &json)
std::string type
Type of the area.
virtual nl::json toJson() const
Story area pointing to a link.
nl::json toJson() const override
StoryAreaTypeLink(const nl::json &json)
void fromJson(const nl::json &json) override
std::string url
StoryAreaTypeLink()
Story area pointing to a location.
nl::json toJson() const override
Ptr< LocationAddress > address
StoryAreaTypeLocation(const nl::json &json)
float latitude
float longitude
void fromJson(const nl::json &json) override
StoryAreaTypeLocation()
Story area pointing to a suggested reaction.
StoryAreaTypeSuggestedReaction(const nl::json &json)
StoryAreaTypeSuggestedReaction()
bool isFlipped
Ptr< ReactionType > reactionType
bool isDark
void fromJson(const nl::json &json) override
nl::json toJson() const override
Story area pointing to a unique gift.
void fromJson(const nl::json &json) override
StoryAreaTypeUniqueGift()
StoryAreaTypeUniqueGift(const nl::json &json)
std::string name
nl::json toJson() const override
Story area showing weather information.
std::string emoji
nl::json toJson() const override
StoryAreaTypeWeather(const nl::json &json)
void fromJson(const nl::json &json) override
float temperature
StoryAreaTypeWeather()
std::int32_t backgroundColor