tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ChatBoost.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
8 struct ChatBoost {
9 ChatBoost() = default;
10 explicit ChatBoost(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string boostId;
16
18 std::time_t addDate{};
19
21 std::time_t expirationDate{};
22
25
26
29 nl::json toJson() const {
30 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "boost_id", boostId);
32 OBJECT_SERIALIZE_FIELD(json, "add_date", addDate);
33 OBJECT_SERIALIZE_FIELD(json, "expiration_date", expirationDate);
34 OBJECT_SERIALIZE_FIELD_PTR(json, "source", source);
35 return json;
36 }
37
39 void fromJson(const nl::json& json) {
40 OBJECT_DESERIALIZE_FIELD(json, "boost_id", boostId, "", false);
41 OBJECT_DESERIALIZE_FIELD(json, "add_date", addDate, 0, false);
42 OBJECT_DESERIALIZE_FIELD(json, "expiration_date", expirationDate, 0, false);
43 OBJECT_DESERIALIZE_FIELD_PTR(json, "source", source, false);
44 }
45 };
46}
#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:70
#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:44
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object contains information about a chat boost. https://core.telegram.org/bots/api#chatboost.
Definition ChatBoost.hpp:8
std::string boostId
Unique identifier of the boost.
Definition ChatBoost.hpp:15
std::time_t expirationDate
Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegra...
Definition ChatBoost.hpp:21
Ptr< ChatBoostSource > source
Source of the added boost.
Definition ChatBoost.hpp:24
nl::json toJson() const
Serializes this object to JSON.
Definition ChatBoost.hpp:29
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition ChatBoost.hpp:39
std::time_t addDate
Point in time (Unix timestamp) when the chat was boosted.
Definition ChatBoost.hpp:18
ChatBoost(const nl::json &json)
Definition ChatBoost.hpp:10