tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
GiveawayWinners.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
10 GiveawayWinners() = default;
11 explicit GiveawayWinners(const nl::json& json) {
12 fromJson(json);
13 }
14
17
19 std::int32_t giveawayMessageId{};
20
22 std::time_t winnersSelectionDate{};
23
25 std::int32_t winnerCount{};
26
28 std::vector<Ptr<User>> winners;
29
31 std::int32_t additionalChatCount{};
32
34 std::int64_t prizeStarCount{};
35
38
40 std::int32_t unclaimedPrizeCount{};
41
44
47
49 std::string prizeDescription{};
50
51
54 nl::json toJson() const {
55 nl::json json = nl::json::object();
56 OBJECT_SERIALIZE_FIELD_PTR(json, "chat", chat);
57 OBJECT_SERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId);
58 OBJECT_SERIALIZE_FIELD(json, "winners_selection_date", winnersSelectionDate);
59 OBJECT_SERIALIZE_FIELD(json, "winner_count", winnerCount);
61 OBJECT_SERIALIZE_FIELD(json, "additional_chat_count", additionalChatCount);
62 OBJECT_SERIALIZE_FIELD(json, "prize_star_count", prizeStarCount);
63 OBJECT_SERIALIZE_FIELD(json, "premium_subscription_month_count", premiumSubscriptionMonthCount);
64 OBJECT_SERIALIZE_FIELD(json, "unclaimed_prize_count", unclaimedPrizeCount);
65 OBJECT_SERIALIZE_FIELD(json, "only_new_members", onlyNewMembers);
66 OBJECT_SERIALIZE_FIELD(json, "was_refunded", wasRefunded);
67 OBJECT_SERIALIZE_FIELD(json, "prize_description", prizeDescription);
68 return json;
69 }
70
72 void fromJson(const nl::json& json) {
73 OBJECT_DESERIALIZE_FIELD_PTR(json, "chat", chat, false);
74 OBJECT_DESERIALIZE_FIELD(json, "giveaway_message_id", giveawayMessageId, 0, false);
75 OBJECT_DESERIALIZE_FIELD(json, "winners_selection_date", winnersSelectionDate, 0, false);
76 OBJECT_DESERIALIZE_FIELD(json, "winner_count", winnerCount, 0, false);
77 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "winners", winners, false);
78 OBJECT_DESERIALIZE_FIELD(json, "additional_chat_count", additionalChatCount, 0, true);
79 OBJECT_DESERIALIZE_FIELD(json, "prize_star_count", prizeStarCount, 0, true);
80 OBJECT_DESERIALIZE_FIELD(json, "premium_subscription_month_count", premiumSubscriptionMonthCount, 0, true);
81 OBJECT_DESERIALIZE_FIELD(json, "unclaimed_prize_count", unclaimedPrizeCount, 0, true);
82 OBJECT_DESERIALIZE_FIELD(json, "only_new_members", onlyNewMembers, false, true);
83 OBJECT_DESERIALIZE_FIELD(json, "was_refunded", wasRefunded, false, true);
84 OBJECT_DESERIALIZE_FIELD(json, "prize_description", prizeDescription, "", true);
85 }
86 };
87}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object represents a message about the completion of a giveaway with public winners....
std::int32_t unclaimedPrizeCount
Optional. Number of undistributed prizes.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string prizeDescription
Optional. Description of additional giveaway prize.
Ptr< Chat > chat
The chat that created the giveaway.
std::int32_t additionalChatCount
Optional. The number of other chats the user had to join in order to be eligible for the giveaway.
std::int64_t prizeStarCount
Optional. The number of Telegram Stars that were split between giveaway winners; for Telegram Star gi...
std::int32_t premiumSubscriptionMonthCount
Optional. The number of months the Telegram Premium subscription won from the giveaway will be active...
std::time_t winnersSelectionDate
Point in time (Unix timestamp) when winners of the giveaway were selected.
bool onlyNewMembers
Optional. True, if only users who had joined the chats after the giveaway started were eligible to wi...
std::int32_t giveawayMessageId
Identifier of the message with the giveaway in the chat.
nl::json toJson() const
Serializes this object to JSON.
std::int32_t winnerCount
Total number of winners in the giveaway.
std::vector< Ptr< User > > winners
List of up to 100 winners of the giveaway.
bool wasRefunded
Optional. True, if the giveaway was canceled because the payment for it was refunded.
GiveawayWinners(const nl::json &json)