tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
GiveawayCompleted.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 GiveawayCompleted() = default;
10 explicit GiveawayCompleted(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::int32_t winnerCount{};
16
18 std::int32_t unclaimedPrizeCount{};
19
22
25
28 nl::json toJson() const {
29 nl::json json = nl::json::object();
30 OBJECT_SERIALIZE_FIELD(json, "winner_count", winnerCount);
31 OBJECT_SERIALIZE_FIELD(json, "unclaimed_prize_count", unclaimedPrizeCount);
32 OBJECT_SERIALIZE_FIELD_PTR(json, "giveaway_message", giveawayMessage);
33 OBJECT_SERIALIZE_FIELD(json, "is_star_giveaway", isStarGiveaway);
34 return json;
35 }
37 void fromJson(const nl::json& json) {
38 OBJECT_DESERIALIZE_FIELD(json, "winner_count", winnerCount, 0, false);
39 OBJECT_DESERIALIZE_FIELD(json, "unclaimed_prize_count", unclaimedPrizeCount, 0, true);
40 OBJECT_DESERIALIZE_FIELD_PTR(json, "giveaway_message", giveawayMessage, true);
41 OBJECT_DESERIALIZE_FIELD(json, "is_star_giveaway", isStarGiveaway, false, true);
42 }
43 };
44
45}
#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 service message about the completion of a giveaway without public winners....
Ptr< Message > giveawayMessage
Optional. Message with the giveaway that was completed.
nl::json toJson() const
Serializes this object to JSON.
bool isStarGiveaway
Optional. True, if the giveaway is a Telegram Star giveaway.
GiveawayCompleted(const nl::json &json)
std::int32_t winnerCount
Number of winners in the giveaway.
std::int32_t unclaimedPrizeCount
Optional. Number of undistributed prizes.
void fromJson(const nl::json &json)
Deserializes this object from JSON.