tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Gift.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct Gift {
10 Gift() = default;
11 explicit Gift(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::string id;
17
20
22 std::int64_t starCount{};
23
25 std::int64_t upgradeStarCount{};
26
28 std::int64_t totalCount{};
29
31 std::int64_t remainingCount{};
32
35
38 nl::json toJson() const {
39 nl::json json = nl::json::object();
40 OBJECT_SERIALIZE_FIELD(json, "id", id);
41 OBJECT_SERIALIZE_FIELD_PTR(json, "sticker", sticker);
42 OBJECT_SERIALIZE_FIELD(json, "star_count", starCount);
43 OBJECT_SERIALIZE_FIELD(json, "upgrade_star_count", upgradeStarCount);
44 OBJECT_SERIALIZE_FIELD(json, "total_count", totalCount);
45 OBJECT_SERIALIZE_FIELD(json, "remaining_count", remainingCount);
47 return json;
48 }
49
51 void fromJson(const nl::json& json) {
52 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
53 OBJECT_DESERIALIZE_FIELD_PTR(json, "sticker", sticker, false);
54 OBJECT_DESERIALIZE_FIELD(json, "star_count", starCount, 0, false);
55 OBJECT_DESERIALIZE_FIELD(json, "upgrade_star_count", upgradeStarCount, 0, true);
56 OBJECT_DESERIALIZE_FIELD(json, "total_count", totalCount, 0, true);
57 OBJECT_DESERIALIZE_FIELD(json, "remaining_count", remainingCount, 0, true);
59 }
60 };
61}
#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 represents a gift that can be sent by the bot. https://core.telegram.org/bots/api#gift.
Definition Gift.hpp:9
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:28
Ptr< Sticker > sticker
The sticker that represents the gift.
Definition Gift.hpp:19
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:25
Ptr< Chat > publisherChat
Optional. Information about the chat that published the gift.
Definition Gift.hpp:34
std::int64_t remainingCount
Optional. The number of remaining gifts of this type that can be sent; for limited gifts only.
Definition Gift.hpp:31
Gift()=default
nl::json toJson() const
Serializes this object to JSON.
Definition Gift.hpp:38
std::string id
Unique identifier of the gift.
Definition Gift.hpp:16
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Gift.hpp:51
std::int64_t starCount
The number of Telegram Stars that must be paid to send the sticker.
Definition Gift.hpp:22
Gift(const nl::json &json)
Definition Gift.hpp:11