tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
SuggestedPostPaid.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
10 SuggestedPostPaid() = default;
11 explicit SuggestedPostPaid(const nl::json& json) {
12 fromJson(json);
13 }
14
17
19 std::string currency;
20
22 std::int64_t amount{};
23
26
27
30 nl::json toJson() const {
31 nl::json json = nl::json::object();
32 OBJECT_SERIALIZE_FIELD_PTR(json, "suggested_post_message", suggestedPostMessage);
33 OBJECT_SERIALIZE_FIELD(json, "currency", currency);
34 OBJECT_SERIALIZE_FIELD(json, "amount", amount);
35 OBJECT_SERIALIZE_FIELD_PTR(json, "star_amount", starAmount);
36 return json;
37 }
39 void fromJson(const nl::json& json) {
40 OBJECT_DESERIALIZE_FIELD_PTR(json, "suggested_post_message", suggestedPostMessage, true);
41 OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
42 OBJECT_DESERIALIZE_FIELD(json, "amount", amount, 0, true);
43 OBJECT_DESERIALIZE_FIELD_PTR(json, "star_amount", starAmount, true);
44 }
45 };
46
47}
#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 successful payment for a suggested post. https://core....
std::int64_t amount
Optional. The amount of the currency that was received (nanotoncoins for TON)
SuggestedPostPaid(const nl::json &json)
Ptr< Message > suggestedPostMessage
Optional. Message containing the suggested post.
std::string currency
Currency in which the payment was made ("XTR" for Stars or "TON" for toncoins)
SuggestedPostPaid()=default
Ptr< StarAmount > starAmount
Optional. The amount of Telegram Stars that was received.
nl::json toJson() const
Serializes this object to JSON.
void fromJson(const nl::json &json)
Deserializes this object from JSON.