tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
UniqueGiftModel.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 UniqueGiftModel() = default;
10 explicit UniqueGiftModel(const nl::json& json) {
12 }
13
15 std::string name;
16
19
21 std::int32_t rarityPerMille{};
22
24 std::string rarity;
25
27 nl::json toJson() const {
28 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "rarity_per_mille", rarityPerMille);
33 return json;
34 }
35
37 void fromJson(const nl::json& json) {
38 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
39 OBJECT_DESERIALIZE_FIELD_PTR(json, "sticker", sticker, false);
40 OBJECT_DESERIALIZE_FIELD(json, "rarity_per_mille", rarityPerMille, 0, false);
41 OBJECT_DESERIALIZE_FIELD(json, "rarity", rarity, "", true);
42 }
43 };
44}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:32
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:92
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:64
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object describes the model of a unique gift. https://core.telegram.org/bots/api#uniquegiftmodel.
Ptr< Sticker > sticker
The sticker that represents the unique gift.
std::string name
Name of the model.
UniqueGiftModel(const nl::json &json)
std::string rarity
Optional. Rarity of the model if it is a crafted model. Currently, can be “uncommon”,...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int32_t rarityPerMille
The number of unique gifts that receive this model for every 1000 gift upgrades. Always 0 for crafted...
nl::json toJson() const
Serializes this object to JSON.