tgbotxx  1.1.6.9
Telegram Bot C++ Library
EncryptedCredentials.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
9  EncryptedCredentials() = default;
10  explicit EncryptedCredentials(const nl::json& json) {
11  fromJson(json);
12  }
13 
16  std::string data;
17 
19  std::string hash;
20 
22  std::string secret;
23 
24 
27  nl::json toJson() const {
28  nl::json json = nl::json::object();
29  OBJECT_SERIALIZE_FIELD(json, "data", data);
30  OBJECT_SERIALIZE_FIELD(json, "hash", hash);
31  OBJECT_SERIALIZE_FIELD(json, "secret", secret);
32  return json;
33  }
34 
36  void fromJson(const nl::json& json) {
37  OBJECT_DESERIALIZE_FIELD(json, "data", data, "", false);
38  OBJECT_DESERIALIZE_FIELD(json, "hash", hash, "", false);
39  OBJECT_DESERIALIZE_FIELD(json, "secret", secret, "", false);
40  }
41  };
42 }
#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
Definition: Api.hpp:14
Describes data required for decrypting and authenticating EncryptedPassportElement....
nl::json toJson() const
Serializes this object to JSON.
std::string data
Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets req...
EncryptedCredentials(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string secret
Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption.
std::string hash
Base64-encoded data hash for data authentication.