tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ChecklistTask.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct ChecklistTask {
10 ChecklistTask() = default;
11 explicit ChecklistTask(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::int32_t id{};
17
19 std::string text;
20
22 std::vector<Ptr<MessageEntity>> textEntities;
23
26
28 std::time_t completionDate{};
29
30
33 nl::json toJson() const {
34 nl::json json = nl::json::object();
35 OBJECT_SERIALIZE_FIELD(json, "id", id);
36 OBJECT_SERIALIZE_FIELD(json, "text", text);
37 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities);
38 OBJECT_SERIALIZE_FIELD_PTR(json, "completed_by_user", completedByUser);
39 OBJECT_SERIALIZE_FIELD(json, "completion_date", completionDate);
40 return json;
41 }
42
44 void fromJson(const nl::json& json) {
45 OBJECT_DESERIALIZE_FIELD(json, "id", id, 0, false);
46 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
47 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities, true);
48 OBJECT_DESERIALIZE_FIELD_PTR(json, "completed_by_user", completedByUser, true);
49 OBJECT_DESERIALIZE_FIELD(json, "completion_date", completionDate, 0, true);
50 }
51 };
52}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Describes a task in a checklist. https://core.telegram.org/bots/api#checklisttask.
std::string text
Text of the task.
std::time_t completionDate
Optional. Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed.
ChecklistTask(const nl::json &json)
nl::json toJson() const
Serializes this object to JSON.
Ptr< User > completedByUser
Optional. User that completed the task; omitted if the task wasn't completed.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::vector< Ptr< MessageEntity > > textEntities
Optional. Special entities that appear in the task text.