tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
LabeledPrice.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct LabeledPrice {
8 LabeledPrice() = default;
9 explicit LabeledPrice(const nl::json& json) {
10 fromJson(json);
11 }
12
14 std::string label;
15
19 std::int32_t amount{};
20
21
24 nl::json toJson() const {
25 nl::json json = nl::json::object();
26 OBJECT_SERIALIZE_FIELD(json, "label", label);
27 OBJECT_SERIALIZE_FIELD(json, "amount", amount);
28 return json;
29 }
30
32 void fromJson(const nl::json& json) {
33 OBJECT_DESERIALIZE_FIELD(json, "label", label, "", false);
34 OBJECT_DESERIALIZE_FIELD(json, "amount", amount, 0, false);
35 }
36 };
37}
#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
This object represents a portion of the price for goods or services. https://core....
nl::json toJson() const
Serializes this object to JSON.
std::int32_t amount
Price of the product in the smallest units of the currency (integer, not float/double)....
LabeledPrice(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string label
Portion label.