tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Gift.hpp
Go to the documentation of this file.
1#pragma once
6
7namespace tgbotxx {
10 struct Gift {
11 Gift() = default;
12 explicit Gift(const nl::json& json) {
14 }
15
17 std::string id;
18
21
23 std::int64_t starCount{};
24
26 std::int64_t upgradeStarCount{};
27
29 bool isPremium{};
30
32 bool hasColors{};
33
35 std::int64_t totalCount{};
36
38 std::int64_t remainingCount{};
39
41 std::int64_t personalTotalCount{};
42
44 std::int64_t personalRemainingCount{};
45
48
50 std::int64_t uniqueGiftVariantCount{};
51
54
57 nl::json toJson() const {
58 nl::json json = nl::json::object();
62 OBJECT_SERIALIZE_FIELD(json, "upgrade_star_count", upgradeStarCount);
65 OBJECT_SERIALIZE_FIELD(json, "total_count", totalCount);
66 OBJECT_SERIALIZE_FIELD(json, "remaining_count", remainingCount);
67 OBJECT_SERIALIZE_FIELD(json, "personal_total_count", personalTotalCount);
68 OBJECT_SERIALIZE_FIELD(json, "personal_remaining_count", personalRemainingCount);
70 OBJECT_SERIALIZE_FIELD(json, "unique_gift_variant_count", uniqueGiftVariantCount);
72 return json;
73 }
74
76 void fromJson(const nl::json& json) {
77 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
78 OBJECT_DESERIALIZE_FIELD_PTR(json, "sticker", sticker, false);
79 OBJECT_DESERIALIZE_FIELD(json, "star_count", starCount, 0, false);
80 OBJECT_DESERIALIZE_FIELD(json, "upgrade_star_count", upgradeStarCount, 0, true);
81 OBJECT_DESERIALIZE_FIELD(json, "is_premium", isPremium, false, true);
82 OBJECT_DESERIALIZE_FIELD(json, "has_colors", hasColors, false, true);
83 OBJECT_DESERIALIZE_FIELD(json, "total_count", totalCount, 0, true);
84 OBJECT_DESERIALIZE_FIELD(json, "remaining_count", remainingCount, 0, true);
85 OBJECT_DESERIALIZE_FIELD(json, "personal_total_count", personalTotalCount, 0, true);
86 OBJECT_DESERIALIZE_FIELD(json, "personal_remaining_count", personalRemainingCount, 0, true);
87 OBJECT_DESERIALIZE_FIELD_PTR(json, "background", background, true);
88 OBJECT_DESERIALIZE_FIELD(json, "unique_gift_variant_count", uniqueGiftVariantCount, 0, true);
89 OBJECT_DESERIALIZE_FIELD_PTR(json, "publisher_chat", publisherChat, true);
90 }
91 };
92}
#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 represents a gift that can be sent by the bot. https://core.telegram.org/bots/api#gift.
Definition Gift.hpp:10
std::int64_t personalTotalCount
Optional. The total number of gifts of this type that can be sent by the bot; for limited gifts only.
Definition Gift.hpp:41
bool hasColors
Optional. True, if the gift can be used (after being upgraded) to customize a user's appearance.
Definition Gift.hpp:32
std::int64_t totalCount
Optional. The total number of the gifts of this type that can be sent; for limited gifts only.
Definition Gift.hpp:35
bool isPremium
Optional. True, if the gift can only be purchased by Telegram Premium subscribers.
Definition Gift.hpp:29
Ptr< Sticker > sticker
The sticker that represents the gift.
Definition Gift.hpp:20
std::int64_t upgradeStarCount
Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one.
Definition Gift.hpp:26
Ptr< Chat > publisherChat
Optional. Information about the chat that published the gift.
Definition Gift.hpp:53
std::int64_t remainingCount
Optional. The number of remaining gifts of this type that can be sent; for limited gifts only.
Definition Gift.hpp:38
Gift()=default
std::int64_t personalRemainingCount
Optional. The number of remaining gifts of this type that can be sent by the bot; for limited gifts o...
Definition Gift.hpp:44
nl::json toJson() const
Serializes this object to JSON.
Definition Gift.hpp:57
std::int64_t uniqueGiftVariantCount
Optional. The total number of different unique gifts that can be obtained by upgrading the gift.
Definition Gift.hpp:50
std::string id
Unique identifier of the gift.
Definition Gift.hpp:17
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Gift.hpp:76
Ptr< GiftBackground > background
Optional. Information about the chat that published the gift.
Definition Gift.hpp:47
std::int64_t starCount
The number of Telegram Stars that must be paid to send the sticker.
Definition Gift.hpp:23
Gift(const nl::json &json)
Definition Gift.hpp:12