tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Birthdate.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct Birthdate {
8 Birthdate() = default;
9 explicit Birthdate(const nl::json& json) {
10 fromJson(json);
11 }
12
14 std::int32_t day{};
15
17 std::int32_t month{};
18
20 std::int32_t year{};
21
24 nl::json toJson() const {
25 nl::json json = nl::json::object();
26 OBJECT_SERIALIZE_FIELD(json, "day", day);
27 OBJECT_SERIALIZE_FIELD(json, "month", month);
28 OBJECT_SERIALIZE_FIELD(json, "year", year);
29 return json;
30 }
31
33 void fromJson(const nl::json& json) {
34 OBJECT_DESERIALIZE_FIELD(json, "day", day, 0, false);
35 OBJECT_DESERIALIZE_FIELD(json, "month", month, 0, false);
36 OBJECT_DESERIALIZE_FIELD(json, "year", year, 0, true);
37 }
38 };
39}
#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 birthdate of a user. https://core.telegram.org/bots/api#birthdate.
Definition Birthdate.hpp:7
Birthdate(const nl::json &json)
Definition Birthdate.hpp:9
std::int32_t month
Month of the user's birth; 1-12.
Definition Birthdate.hpp:17
std::int32_t year
Optional. Year of the user's birth.
Definition Birthdate.hpp:20
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Birthdate.hpp:33
std::int32_t day
Day of the user's birth; 1-31.
Definition Birthdate.hpp:14
nl::json toJson() const
Serializes this object to JSON.
Definition Birthdate.hpp:24