tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ShippingOption.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 ShippingOption() = default;
10 explicit ShippingOption(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string id;
16
18 std::string title;
19
21 std::vector<Ptr<LabeledPrice>> prices;
22
25 nl::json toJson() const {
26 nl::json json = nl::json::object();
27 OBJECT_SERIALIZE_FIELD(json, "id", id);
28 OBJECT_SERIALIZE_FIELD(json, "title", title);
30 return json;
31 }
32
34 void fromJson(const nl::json& json) {
35 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
36 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
37 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "prices", prices, false);
38 }
39 };
40}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:87
This object represents one shipping option. https://core.telegram.org/bots/api#shippingoption.
std::string title
Option title.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::vector< Ptr< LabeledPrice > > prices
List of price portions.
std::string id
Shipping option identifier.
nl::json toJson() const
Serializes this object to JSON.
ShippingOption(const nl::json &json)