tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Checklist.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct Checklist {
10 Checklist() = default;
11 explicit Checklist(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::string title;
17
19 std::vector<Ptr<MessageEntity>> titleEntities;
20
22 std::vector<Ptr<ChecklistTask>> tasks;
23
26
29
30
33 nl::json toJson() const {
34 nl::json json = nl::json::object();
35 OBJECT_SERIALIZE_FIELD(json, "title", title);
36 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "title_entities", titleEntities);
38 OBJECT_SERIALIZE_FIELD(json, "others_can_add_tasks", othersCanAddTasks);
39 OBJECT_SERIALIZE_FIELD(json, "others_can_mark_tasks_as_done", othersCanMarkTasksAsDone);
40 return json;
41 }
42
44 void fromJson(const nl::json& json) {
45 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
46 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "title_entities", titleEntities, true);
47 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "tasks", tasks, false);
48 OBJECT_DESERIALIZE_FIELD(json, "others_can_add_tasks", othersCanAddTasks, false, true);
49 OBJECT_DESERIALIZE_FIELD(json, "others_can_mark_tasks_as_done", othersCanMarkTasksAsDone, false, true);
50 }
51 };
52}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
Describes a checklist. https://core.telegram.org/bots/api#checklist.
Definition Checklist.hpp:9
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Checklist.hpp:44
bool othersCanMarkTasksAsDone
Optional. True, if users other than the creator of the list can mark tasks as done or not done.
Definition Checklist.hpp:28
Checklist(const nl::json &json)
Definition Checklist.hpp:11
std::string title
Title of the checklist.
Definition Checklist.hpp:16
bool othersCanAddTasks
Optional. True, if users other than the creator of the list can add tasks to the list.
Definition Checklist.hpp:25
std::vector< Ptr< MessageEntity > > titleEntities
Optional. Special entities that appear in the checklist title.
Definition Checklist.hpp:19
std::vector< Ptr< ChecklistTask > > tasks
List of tasks in the checklist.
Definition Checklist.hpp:22
nl::json toJson() const
Serializes this object to JSON.
Definition Checklist.hpp:33