tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ShippingAddress.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <nlohmann/json.hpp>
6
7namespace nl = nlohmann;
8
9namespace tgbotxx {
13 ShippingAddress() = default;
14 explicit ShippingAddress(const nl::json& json) {
15 fromJson(json);
16 }
17
19 std::string countryCode;
20
22 std::string state;
23
25 std::string city;
26
28 std::string streetLine1;
29
31 std::string streetLine2;
32
34 std::string postCode;
35
38 nl::json toJson() const {
39 nl::json json = nl::json::object();
40 OBJECT_SERIALIZE_FIELD(json, "country_code", countryCode);
41 OBJECT_SERIALIZE_FIELD(json, "state", state);
42 OBJECT_SERIALIZE_FIELD(json, "city", city);
43 OBJECT_SERIALIZE_FIELD(json, "street_line1", streetLine1);
44 OBJECT_SERIALIZE_FIELD(json, "street_line2", streetLine2);
45 OBJECT_SERIALIZE_FIELD(json, "post_code", postCode);
46 return json;
47 }
48
50 void fromJson(const nl::json& json) {
51 OBJECT_DESERIALIZE_FIELD(json, "country_code", countryCode, "", false);
52 OBJECT_DESERIALIZE_FIELD(json, "state", state, "", false);
53 OBJECT_DESERIALIZE_FIELD(json, "city", city, "", false);
54 OBJECT_DESERIALIZE_FIELD(json, "street_line1", streetLine1, "", false);
55 OBJECT_DESERIALIZE_FIELD(json, "street_line2", streetLine2, "", false);
56 OBJECT_DESERIALIZE_FIELD(json, "post_code", postCode, "", false);
57 }
58 };
59}
#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 shipping address. https://core.telegram.org/bots/api#shippingaddress.
std::string postCode
Address post code.
std::string streetLine1
First line for the address.
nl::json toJson() const
Serializes this object to JSON.
ShippingAddress(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string streetLine2
Second line for the address.
std::string countryCode
Two-letter ISO 3166-1 alpha-2 country code.
std::string state
State, if applicable.