tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
AcceptedGiftTypes.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
5
9 AcceptedGiftTypes() = default;
10 explicit AcceptedGiftTypes(const nl::json& json) {
11 fromJson(json);
12 }
13
16
19
22
25
28 nl::json toJson() const {
29 nl::json json = nl::json::object();
30 OBJECT_SERIALIZE_FIELD(json, "unlimited_gifts", unlimitedGifts);
31 OBJECT_SERIALIZE_FIELD(json, "limited_gifts", limitedGifts);
32 OBJECT_SERIALIZE_FIELD(json, "unique_gifts", uniqueGifts);
33 OBJECT_SERIALIZE_FIELD(json, "premium_subscription", premiumSubscription);
34 return json;
35 }
36
38 void fromJson(const nl::json& json) {
39 OBJECT_DESERIALIZE_FIELD(json, "unlimited_gifts", unlimitedGifts, false, false);
40 OBJECT_DESERIALIZE_FIELD(json, "limited_gifts", limitedGifts, false, false);
41 OBJECT_DESERIALIZE_FIELD(json, "unique_gifts", uniqueGifts, false, false);
42 OBJECT_DESERIALIZE_FIELD(json, "premium_subscription", premiumSubscription, false, false);
43 }
44 };
45
46}
#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
This object describes the types of gifts that can be gifted to a user or a chat. https://core....
bool uniqueGifts
True, if unique gifts or gifts that can be upgraded to unique for free are accepted.
bool unlimitedGifts
True, if unlimited regular gifts are accepted.
nl::json toJson() const
Serializes this object to JSON.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
bool premiumSubscription
True, if a Telegram Premium subscription is accepted.
AcceptedGiftTypes(const nl::json &json)
bool limitedGifts
True, if limited regular gifts are accepted.