tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
LocationAddress.hpp
Go to the documentation of this file.
1#pragma once
3#include <string>
4
5namespace tgbotxx {
6
10 LocationAddress() = default;
11 explicit LocationAddress(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::string countryCode;
17
19 std::string state;
20
22 std::string city;
23
25 std::string street;
26
29 nl::json toJson() const {
30 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "country_code", countryCode);
32 OBJECT_SERIALIZE_FIELD(json, "state", state);
33 OBJECT_SERIALIZE_FIELD(json, "city", city);
34 OBJECT_SERIALIZE_FIELD(json, "street", street);
35 return json;
36 }
37
39 void fromJson(const nl::json& json) {
40 OBJECT_DESERIALIZE_FIELD(json, "country_code", countryCode, "", false);
41 OBJECT_DESERIALIZE_FIELD(json, "state", state, "", true);
42 OBJECT_DESERIALIZE_FIELD(json, "city", city, "", true);
43 OBJECT_DESERIALIZE_FIELD(json, "street", street, "", true);
44 }
45 };
46
47}
#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:46
Describes the physical address of a location. https://core.telegram.org/bots/api#locationaddress.
std::string state
Optional. State of the location.
LocationAddress(const nl::json &json)
std::string city
Optional. City of the location.
std::string countryCode
The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located.
std::string street
Optional. Street address of the location.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.