tgbotxx 1.1.6.9
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) {
14 _fromJson(json);
15 }
16
18 std::string source;
19
20
23 virtual nl::json toJson() const {
24 nl::json json = nl::json::object();
25 OBJECT_SERIALIZE_FIELD(json, "source", source);
26 return json;
27 }
28
30 virtual void fromJson(const nl::json& json) {
31 OBJECT_DESERIALIZE_FIELD(json, "source", source, "", false);
32 }
33
34 private:
35 void _fromJson(const nl::json& json) {
36 fromJson(json);
37 }
38 };
39
46 explicit ChatBoostSourcePremium(const nl::json& json) {
48 ChatBoostSource::source = "premium";
49 }
50
53
54 nl::json toJson() const override {
55 nl::json json = ChatBoostSource::toJson();
56 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
57 return json;
58 }
59 void fromJson(const nl::json& json) override {
61 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
62 }
63 };
64
71 explicit ChatBoostSourceGiftCode(const nl::json& json) {
73 ChatBoostSource::source = "gift_code";
74 }
75
78
79 nl::json toJson() const override {
80 nl::json json = ChatBoostSource::toJson();
81 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
82 return json;
83 }
84 void fromJson(const nl::json& json) override {
86 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
87 }
88 };
89
97 explicit ChatBoostSourceGiveaway(const nl::json& json) {
99 ChatBoostSource::source = "giveaway";
100 }
101
104 std::int32_t giveawayMessageId{};
105
108
111
112 nl::json toJson() const override {
113 nl::json json = ChatBoostSource::toJson();
114 OBJECT_SERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId);
115 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
116 OBJECT_SERIALIZE_FIELD(json, "is_unclaimed", isUnclaimed);
117 return json;
118 }
119 void fromJson(const nl::json& json) override {
121 OBJECT_DESERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId, 0, false);
122 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, true);
123 OBJECT_DESERIALIZE_FIELD(json, "is_unclaimed", isUnclaimed, 0, true);
124 }
125 };
126
127
128}
#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:70
#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:44
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 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.