tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
UniqueGiftInfo.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 UniqueGiftInfo() = default;
10 explicit UniqueGiftInfo(const nl::json& json) {
12 }
13
16
23 std::string origin;
24
27 std::string lastResaleCurrency{};
28
30 std::int64_t lastResaleAmount{};
31
34 std::string ownedGiftId;
35
38 std::int64_t transferStarCount{};
39
42 std::time_t nextTransferDate{};
43
46 nl::json toJson() const {
47 nl::json json = nl::json::object();
50 OBJECT_SERIALIZE_FIELD(json, "last_resale_currency", lastResaleCurrency);
51 OBJECT_SERIALIZE_FIELD(json, "last_resale_amount", lastResaleAmount);
52 OBJECT_SERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId);
53 OBJECT_SERIALIZE_FIELD(json, "transfer_star_count", transferStarCount);
54 OBJECT_SERIALIZE_FIELD(json, "next_transfer_date", nextTransferDate);
55 return json;
56 }
57
59 void fromJson(const nl::json& json) {
60 OBJECT_DESERIALIZE_FIELD_PTR(json, "gift", gift, false);
61 OBJECT_DESERIALIZE_FIELD(json, "origin", origin, "", false);
62 OBJECT_DESERIALIZE_FIELD(json, "last_resale_currency", lastResaleCurrency, "", true);
63 OBJECT_DESERIALIZE_FIELD(json, "last_resale_amount", lastResaleAmount, 0, true);
64 OBJECT_DESERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId, "", true);
65 OBJECT_DESERIALIZE_FIELD(json, "transfer_star_count", transferStarCount, 0, true);
66 OBJECT_DESERIALIZE_FIELD(json, "next_transfer_date", nextTransferDate, 0, true);
67 }
68 };
69}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:32
#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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Describes a service message about a unique gift that was sent or received. https://core....
std::string ownedGiftId
Optional. Unique identifier of the received gift for the bot; only present for gifts received on beha...
std::int64_t lastResaleAmount
Optional. For gifts bought from other users, the price paid for the gift in either Telegram Stars or ...
Ptr< UniqueGift > gift
Information about the gift.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int64_t transferStarCount
Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot ...
std::string lastResaleCurrency
Optional. For gifts bought from other users, the currency in which the payment for the gift was done....
std::time_t nextTransferDate
Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in the past,...
UniqueGiftInfo(const nl::json &json)
nl::json toJson() const
Serializes this object to JSON.