tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
PaidMediaInfo.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
8 struct PaidMediaInfo {
9 PaidMediaInfo() = default;
10 explicit PaidMediaInfo(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::int64_t starCount{};
16
18 std::vector<Ptr<PaidMedia>> paidMedia;
19
20
23 nl::json toJson() const {
24 nl::json json = nl::json::object();
25 OBJECT_SERIALIZE_FIELD(json, "star_count", starCount);
27 return json;
28 }
29
31 void fromJson(const nl::json& json) {
32 OBJECT_DESERIALIZE_FIELD(json, "star_count", starCount, 0, false);
33 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "paid_media", paidMedia, false);
34 }
35 };
36}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
Describes the paid media added to a message. https://core.telegram.org/bots/api#paidmediainfo.
std::int64_t starCount
The number of Telegram Stars that must be paid to buy access to the media.
nl::json toJson() const
Serializes this object to JSON.
std::vector< Ptr< PaidMedia > > paidMedia
Information about the paid media.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
PaidMediaInfo(const nl::json &json)