tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
StarAmount.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct StarAmount {
8 StarAmount() = default;
9 explicit StarAmount(const nl::json& json) {
10 fromJson(json);
11 }
12
14 std::int64_t amount{};
15
18 std::int64_t nanostarAmount{};
19
22 nl::json toJson() const {
23 nl::json json = nl::json::object();
24 OBJECT_SERIALIZE_FIELD(json, "amount", amount);
25 OBJECT_SERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount);
26 return json;
27 }
29 void fromJson(const nl::json& json) {
30 OBJECT_DESERIALIZE_FIELD(json, "amount", amount, 0, false);
31 OBJECT_DESERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount, 0, true);
32 }
33 };
34
35}
#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
Describes an amount of Telegram Stars. https://core.telegram.org/bots/api#staramount.
Definition StarAmount.hpp:7
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int64_t amount
Integer amount of Telegram Stars, rounded to 0; can be negative.
nl::json toJson() const
Serializes this object to JSON.
std::int64_t nanostarAmount
Optional. The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be n...
StarAmount(const nl::json &json)
Definition StarAmount.hpp:9