tgbotxx  1.1.6.9
Telegram Bot C++ Library
ShippingQuery.hpp
Go to the documentation of this file.
1 #pragma once
5 
6 
7 namespace tgbotxx {
10  struct ShippingQuery {
11  ShippingQuery() = default;
12  explicit ShippingQuery(const nl::json& json) {
13  fromJson(json);
14  }
15 
17  std::string id;
18 
21 
23  std::string invoicePayload;
24 
27 
30  nl::json toJson() const {
31  nl::json json = nl::json::object();
32  OBJECT_SERIALIZE_FIELD(json, "id", id);
33  OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
34  OBJECT_SERIALIZE_FIELD(json, "invoice_payload", invoicePayload);
35  OBJECT_SERIALIZE_FIELD_PTR(json, "shipping_address", shippingAddress);
36  return json;
37  }
38 
40  void fromJson(const nl::json& json) {
41  OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
42  OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
43  OBJECT_DESERIALIZE_FIELD(json, "invoice_payload", invoicePayload, "", false);
44  OBJECT_DESERIALIZE_FIELD_PTR(json, "shipping_address", shippingAddress, false);
45  }
46  };
47 }
#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
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
This object contains information about an incoming shipping query. https://core.telegram....
ShippingQuery(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string id
Unique query identifier.
Ptr< User > from
User who sent the query.
std::string invoicePayload
Bot specified invoice payload.
nl::json toJson() const
Serializes this object to JSON.
Ptr< ShippingAddress > shippingAddress
User specified shipping address.