tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
UniqueGift.hpp
Go to the documentation of this file.
1#pragma once
7
8namespace tgbotxx {
11 struct UniqueGift {
12 UniqueGift() = default;
13 explicit UniqueGift(const nl::json& json) {
14 fromJson(json);
15 }
16
18 std::string baseName;
19
21 std::string name;
22
24 std::int32_t number{};
25
28
31
34
37
40 nl::json toJson() const {
41 nl::json json = nl::json::object();
42 OBJECT_SERIALIZE_FIELD(json, "base_name", baseName);
43 OBJECT_SERIALIZE_FIELD(json, "name", name);
44 OBJECT_SERIALIZE_FIELD(json, "number", number);
45 OBJECT_SERIALIZE_FIELD_PTR(json, "model", model);
46 OBJECT_SERIALIZE_FIELD_PTR(json, "symbol", symbol);
47 OBJECT_SERIALIZE_FIELD_PTR(json, "backdrop", backdrop);
48 OBJECT_SERIALIZE_FIELD_PTR(json, "publisher_chat", publisherChat);
49 return json;
50 }
51
53 void fromJson(const nl::json& json) {
54 OBJECT_DESERIALIZE_FIELD(json, "base_name", baseName, "", false);
55 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
56 OBJECT_DESERIALIZE_FIELD(json, "number", number, 0, false);
57 OBJECT_DESERIALIZE_FIELD_PTR(json, "model", model, false);
58 OBJECT_DESERIALIZE_FIELD_PTR(json, "symbol", symbol, false);
59 OBJECT_DESERIALIZE_FIELD_PTR(json, "backdrop", backdrop, false);
60 OBJECT_DESERIALIZE_FIELD_PTR(json, "publisher_chat", publisherChat, true);
61 }
62 };
63}
#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 describes a unique gift that was upgraded from a regular gift. https://core....
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.
std::string name
Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas.
Ptr< UniqueGiftModel > model
Model of the gift.
Ptr< UniqueGiftSymbol > symbol
Symbol of the gift.
std::string baseName
Human-readable name of the regular gift from which this unique gift was upgraded.
Ptr< Chat > publisherChat
Optional. Information about the chat that published the gift.
Ptr< UniqueGiftBackdrop > backdrop
Backdrop of the gift.
UniqueGift(const nl::json &json)
std::int32_t number
Unique number of the upgraded gift among gifts upgraded from the same regular gift.