tgbotxx  1.1.6.9
Telegram Bot C++ Library
Invoice.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct Invoice {
8  Invoice() = default;
9  explicit Invoice(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::string title;
15 
17  std::string description;
18 
20  std::string startParameter;
21 
24  std::string currency;
25 
30  std::int32_t totalAmount{};
31 
32 
35  nl::json toJson() const {
36  nl::json json = nl::json::object();
37  OBJECT_SERIALIZE_FIELD(json, "title", title);
38  OBJECT_SERIALIZE_FIELD(json, "description", description);
39  OBJECT_SERIALIZE_FIELD(json, "start_parameter", startParameter);
40  OBJECT_SERIALIZE_FIELD(json, "currency", currency);
41  OBJECT_SERIALIZE_FIELD(json, "total_amount", totalAmount);
42  return json;
43  }
44 
46  void fromJson(const nl::json& json) {
47  OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
48  OBJECT_DESERIALIZE_FIELD(json, "description", description, "", false);
49  OBJECT_DESERIALIZE_FIELD(json, "start_parameter", startParameter, "", false);
50  OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
51  OBJECT_DESERIALIZE_FIELD(json, "total_amount", totalAmount, 0, false);
52  }
53  };
54 }
#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
Definition: Api.hpp:14
This object contains basic information about an invoice. https://core.telegram.org/bots/api#invoice.
Definition: Invoice.hpp:7
std::string currency
Three-letter ISO 4217 currency code https://core.telegram.org/bots/payments#supported-currencies .
Definition: Invoice.hpp:24
std::string description
Product description.
Definition: Invoice.hpp:17
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: Invoice.hpp:46
std::string title
Product name.
Definition: Invoice.hpp:14
std::int32_t totalAmount
Total price in the smallest units of the currency (integer, not float/double). For example,...
Definition: Invoice.hpp:30
nl::json toJson() const
Serializes this object to JSON.
Definition: Invoice.hpp:35
std::string startParameter
Unique bot deep-linking parameter that can be used to generate this invoice.
Definition: Invoice.hpp:20
Invoice()=default
Invoice(const nl::json &json)
Definition: Invoice.hpp:9