tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
WriteAccessAllowed.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
9 WriteAccessAllowed() = default;
10 explicit WriteAccessAllowed(const nl::json& json) {
11 fromJson(json);
12 }
13
16
18 std::string webAppName;
19
22
25 nl::json toJson() const {
26 nl::json json = nl::json::object();
27 OBJECT_SERIALIZE_FIELD(json, "from_request", fromRequest);
28 OBJECT_SERIALIZE_FIELD(json, "web_app_name", webAppName);
29 OBJECT_SERIALIZE_FIELD(json, "from_attachment_menu", fromAttachmentMenu);
30 return json;
31 }
32
34 void fromJson(const nl::json& json) {
35 OBJECT_DESERIALIZE_FIELD(json, "from_request", fromRequest, false, true);
36 OBJECT_DESERIALIZE_FIELD(json, "web_app_name", webAppName, "", true);
37 OBJECT_DESERIALIZE_FIELD(json, "from_attachment_menu", fromAttachmentMenu, false, true);
38 }
39 };
40}
#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 service message about a user allowing a bot to write messages after adding i...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
WriteAccessAllowed(const nl::json &json)
bool fromRequest
Optional. True, if the access was granted after the user accepted an explicit request from a Web App ...
bool fromAttachmentMenu
Optional. True, if the access was granted when the bot was added to the attachment or side menu.
std::string webAppName
Optional. Name of the Web App, if the access was granted when the Web App was launched from a link.
nl::json toJson() const
Serializes this object to JSON.