tgbotxx 1.1.9.2
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) {
11 fromJson(json);
12 }
13
16
22 std::string origin;
23
25 std::int64_t lastResaleStarCount{};
26
29 std::string ownedGiftId;
30
33 std::int64_t transferStarCount{};
34
37 std::time_t nextTransferDate{};
38
41 nl::json toJson() const {
42 nl::json json = nl::json::object();
43 OBJECT_SERIALIZE_FIELD_PTR(json, "gift", gift);
44 OBJECT_SERIALIZE_FIELD(json, "origin", origin);
45 OBJECT_SERIALIZE_FIELD(json, "last_resale_star_count", lastResaleStarCount);
46 OBJECT_SERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId);
47 OBJECT_SERIALIZE_FIELD(json, "transfer_star_count", transferStarCount);
48 OBJECT_SERIALIZE_FIELD(json, "next_transfer_date", nextTransferDate);
49 return json;
50 }
51
53 void fromJson(const nl::json& json) {
54 OBJECT_DESERIALIZE_FIELD_PTR(json, "gift", gift, false);
55 OBJECT_DESERIALIZE_FIELD(json, "origin", origin, "", false);
56 OBJECT_DESERIALIZE_FIELD(json, "last_resale_star_count", lastResaleStarCount, 0, true);
57 OBJECT_DESERIALIZE_FIELD(json, "owned_gift_id", ownedGiftId, "", true);
58 OBJECT_DESERIALIZE_FIELD(json, "transfer_star_count", transferStarCount, 0, true);
59 OBJECT_DESERIALIZE_FIELD(json, "next_transfer_date", nextTransferDate, 0, true);
60 }
61 };
62}
#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
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 lastResaleStarCount
Optional. For gifts bought from other users, the price paid for the gift.
std::string origin
Origin of the gift. Currently, either “upgrade” for gifts upgraded from regular gifts,...
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::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.