tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
WebhookInfo.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct WebhookInfo {
8 WebhookInfo() = default;
9 explicit WebhookInfo(const nl::json& json) {
10 fromJson(json);
11 }
12
14 std::string url;
15
18
20 std::int32_t pendingUpdateCount{};
21
23 std::string ipAddress;
24
26 std::time_t lastErrorDate{};
27
29 std::string lastErrorMessage;
30
33
35 std::int32_t maxConnections{};
36
38 std::vector<std::string> allowedUpdates;
39
40
43 nl::json toJson() const {
44 nl::json json = nl::json::object();
45 OBJECT_SERIALIZE_FIELD(json, "url", url);
46 OBJECT_SERIALIZE_FIELD(json, "has_custom_certificate", hasCustomCertificate);
47 OBJECT_SERIALIZE_FIELD(json, "pending_update_count", pendingUpdateCount);
48 OBJECT_SERIALIZE_FIELD(json, "ip_address", ipAddress);
49 OBJECT_SERIALIZE_FIELD(json, "last_error_date", lastErrorDate);
50 OBJECT_SERIALIZE_FIELD(json, "last_error_message", lastErrorMessage);
51 OBJECT_SERIALIZE_FIELD(json, "last_synchronization_error_date", lastSynchronizationErrorDate);
52 OBJECT_SERIALIZE_FIELD(json, "max_connections", maxConnections);
53 OBJECT_SERIALIZE_FIELD(json, "allowed_updates", allowedUpdates);
54 return json;
55 }
56
58 void fromJson(const nl::json& json) {
59 OBJECT_DESERIALIZE_FIELD(json, "url", url, "", false);
60 OBJECT_DESERIALIZE_FIELD(json, "has_custom_certificate", hasCustomCertificate, false, false);
61 OBJECT_DESERIALIZE_FIELD(json, "pending_update_count", pendingUpdateCount, 0, false);
62 OBJECT_DESERIALIZE_FIELD(json, "ip_address", ipAddress, "", true);
63 OBJECT_DESERIALIZE_FIELD(json, "last_error_date", lastErrorDate, 0, true);
64 OBJECT_DESERIALIZE_FIELD(json, "last_error_message", lastErrorMessage, "", true);
65 OBJECT_DESERIALIZE_FIELD(json, "last_synchronization_error_date", lastSynchronizationErrorDate, 0, true);
66 OBJECT_DESERIALIZE_FIELD(json, "max_connections", maxConnections, 0, true);
67 OBJECT_DESERIALIZE_FIELD(json, "allowed_updates", allowedUpdates, std::vector<std::string>(), true);
68 }
69 };
70}
#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
Describes the current status of a webhook. https://core.telegram.org/bots/api#webhookinfo.
std::string url
Webhook URL, may be empty if webhook is not set up.
WebhookInfo(const nl::json &json)
std::int32_t maxConnections
Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update deli...
std::int32_t pendingUpdateCount
Number of updates awaiting delivery.
std::time_t lastSynchronizationErrorDate
Optional. Unix time of the most recent error that happened when trying to synchronize available updat...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string ipAddress
Optional. Currently used webhook IP address.
bool hasCustomCertificate
True, if a custom certificate was provided for webhook certificate checks.
nl::json toJson() const
Serializes this object to JSON.
std::string lastErrorMessage
Optional. Error message in human-readable format for the most recent error that happened when trying ...
std::vector< std::string > allowedUpdates
Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_m...
std::time_t lastErrorDate
Optional. Unix time for the most recent error that happened when trying to deliver an update via webh...