tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
PassportElementError.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
19 explicit PassportElementError(const nl::json& json) {
20 _fromJson(json);
21 }
22 virtual ~PassportElementError() = default;
23
25 std::string source;
26
29 std::string type;
30
33 virtual nl::json toJson() const {
34 nl::json json = nl::json::object();
35 OBJECT_SERIALIZE_FIELD(json, "source", source);
36 OBJECT_SERIALIZE_FIELD(json, "type", type);
37 return json;
38 }
39
41 virtual void fromJson(const nl::json& json) {
42 OBJECT_DESERIALIZE_FIELD(json, "source", source, "", false);
43 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
44 }
45
46 private:
47 void _fromJson(const nl::json& json) {
48 fromJson(json);
49 }
50 };
51
59 explicit PassportElementErrorDataField(const nl::json& json) {
62 }
63
65 std::string fieldName;
66
68 std::string dataHash;
69
71 std::string message;
72
73 nl::json toJson() const override {
74 nl::json json = PassportElementError::toJson();
75 OBJECT_SERIALIZE_FIELD(json, "field_name", fieldName);
76 OBJECT_SERIALIZE_FIELD(json, "data_hash", dataHash);
77 OBJECT_SERIALIZE_FIELD(json, "message", message);
78 return json;
79 }
80 void fromJson(const nl::json& json) override {
82 OBJECT_DESERIALIZE_FIELD(json, "field_name", fieldName, "", false);
83 OBJECT_DESERIALIZE_FIELD(json, "data_hash", dataHash, "", false);
84 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
85 }
86 };
87
95 explicit PassportElementErrorFrontSide(const nl::json& json) {
97 PassportElementError::source = "front_side";
98 }
99
101 std::string fileHash;
102
104 std::string message;
105
106 nl::json toJson() const override {
107 nl::json json = PassportElementError::toJson();
108 OBJECT_SERIALIZE_FIELD(json, "file_hash", fileHash);
109 OBJECT_SERIALIZE_FIELD(json, "message", message);
110 return json;
111 }
112 void fromJson(const nl::json& json) override {
114 OBJECT_DESERIALIZE_FIELD(json, "file_hash", fileHash, "", false);
115 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
116 }
117 };
118
126 explicit PassportElementErrorReverseSide(const nl::json& json) {
128 PassportElementError::source = "reverse_side";
129 }
130
132 std::string fileHash;
133
135 std::string message;
136
137 nl::json toJson() const override {
138 nl::json json = PassportElementError::toJson();
139 OBJECT_SERIALIZE_FIELD(json, "file_hash", fileHash);
140 OBJECT_SERIALIZE_FIELD(json, "message", message);
141 return json;
142 }
143 void fromJson(const nl::json& json) override {
145 OBJECT_DESERIALIZE_FIELD(json, "file_hash", fileHash, "", false);
146 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
147 }
148 };
149
157 explicit PassportElementErrorSelfie(const nl::json& json) {
160 }
161
163 std::string fileHash;
164
166 std::string message;
167
168 nl::json toJson() const override {
169 nl::json json = PassportElementError::toJson();
170 OBJECT_SERIALIZE_FIELD(json, "file_hash", fileHash);
171 OBJECT_SERIALIZE_FIELD(json, "message", message);
172 return json;
173 }
174 void fromJson(const nl::json& json) override {
176 OBJECT_DESERIALIZE_FIELD(json, "file_hash", fileHash, "", false);
177 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
178 }
179 };
180
188 explicit PassportElementErrorFile(const nl::json& json) {
191 }
192
194 std::string fileHash;
195
197 std::string message;
198
199 nl::json toJson() const override {
200 nl::json json = PassportElementError::toJson();
201 OBJECT_SERIALIZE_FIELD(json, "file_hash", fileHash);
202 OBJECT_SERIALIZE_FIELD(json, "message", message);
203 return json;
204 }
205 void fromJson(const nl::json& json) override {
207 OBJECT_DESERIALIZE_FIELD(json, "file_hash", fileHash, "", false);
208 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
209 }
210 };
211
212
220 explicit PassportElementErrorFiles(const nl::json& json) {
223 }
224
226 std::vector<std::string> fileHashes;
227
229 std::string message;
230
231 nl::json toJson() const override {
232 nl::json json = PassportElementError::toJson();
233 OBJECT_SERIALIZE_FIELD(json, "file_hashes", fileHashes);
234 OBJECT_SERIALIZE_FIELD(json, "message", message);
235 return json;
236 }
237 void fromJson(const nl::json& json) override {
239 OBJECT_DESERIALIZE_FIELD(json, "file_hashes", fileHashes, {}, false);
240 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
241 }
242 };
243
251 explicit PassportElementErrorTranslationFile(const nl::json& json) {
253 PassportElementError::source = "translation_file";
254 }
255
257 std::string fileHash;
258
260 std::string message;
261
262 nl::json toJson() const override {
263 nl::json json = PassportElementError::toJson();
264 OBJECT_SERIALIZE_FIELD(json, "file_hash", fileHash);
265 OBJECT_SERIALIZE_FIELD(json, "message", message);
266 return json;
267 }
268 void fromJson(const nl::json& json) override {
270 OBJECT_DESERIALIZE_FIELD(json, "file_hash", fileHash, "", false);
271 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
272 }
273 };
274
282 explicit PassportElementErrorTranslationFiles(const nl::json& json) {
284 PassportElementError::source = "translation_files";
285 }
286
288 std::vector<std::string> fileHashes;
289
291 std::string message;
292
293 nl::json toJson() const override {
294 nl::json json = PassportElementError::toJson();
295 OBJECT_SERIALIZE_FIELD(json, "file_hashes", fileHashes);
296 OBJECT_SERIALIZE_FIELD(json, "message", message);
297 return json;
298 }
299 void fromJson(const nl::json& json) override {
301 OBJECT_DESERIALIZE_FIELD(json, "file_hashes", fileHashes, {}, false);
302 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
303 }
304 };
305
313 explicit PassportElementErrorUnspecified(const nl::json& json) {
315 PassportElementError::source = "unspecified";
316 }
317
319 std::string elementHash;
320
322 std::string message;
323
324 nl::json toJson() const override {
325 nl::json json = PassportElementError::toJson();
326 OBJECT_SERIALIZE_FIELD(json, "element_hash", elementHash);
327 OBJECT_SERIALIZE_FIELD(json, "message", message);
328 return json;
329 }
330 void fromJson(const nl::json& json) override {
332 OBJECT_DESERIALIZE_FIELD(json, "element_hash", elementHash, "", false);
333 OBJECT_DESERIALIZE_FIELD(json, "message", message, "", false);
334 }
335 };
336
337}
#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
Represents an issue in one of the data fields that was provided by the user. The error is considered ...
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
std::string fieldName
Name of the data field which has the error.
std::string dataHash
Base64-encoded data hash.
Represents an issue with a document scan. The error is considered resolved when the file with the doc...
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string fileHash
Base64-encoded file hash.
nl::json toJson() const override
Serializes this object to JSON.
Represents an issue with a list of scans. The error is considered resolved when the list of files con...
std::vector< std::string > fileHashes
List of base64-encoded file hashes.
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Represents an issue with the front side of a document. The error is considered resolved when the file...
std::string fileHash
Base64-encoded hash of the file with the front side of the document.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
This object represents an error in the Telegram Passport element which was submitted that should be r...
virtual nl::json toJson() const
Serializes this object to JSON.
std::string type
The section of the user's Telegram Passport which has the issue, one of “passport”,...
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
virtual ~PassportElementError()=default
PassportElementError(const nl::json &json)
Represents an issue with the reverse side of a document. The error is considered resolved when the fi...
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string fileHash
Base64-encoded hash of the file with the front side of the document.
Represents an issue with the selfie with a document. The error is considered resolved when the file w...
nl::json toJson() const override
Serializes this object to JSON.
std::string fileHash
Base64-encoded hash of the file with the selfie.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Represents an issue with one of the files that constitute the translation of a document....
std::string fileHash
Base64-encoded file hash.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
Represents an issue with the translated version of a document. The error is considered resolved when ...
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::vector< std::string > fileHashes
List of base64-encoded file hashes.
Represents an issue in an unspecified place. The error is considered resolved when new data is added....
nl::json toJson() const override
Serializes this object to JSON.
std::string elementHash
Base64-encoded element hash.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.