tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
OwnedGifts.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
6
9 struct OwnedGifts {
10 OwnedGifts() = default;
11 explicit OwnedGifts(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::int32_t totalCount{};
17
19 std::vector<Ptr<OwnedGift>> gifts;
20
22 std::string nextOffset;
23
26 nl::json toJson() const {
27 nl::json json = nl::json::object();
28 OBJECT_SERIALIZE_FIELD(json, "total_count", totalCount);
30 OBJECT_SERIALIZE_FIELD(json, "next_offset", nextOffset);
31 return json;
32 }
33
35 void fromJson(const nl::json& json) {
36 OBJECT_DESERIALIZE_FIELD(json, "total_count", totalCount, 0, false);
37 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "gifts", gifts, false);
38 OBJECT_DESERIALIZE_FIELD(json, "next_offset", nextOffset, "", true);
39 }
40 };
41
42}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
Contains the list of gifts received and owned by a user or a chat. https://core.telegram....
Definition OwnedGifts.hpp:9
std::string nextOffset
Optional. Offset for the next request. If empty, then there are no more results.
OwnedGifts(const nl::json &json)
nl::json toJson() const
Serializes this object to JSON.
std::vector< Ptr< OwnedGift > > gifts
The list of gifts.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int32_t totalCount
The total number of gifts owned by the user or the chat.