tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
UniqueGiftSymbol.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 UniqueGiftSymbol() = default;
10 explicit UniqueGiftSymbol(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string name;
16
19
21 std::int32_t rarityPerMille{};
22
24 nl::json toJson() const {
25 nl::json json = nl::json::object();
26 OBJECT_SERIALIZE_FIELD(json, "name", name);
27 OBJECT_SERIALIZE_FIELD_PTR(json, "sticker", sticker);
28 OBJECT_SERIALIZE_FIELD(json, "rarity_per_mille", rarityPerMille);
29 return json;
30 }
31
33 void fromJson(const nl::json& json) {
34 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
35 OBJECT_DESERIALIZE_FIELD_PTR(json, "sticker", sticker, false);
36 OBJECT_DESERIALIZE_FIELD(json, "rarity_per_mille", rarityPerMille, 0, false);
37 }
38 };
39}
#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
This object describes the symbol shown on the pattern of a unique gift. https://core....
UniqueGiftSymbol(const nl::json &json)
std::int32_t rarityPerMille
The number of unique gifts that receive this symbol for every 1000 gifts upgraded.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< Sticker > sticker
The sticker that represents the unique gift.
nl::json toJson() const
Serializes this object to JSON.
std::string name
Name of the symbol.