tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
PreCheckoutQuery.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
10 PreCheckoutQuery() = default;
11 explicit PreCheckoutQuery(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::string id;
17
20
23 std::string currency;
24
28 std::int32_t totalAmount{};
29
31 std::string invoicePayload;
32
34 std::string shippingOptionId;
35
38
39
42 nl::json toJson() const {
43 nl::json json = nl::json::object();
44 OBJECT_SERIALIZE_FIELD(json, "id", id);
45 OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
46 OBJECT_SERIALIZE_FIELD(json, "currency", currency);
47 OBJECT_SERIALIZE_FIELD(json, "total_amount", totalAmount);
48 OBJECT_SERIALIZE_FIELD(json, "invoice_payload", invoicePayload);
49 OBJECT_SERIALIZE_FIELD(json, "shipping_option_id", shippingOptionId);
50 OBJECT_SERIALIZE_FIELD_PTR(json, "order_info", orderInfo);
51 return json;
52 }
53
55 void fromJson(const nl::json& json) {
56 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
57 OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
58 OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
59 OBJECT_DESERIALIZE_FIELD(json, "total_amount", totalAmount, 0, false);
60 OBJECT_DESERIALIZE_FIELD(json, "invoice_payload", invoicePayload, "", false);
61 OBJECT_DESERIALIZE_FIELD(json, "shipping_option_id", shippingOptionId, "", true);
62 OBJECT_DESERIALIZE_FIELD_PTR(json, "order_info", orderInfo, true);
63 }
64 };
65}
#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 an incoming pre-checkout query. https://core....
nl::json toJson() const
Serializes this object to JSON.
std::string currency
Three-letter ISO 4217 currency code.
PreCheckoutQuery(const nl::json &json)
Ptr< User > from
User who sent the query.
Ptr< OrderInfo > orderInfo
Optional. Order information provided by the user.
std::string shippingOptionId
Optional. Identifier of the shipping option chosen by the user.
std::int32_t totalAmount
Total price in the smallest units of the currency (integer, not float/double). For example,...
std::string invoicePayload
Bot specified invoice payload.
std::string id
Unique query identifier.
void fromJson(const nl::json &json)
Deserializes this object from JSON.