tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
GiftInfo.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct GiftInfo {
10 GiftInfo() = default;
11 explicit GiftInfo(const nl::json& json) {
13 }
14
17
19 std::string ownedGiftId;
20
23 std::int64_t convertStarCount{};
24
27
30
33
35 std::string text;
36
38 std::vector<Ptr<MessageEntity>> entities;
39
41 bool isPrivate{};
42
44 std::int32_t uniqueGiftNumber{};
45
48 nl::json toJson() const {
49 nl::json json = nl::json::object();
51 OBJECT_SERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId);
52 OBJECT_SERIALIZE_FIELD(json, "convert_star_count", convertStarCount);
53 OBJECT_SERIALIZE_FIELD(json, "prepaid_upgrade_star_count", prepaidUpgradeStarCount);
54 OBJECT_SERIALIZE_FIELD(json, "is_upgrade_separate", isUpgradeSeparate);
55 OBJECT_SERIALIZE_FIELD(json, "can_be_upgraded", canBeUpgraded);
59 OBJECT_SERIALIZE_FIELD(json, "unique_gift_number", uniqueGiftNumber);
60 return json;
61 }
62
64 void fromJson(const nl::json& json) {
65 OBJECT_DESERIALIZE_FIELD_PTR(json, "gift", gift, false);
66 OBJECT_DESERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId, "", true);
67 OBJECT_DESERIALIZE_FIELD(json, "convert_star_count", convertStarCount, 0, true);
68 OBJECT_DESERIALIZE_FIELD(json, "prepaid_upgrade_star_count", prepaidUpgradeStarCount, 0, true);
69 OBJECT_DESERIALIZE_FIELD(json, "is_upgrade_separate", isUpgradeSeparate, false, true);
70 OBJECT_DESERIALIZE_FIELD(json, "can_be_upgraded", canBeUpgraded, false, true);
71 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", true);
73 OBJECT_DESERIALIZE_FIELD(json, "is_private", isPrivate, false, true);
74 OBJECT_DESERIALIZE_FIELD(json, "unique_gift_number", uniqueGiftNumber, 0, true);
75 }
76 };
77}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:32
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:39
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:92
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:64
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:111
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Describes a service message about a regular gift that was sent or received. https://core....
Definition GiftInfo.hpp:9
Ptr< Gift > gift
Information about the gift.
Definition GiftInfo.hpp:16
std::string text
Optional. Text of the message that was added to the gift.
Definition GiftInfo.hpp:35
std::int64_t convertStarCount
Optional. Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitte...
Definition GiftInfo.hpp:23
std::int32_t uniqueGiftNumber
Optional. Unique number reserved for this gift when upgraded. See the number field in UniqueGift.
Definition GiftInfo.hpp:44
bool isUpgradeSeparate
Optional. True, if the gift's upgrade was purchased after the gift was sent.
Definition GiftInfo.hpp:29
std::vector< Ptr< MessageEntity > > entities
Optional. Special entities that appear in the text.
Definition GiftInfo.hpp:38
std::string ownedGiftId
Optional. Unique identifier of the received gift for the bot; only present for gifts received on beha...
Definition GiftInfo.hpp:19
GiftInfo()=default
nl::json toJson() const
Serializes this object to JSON.
Definition GiftInfo.hpp:48
bool isPrivate
Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise,...
Definition GiftInfo.hpp:41
bool canBeUpgraded
Optional. True, if the gift can be upgraded to a unique gift.
Definition GiftInfo.hpp:32
std::int64_t prepaidUpgradeStarCount
Optional. Number of Telegram Stars that were prepaid by the sender for the ability to upgrade the gif...
Definition GiftInfo.hpp:26
GiftInfo(const nl::json &json)
Definition GiftInfo.hpp:11
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition GiftInfo.hpp:64