tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ChatBoostSource.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
12 ChatBoostSource() = default;
13 explicit ChatBoostSource(const nl::json& json) {
15 }
16 virtual ~ChatBoostSource() = default;
17
19 std::string source;
20
21
24 [[nodiscard]] virtual nl::json toJson() const {
25 nl::json json = nl::json::object();
27 return json;
28 }
29
31 virtual void fromJson(const nl::json& json) {
32 OBJECT_DESERIALIZE_FIELD(json, "source", source, "", false);
33 }
34 };
35
40 source = "premium";
41 }
45
48
49 [[nodiscard]] nl::json toJson() const override {
50 nl::json json = ChatBoostSource::toJson();
52 return json;
53 }
54 void fromJson(const nl::json& json) override {
56 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
57 }
58 };
59
64 source = "gift_code";
65 }
69
72
73 [[nodiscard]] nl::json toJson() const override {
74 nl::json json = ChatBoostSource::toJson();
76 return json;
77 }
78 void fromJson(const nl::json& json) override {
80 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
81 }
82 };
83
89 source = "giveaway";
90 }
94
97 std::int32_t giveawayMessageId{};
98
101
104
105 [[nodiscard]] nl::json toJson() const override {
106 nl::json json = ChatBoostSource::toJson();
107 OBJECT_SERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId);
109 OBJECT_SERIALIZE_FIELD(json, "is_unclaimed", isUnclaimed);
110 return json;
111 }
112 void fromJson(const nl::json& json) override {
114 OBJECT_DESERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId, 0, false);
115 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, true);
116 OBJECT_DESERIALIZE_FIELD(json, "is_unclaimed", isUnclaimed, 0, true);
117 }
118 };
119
120
121}
#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
The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscripti...
Ptr< User > user
User for which the gift code was created.
nl::json toJson() const override
Serializes this object to JSON.
ChatBoostSourceGiftCode(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times f...
Ptr< User > user
Optional. User that won the prize in the giveaway if any.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
std::int32_t giveawayMessageId
Identifier of a message in the chat with the giveaway; the message could have been deleted already....
ChatBoostSourceGiveaway(const nl::json &json)
bool isUnclaimed
Optional. True, if the giveaway was completed, but there was no user to win the prize.
This object describes the source of a chat boost. It can be one of:
ChatBoostSource(const nl::json &json)
virtual nl::json toJson() const
Serializes this object to JSON.
virtual ~ChatBoostSource()=default
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string source
Source of the boost.
The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscripti...
ChatBoostSourcePremium(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
Ptr< User > user
User that boosted the chat.