summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--include/tgbot/Api.h36
-rw-r--r--include/tgbot/TgTypeParser.h54
-rw-r--r--include/tgbot/types/EncryptedCredentials.h37
-rw-r--r--include/tgbot/types/EncryptedPassportElement.h84
-rw-r--r--include/tgbot/types/Message.h3
-rw-r--r--include/tgbot/types/PassportData.h32
-rw-r--r--include/tgbot/types/PassportElementError.h42
-rw-r--r--include/tgbot/types/PassportElementErrorDataField.h39
-rw-r--r--include/tgbot/types/PassportElementErrorFile.h34
-rw-r--r--include/tgbot/types/PassportElementErrorFiles.h35
-rw-r--r--include/tgbot/types/PassportElementErrorFrontSide.h34
-rw-r--r--include/tgbot/types/PassportElementErrorReverseSide.h34
-rw-r--r--include/tgbot/types/PassportElementErrorSelfie.h34
-rw-r--r--include/tgbot/types/PassportElementErrorTranslationFile.h34
-rw-r--r--include/tgbot/types/PassportElementErrorTranslationFiles.h35
-rw-r--r--include/tgbot/types/PassportElementErrorUnspecified.h34
-rw-r--r--include/tgbot/types/PassportFile.h43
-rw-r--r--src/Api.cpp29
-rw-r--r--src/TgTypeParser.cpp359
-rw-r--r--src/types/PassportElementError.cpp23
21 files changed, 1013 insertions, 44 deletions
diff --git a/README.md b/README.md
index 0aa45e9..a7d6734 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
- [x] Bot API 3.0 ~ 3.6
-- [x] Bot API 4.0 ~ 4.9 (Implemented all APIs except 'Telegram Passport')
+- [x] Bot API 4.0 ~ 4.9
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 6a95139..bb9aa26 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -353,13 +353,6 @@ public:
bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
- * @brief Deprecated. Use @ref Api::sendPoll
- * @deprecated since Bot API 4.6. This remains unchanged for backward compatibility.
- */
- Message::Ptr sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options,
- bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
-
- /**
* @brief Use this method to send a dice, which will have a random value from 1 to 6.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -731,13 +724,6 @@ public:
bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
/**
- * @brief Deprecated. Use @ref Api::createNewStickerSet
- * @deprecated since Bot API 4.7. This remains unchanged for backward compatibility.
- */
- bool createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title,
- boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
-
- /**
* @brief Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers.
*
* @param userId User identifier of sticker set owner
@@ -753,13 +739,6 @@ public:
boost::variant<InputFile::Ptr, std::string> pngSticker = "", boost::variant<InputFile::Ptr, std::string> tgsSticker = "", MaskPosition::Ptr maskPosition = nullptr) const;
/**
- * @brief Deprecated. Use @ref Api::addStickerToSet
- * @deprecated since Bot API 4.7. This remains unchanged for backward compatibility.
- */
- bool addStickerToSet(std::int64_t userId, const std::string& name, boost::variant<InputFile::Ptr, std::string> pngSticker,
- const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
-
- /**
* @brief Use this method to move a sticker in a set created by the bot to a specific position.
* @param stickers File identifier of the sticker.
* @param position New sticker position in the set, zero-based.
@@ -862,6 +841,21 @@ public:
bool answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok, const std::string& errorMessage = "") const;
/**
+ * @brief Informs a user that some of the Telegram Passport elements they provided contains errors.
+ *
+ * The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change).
+ * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason.
+ * For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc.
+ * Supply some details in the error message to make sure the user knows how to correct the issues.
+ *
+ * @param userId User identifier
+ * @param errors A JSON-serialized array describing the errors
+ *
+ * @return True on success.
+ */
+ bool setPassportDataErrors(std::int64_t userId, const std::vector<PassportElementError::Ptr>& errors) const;
+
+ /**
* @brief Use this method to send a game.
* @param chatId Unique identifier for the target chat.
* @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index a5f1511..15a29d6 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -84,6 +84,18 @@
#include "tgbot/types/InputMediaAudio.h"
#include "tgbot/types/InputMediaDocument.h"
#include "tgbot/types/InputMediaAnimation.h"
+#include "tgbot/types/PassportData.h"
+#include "tgbot/types/PassportFile.h"
+#include "tgbot/types/PassportElementError.h"
+#include "tgbot/types/PassportElementErrorDataField.h"
+#include "tgbot/types/PassportElementErrorFrontSide.h"
+#include "tgbot/types/PassportElementErrorReverseSide.h"
+#include "tgbot/types/PassportElementErrorSelfie.h"
+#include "tgbot/types/PassportElementErrorFile.h"
+#include "tgbot/types/PassportElementErrorFiles.h"
+#include "tgbot/types/PassportElementErrorTranslationFile.h"
+#include "tgbot/types/PassportElementErrorTranslationFiles.h"
+#include "tgbot/types/PassportElementErrorUnspecified.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
@@ -339,6 +351,48 @@ public:
SuccessfulPayment::Ptr parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const;
std::string parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const;
+ PassportData::Ptr parseJsonAndGetPassportData(const boost::property_tree::ptree& data) const;
+ std::string parsePassportData(const PassportData::Ptr& object) const;
+
+ PassportFile::Ptr parseJsonAndGetPassportFile(const boost::property_tree::ptree& data) const;
+ std::string parsePassportFile(const PassportFile::Ptr& object) const;
+
+ EncryptedPassportElement::Ptr parseJsonAndGetEncryptedPassportElement(const boost::property_tree::ptree& data) const;
+ std::string parseEncryptedPassportElement(const EncryptedPassportElement::Ptr& object) const;
+
+ EncryptedCredentials::Ptr parseJsonAndGetEncryptedCredentials(const boost::property_tree::ptree& data) const;
+ std::string parseEncryptedCredentials(const EncryptedCredentials::Ptr& object) const;
+
+ PassportElementError::Ptr parseJsonAndGetPassportElementError(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementError(const PassportElementError::Ptr& object) const;
+
+ PassportElementErrorDataField::Ptr parseJsonAndGetPassportElementErrorDataField(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorDataField(const PassportElementErrorDataField::Ptr& object) const;
+
+ PassportElementErrorFrontSide::Ptr parseJsonAndGetPassportElementErrorFrontSide(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorFrontSide(const PassportElementErrorFrontSide::Ptr& object) const;
+
+ PassportElementErrorReverseSide::Ptr parseJsonAndGetPassportElementErrorReverseSide(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorReverseSide(const PassportElementErrorReverseSide::Ptr& object) const;
+
+ PassportElementErrorSelfie::Ptr parseJsonAndGetPassportElementErrorSelfie(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorSelfie(const PassportElementErrorSelfie::Ptr& object) const;
+
+ PassportElementErrorFile::Ptr parseJsonAndGetPassportElementErrorFile(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorFile(const PassportElementErrorFile::Ptr& object) const;
+
+ PassportElementErrorFiles::Ptr parseJsonAndGetPassportElementErrorFiles(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorFiles(const PassportElementErrorFiles::Ptr& object) const;
+
+ PassportElementErrorTranslationFile::Ptr parseJsonAndGetPassportElementErrorTranslationFile(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorTranslationFile(const PassportElementErrorTranslationFile::Ptr& object) const;
+
+ PassportElementErrorTranslationFiles::Ptr parseJsonAndGetPassportElementErrorTranslationFiles(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorTranslationFiles(const PassportElementErrorTranslationFiles::Ptr& object) const;
+
+ PassportElementErrorUnspecified::Ptr parseJsonAndGetPassportElementErrorUnspecified(const boost::property_tree::ptree& data) const;
+ std::string parsePassportElementErrorUnspecified(const PassportElementErrorUnspecified::Ptr& object) const;
+
inline boost::property_tree::ptree parseJson(const std::string& json) const {
boost::property_tree::ptree tree;
std::istringstream input(json);
diff --git a/include/tgbot/types/EncryptedCredentials.h b/include/tgbot/types/EncryptedCredentials.h
new file mode 100644
index 0000000..f6f3231
--- /dev/null
+++ b/include/tgbot/types/EncryptedCredentials.h
@@ -0,0 +1,37 @@
+#ifndef TGBOT_CPP_ENCRYPTEDCREDENTIALS_H
+#define TGBOT_CPP_ENCRYPTEDCREDENTIALS_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Contains data required for decrypting and authenticating EncryptedPassportElement.
+ * See https://core.telegram.org/passport#receiving-information for a complete description of the data decryption and authentication
+ *
+ * @ingroup types
+ */
+class EncryptedCredentials {
+
+public:
+ typedef std::shared_ptr<EncryptedCredentials> Ptr;
+
+ /**
+ * @brief Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for @ref EncryptedPassportElement decryption and authentication
+ */
+ std::string data;
+
+ /**
+ * @brief Base64-encoded data hash for data authentication
+ */
+ std::string hash;
+
+ /**
+ * @brief Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
+ */
+ std::string secret;
+};
+}
+
+#endif //TGBOT_CPP_ENCRYPTEDCREDENTIALS_H
diff --git a/include/tgbot/types/EncryptedPassportElement.h b/include/tgbot/types/EncryptedPassportElement.h
new file mode 100644
index 0000000..3557f27
--- /dev/null
+++ b/include/tgbot/types/EncryptedPassportElement.h
@@ -0,0 +1,84 @@
+#ifndef TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H
+#define TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H
+
+#include "tgbot/types/PassportFile.h"
+
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief Contains information about documents or other Telegram Passport elements shared with the bot by the user.
+ *
+ * @ingroup types
+ */
+class EncryptedPassportElement {
+
+public:
+ typedef std::shared_ptr<EncryptedPassportElement> Ptr;
+
+ /**
+ * @brief Element type.
+ * One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”.
+ */
+ std::string type;
+
+ /**
+ * @brief Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types.
+ * Can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ std::string data;
+
+ /**
+ * @brief Optional. User's verified phone number, available only for “phone_number” type
+ */
+ std::string phoneNumber;
+
+ /**
+ * @brief Optional. User's verified email address, available only for “email” type
+ */
+ std::string email;
+
+ /**
+ * @brief Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types.
+ * Files can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ std::vector<PassportFile::Ptr> files;
+
+ /**
+ * @brief Optional. Encrypted file with the front side of the document, provided by the user.
+ * Available for “passport”, “driver_license”, “identity_card” and “internal_passport”.
+ * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ PassportFile::Ptr frontSide;
+
+ /**
+ * @brief Optional. Encrypted file with the reverse side of the document, provided by the user.
+ * Available for “driver_license” and “identity_card”.
+ * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ PassportFile::Ptr reverseSide;
+
+ /**
+ * @brief Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”.
+ * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ PassportFile::Ptr selfie;
+
+ /**
+ * @brief Optional. Array of encrypted files with translated versions of documents provided by the user.
+ * Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types.
+ * Files can be decrypted and verified using the accompanying @ref EncryptedCredentials.
+ */
+ std::vector<PassportFile::Ptr> translation;
+
+ /**
+ * @brief Base64-encoded element hash for using in @ref PassportElementErrorUnspecified
+ */
+ std::string hash;
+};
+}
+
+#endif //TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index 753e393..f8f1b13 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -21,6 +21,7 @@
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Invoice.h"
#include "tgbot/types/SuccessfulPayment.h"
+#include "tgbot/types/PassportData.h"
#include "tgbot/types/InlineKeyboardMarkup.h"
#include <cstdint>
@@ -286,7 +287,7 @@ public:
/**
* @brief Optional. Telegram Passport data
*/
- // TODO PassportData::Ptr passportData;
+ PassportData::Ptr passportData;
/**
* @brief Optional. Inline keyboard attached to the message.
diff --git a/include/tgbot/types/PassportData.h b/include/tgbot/types/PassportData.h
new file mode 100644
index 0000000..16076fc
--- /dev/null
+++ b/include/tgbot/types/PassportData.h
@@ -0,0 +1,32 @@
+#ifndef TGBOT_CPP_PASSPORTDATA_H
+#define TGBOT_CPP_PASSPORTDATA_H
+
+#include "tgbot/types/EncryptedPassportElement.h"
+#include "tgbot/types/EncryptedCredentials.h"
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Contains information about Telegram Passport data shared with the bot by the user.
+ *
+ * @ingroup types
+ */
+class PassportData {
+
+public:
+ typedef std::shared_ptr<PassportData> Ptr;
+
+ /**
+ * @brief Array with information about documents and other Telegram Passport elements that was shared with the bot
+ */
+ std::vector<EncryptedPassportElement::Ptr> data;
+
+ /**
+ * @brief Encrypted credentials required to decrypt the data
+ */
+ EncryptedCredentials::Ptr credentials;
+};
+}
+
+#endif //TGBOT_CPP_PASSPORTDATA_H
diff --git a/include/tgbot/types/PassportElementError.h b/include/tgbot/types/PassportElementError.h
new file mode 100644
index 0000000..cbb976d
--- /dev/null
+++ b/include/tgbot/types/PassportElementError.h
@@ -0,0 +1,42 @@
+#ifndef TGBOT_PASSPORTELEMENTERROR_H
+#define TGBOT_PASSPORTELEMENTERROR_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This abstract class is base of all passport element errors.
+ *
+ * This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user.
+ *
+ * @ingroup types
+ */
+class PassportElementError {
+public:
+ typedef std::shared_ptr<PassportElementError> Ptr;
+
+ PassportElementError() { }
+
+ virtual ~PassportElementError() { }
+
+ /**
+ * @brief Error source
+ */
+ std::string source;
+
+ /**
+ * @brief See description of derived classes.
+ * Type of element of the user's Telegram Passport which has the issue
+ */
+ std::string type;
+
+ /**
+ * @brief Error message
+ */
+ std::string message;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERROR_H
diff --git a/include/tgbot/types/PassportElementErrorDataField.h b/include/tgbot/types/PassportElementErrorDataField.h
new file mode 100644
index 0000000..70f3d34
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorDataField.h
@@ -0,0 +1,39 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORDATAFILED_H
+#define TGBOT_PASSPORTELEMENTERRORDATAFILED_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue in one of the data fields that was provided by the user.
+ * The error is considered resolved when the field's value changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorDataField : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorDataField> Ptr;
+
+ PassportElementErrorDataField() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Name of the data field which has the error
+ */
+ std::string fieldName;
+
+ /**
+ * @brief Base64-encoded data hash
+ */
+ std::string dataHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORDATAFILED_H
diff --git a/include/tgbot/types/PassportElementErrorFile.h b/include/tgbot/types/PassportElementErrorFile.h
new file mode 100644
index 0000000..07c5174
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorFile.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORFILE_H
+#define TGBOT_PASSPORTELEMENTERRORFILE_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with a document scan.
+ * The error is considered resolved when the file with the document scan changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorFile : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorFile> Ptr;
+
+ PassportElementErrorFile() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded file hash
+ */
+ std::string fileHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORFILE_H
diff --git a/include/tgbot/types/PassportElementErrorFiles.h b/include/tgbot/types/PassportElementErrorFiles.h
new file mode 100644
index 0000000..307c197
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorFiles.h
@@ -0,0 +1,35 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORFILES_H
+#define TGBOT_PASSPORTELEMENTERRORFILES_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with a list of scans.
+ * The error is considered resolved when the list of files containing the scans changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorFiles : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorFiles> Ptr;
+
+ PassportElementErrorFiles() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief List of base64-encoded file hashes
+ */
+ std::vector<std::string> fileHashes;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORFILES_H
diff --git a/include/tgbot/types/PassportElementErrorFrontSide.h b/include/tgbot/types/PassportElementErrorFrontSide.h
new file mode 100644
index 0000000..5bac683
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorFrontSide.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORFRONTSIDE_H
+#define TGBOT_PASSPORTELEMENTERRORFRONTSIDE_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with the front side of a document.
+ * The error is considered resolved when the file with the front side of the document changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorFrontSide : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorFrontSide> Ptr;
+
+ PassportElementErrorFrontSide() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded hash of the file with the front side of the document
+ */
+ std::string fileHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORFRONTSIDE_H
diff --git a/include/tgbot/types/PassportElementErrorReverseSide.h b/include/tgbot/types/PassportElementErrorReverseSide.h
new file mode 100644
index 0000000..a2ca677
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorReverseSide.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORREVERSESIDE_H
+#define TGBOT_PASSPORTELEMENTERRORREVERSESIDE_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with the reverse side of a document.
+ * The error is considered resolved when the file with reverse side of the document changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorReverseSide : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorReverseSide> Ptr;
+
+ PassportElementErrorReverseSide() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded hash of the file with the reverse side of the document
+ */
+ std::string fileHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORREVERSESIDE_H
diff --git a/include/tgbot/types/PassportElementErrorSelfie.h b/include/tgbot/types/PassportElementErrorSelfie.h
new file mode 100644
index 0000000..95dd77a
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorSelfie.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORSELFIE_H
+#define TGBOT_PASSPORTELEMENTERRORSELFIE_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with the selfie with a document.
+ * The error is considered resolved when the file with the selfie changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorSelfie : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorSelfie> Ptr;
+
+ PassportElementErrorSelfie() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded hash of the file with the selfie
+ */
+ std::string fileHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORSELFIE_H
diff --git a/include/tgbot/types/PassportElementErrorTranslationFile.h b/include/tgbot/types/PassportElementErrorTranslationFile.h
new file mode 100644
index 0000000..616b3e4
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorTranslationFile.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILE_H
+#define TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILE_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with one of the files that constitute the translation of a document.
+ * The error is considered resolved when the file changes.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorTranslationFile : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorTranslationFile> Ptr;
+
+ PassportElementErrorTranslationFile() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded file hash
+ */
+ std::string fileHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILE_H
diff --git a/include/tgbot/types/PassportElementErrorTranslationFiles.h b/include/tgbot/types/PassportElementErrorTranslationFiles.h
new file mode 100644
index 0000000..b26c6b7
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorTranslationFiles.h
@@ -0,0 +1,35 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILES_H
+#define TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILES_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue with the translated version of a document.
+ * The error is considered resolved when a file with the document translation change.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorTranslationFiles : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorTranslationFiles> Ptr;
+
+ PassportElementErrorTranslationFiles() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief List of base64-encoded file hashes
+ */
+ std::vector<std::string> fileHashes;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORTRANSLATIONFILES_H
diff --git a/include/tgbot/types/PassportElementErrorUnspecified.h b/include/tgbot/types/PassportElementErrorUnspecified.h
new file mode 100644
index 0000000..062f216
--- /dev/null
+++ b/include/tgbot/types/PassportElementErrorUnspecified.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_PASSPORTELEMENTERRORUNSPECIFIED_H
+#define TGBOT_PASSPORTELEMENTERRORUNSPECIFIED_H
+
+#include "tgbot/types/PassportElementError.h"
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an issue in an unspecified place.
+ * The error is considered resolved when new data is added.
+ *
+ * @ingroup types
+ */
+class PassportElementErrorUnspecified : public PassportElementError {
+public:
+ static const std::string SOURCE;
+
+ typedef std::shared_ptr<PassportElementErrorUnspecified> Ptr;
+
+ PassportElementErrorUnspecified() {
+ this->source = SOURCE;
+ }
+
+ /**
+ * @brief Base64-encoded element hash
+ */
+ std::string elementHash;
+};
+}
+
+#endif //TGBOT_PASSPORTELEMENTERRORUNSPECIFIED_H
diff --git a/include/tgbot/types/PassportFile.h b/include/tgbot/types/PassportFile.h
new file mode 100644
index 0000000..f85493a
--- /dev/null
+++ b/include/tgbot/types/PassportFile.h
@@ -0,0 +1,43 @@
+#ifndef TGBOT_CPP_PASSPORTFILE_H
+#define TGBOT_CPP_PASSPORTFILE_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a file uploaded to Telegram Passport.
+ * Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB.
+ *
+ * @ingroup types
+ */
+class PassportFile {
+
+public:
+ typedef std::shared_ptr<PassportFile> Ptr;
+
+ /**
+ * @brief Identifier for this file, which can be used to download or reuse the file
+ */
+ std::string fileId;
+
+ /**
+ * @brief Unique identifier for this file, which is supposed to be the same over time and for different bots.
+ * Can't be used to download or reuse the file.
+ */
+ std::string fileUniqueId;
+
+ /**
+ * @brief File size
+ */
+ std::int32_t fileSize;
+
+ /**
+ * @brief Unix time when the file was uploaded
+ */
+ std::int32_t fileDate;
+};
+}
+
+#endif //TGBOT_CPP_PASSPORTFILE_H
diff --git a/src/Api.cpp b/src/Api.cpp
index 77e8c0b..070d72e 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -570,12 +570,6 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args));
}
-Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options,
- bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const {
-
- return sendPoll(chatId, question, options, true, "", false, 0, "", "", 0, 0, false, false, 0);
-}
-
Message::Ptr Api::sendDice(std::int64_t chatId, const std::string& emoji, bool disableNotification,
std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
@@ -1053,13 +1047,6 @@ bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, cons
return sendRequest("createNewStickerSet", args).get<bool>("", false);
}
-bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title,
- boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, bool containsMasks,
- MaskPosition::Ptr maskPosition) const {
-
- return createNewStickerSet(userId, name, title, emojis, pngSticker, "", containsMasks, maskPosition);
-}
-
bool Api::addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis,
boost::variant<InputFile::Ptr, std::string> pngSticker, boost::variant<InputFile::Ptr, std::string> tgsSticker, MaskPosition::Ptr maskPosition) const {
vector<HttpReqArg> args;
@@ -1087,12 +1074,6 @@ bool Api::addStickerToSet(std::int64_t userId, const std::string& name, const st
return sendRequest("addStickerToSet", args).get<bool>("", false);
}
-bool Api::addStickerToSet(std::int64_t userId, const std::string& name, boost::variant<InputFile::Ptr, std::string> pngSticker,
- const std::string& emojis, MaskPosition::Ptr maskPosition) const {
-
- return addStickerToSet(userId, name, emojis, pngSticker, "", maskPosition);
-}
-
bool Api::setStickerPositionInSet(const string& sticker, std::uint32_t position) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -1239,6 +1220,16 @@ bool Api::answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok,
return sendRequest("answerPreCheckoutQuery", args).get<bool>("", false);
}
+bool Api::setPassportDataErrors(std::int64_t userId, const std::vector<PassportElementError::Ptr>& errors) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("user_id", userId);
+ args.emplace_back("errors", _tgTypeParser.parseArray<PassportElementError>(&TgTypeParser::parsePassportElementError, errors));
+
+ return sendRequest("setPassportDataErrors", args).get<bool>("", false);
+}
+
Message::Ptr Api::sendGame(std::int64_t chatId, const std::string& gameShortName, std::int32_t replyToMessageId, const InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(5);
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index daa6184..89cdd4c 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -180,7 +180,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->invoice = tryParseJson<Invoice>(&TgTypeParser::parseJsonAndGetInvoice, data, "invoice");
result->successfulPayment = tryParseJson<SuccessfulPayment>(&TgTypeParser::parseJsonAndGetSuccessfulPayment, data, "successful_payment");
result->connectedWebsite = data.get<string>("connected_website", "");
- // result->passportData = tryParseJson<PassportData>(&TgTypeParser::parseJsonAndGetPassportData, data, "passport_data");
+ result->passportData = tryParseJson<PassportData>(&TgTypeParser::parseJsonAndGetPassportData, data, "passport_data");
result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup");
result->automaticForward = data.get<bool>("is_automatic_forward", false);
return result;
@@ -239,7 +239,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "invoice", parseInvoice(object->invoice));
appendToJson(result, "successful_payment", parseSuccessfulPayment(object->successfulPayment));
appendToJson(result, "connected_website", object->connectedWebsite);
- // appendToJson(result, "passport_data", parsePassportData(object->passportData));
+ appendToJson(result, "passport_data", parsePassportData(object->passportData));
appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));
appendToJson(result, "is_automatic_forward", object->automaticForward);
removeLastComma(result);
@@ -2403,6 +2403,361 @@ std::string TgTypeParser::parseSuccessfulPayment(const SuccessfulPayment::Ptr& o
return result;
}
+PassportData::Ptr TgTypeParser::parseJsonAndGetPassportData(const ptree& data) const {
+ auto result(make_shared<PassportData>());
+ result->data = parseJsonAndGetArray<EncryptedPassportElement>(&TgTypeParser::parseJsonAndGetEncryptedPassportElement, data, "data");
+ result->credentials = tryParseJson(&TgTypeParser::parseJsonAndGetEncryptedCredentials, data, "credentials");
+ return result;
+}
+
+string TgTypeParser::parsePassportData(const PassportData::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "data", parseArray(&TgTypeParser::parseEncryptedPassportElement, object->data));
+ appendToJson(result, "credentials", parseEncryptedCredentials(object->credentials));
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+PassportFile::Ptr TgTypeParser::parseJsonAndGetPassportFile(const ptree& data) const {
+ auto result(make_shared<PassportFile>());
+ result->fileId = data.get<string>("file_id", "");
+ result->fileUniqueId = data.get<string>("file_unique_id", "");
+ result->fileSize = data.get<int32_t>("file_size", 0);
+ result->fileDate = data.get<int32_t>("file_date", 0);
+ return result;
+}
+
+string TgTypeParser::parsePassportFile(const PassportFile::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "file_id", object->fileId);
+ appendToJson(result, "file_unique_id", object->fileUniqueId);
+ appendToJson(result, "file_size", object->fileSize);
+ appendToJson(result, "file_date", object->fileDate);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+EncryptedPassportElement::Ptr TgTypeParser::parseJsonAndGetEncryptedPassportElement(const ptree& data) const {
+ auto result(make_shared<EncryptedPassportElement>());
+ result->type = data.get<string>("type", "");
+ result->data = data.get<string>("data", "");
+ result->phoneNumber = data.get<string>("phone_number", "");
+ result->email = data.get<string>("email", "");
+ result->files = parseJsonAndGetArray<PassportFile>(&TgTypeParser::parseJsonAndGetPassportFile, data, "files");
+ result->frontSide = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "front_side");
+ result->reverseSide = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "reverse_side");
+ result->selfie = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "selfie");
+ result->translation = parseJsonAndGetArray<PassportFile>(&TgTypeParser::parseJsonAndGetPassportFile, data, "translation");
+ result->hash = data.get<string>("hash", "");
+ return result;
+}
+
+string TgTypeParser::parseEncryptedPassportElement(const EncryptedPassportElement::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "type", object->type);
+ appendToJson(result, "data", object->data);
+ appendToJson(result, "phone_number", object->phoneNumber);
+ appendToJson(result, "email", object->email);
+ appendToJson(result, "files", parseArray(&TgTypeParser::parsePassportFile, object->files));
+ appendToJson(result, "front_side", parsePassportFile(object->frontSide));
+ appendToJson(result, "reverse_side", parsePassportFile(object->reverseSide));
+ appendToJson(result, "selfie", parsePassportFile(object->selfie));
+ appendToJson(result, "translation", parseArray(&TgTypeParser::parsePassportFile, object->translation));
+ appendToJson(result, "hash", object->hash);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+EncryptedCredentials::Ptr TgTypeParser::parseJsonAndGetEncryptedCredentials(const ptree& data) const {
+ auto result(make_shared<EncryptedCredentials>());
+ result->data = data.get<string>("data", "");
+ result->hash = data.get<string>("hash", "");
+ result->secret = data.get<string>("secret", "");
+ return result;
+}
+
+string TgTypeParser::parseEncryptedCredentials(const EncryptedCredentials::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "data", object->data);
+ appendToJson(result, "hash", object->hash);
+ appendToJson(result, "secret", object->secret);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+PassportElementError::Ptr TgTypeParser::parseJsonAndGetPassportElementError(const ptree& data) const {
+ string source = data.get<string>("source", "");
+ PassportElementError::Ptr result;
+
+ if (source == PassportElementErrorDataField::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorDataField(data));
+ } else if (source == PassportElementErrorFrontSide::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFrontSide(data));
+ } else if (source == PassportElementErrorReverseSide::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorReverseSide(data));
+ } else if (source == PassportElementErrorSelfie::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorSelfie(data));
+ } else if (source == PassportElementErrorFile::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFile(data));
+ } else if (source == PassportElementErrorFiles::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFiles(data));
+ } else if (source == PassportElementErrorTranslationFile::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFile(data));
+ } else if (source == PassportElementErrorTranslationFiles::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFiles(data));
+ } else if (source == PassportElementErrorUnspecified::SOURCE) {
+ result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorUnspecified(data));
+ } else {
+ result = make_shared<PassportElementError>();
+ }
+
+ result->source = data.get<string>("source", "");
+ result->type = data.get<string>("type", "");
+ result->message = data.get<string>("message", "");
+
+ return result;
+}
+
+string TgTypeParser::parsePassportElementError(const PassportElementError::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "source", object->source);
+ appendToJson(result, "type", object->type);
+ appendToJson(result, "message", object->message);
+
+ if (object->source == PassportElementErrorDataField::SOURCE) {
+ result += parsePassportElementErrorDataField(static_pointer_cast<PassportElementErrorDataField>(object));
+ } else if (object->source == PassportElementErrorFrontSide::SOURCE) {
+ result += parsePassportElementErrorFrontSide(static_pointer_cast<PassportElementErrorFrontSide>(object));
+ } else if (object->source == PassportElementErrorReverseSide::SOURCE) {
+ result += parsePassportElementErrorReverseSide(static_pointer_cast<PassportElementErrorReverseSide>(object));
+ } else if (object->source == PassportElementErrorSelfie::SOURCE) {
+ result += parsePassportElementErrorSelfie(static_pointer_cast<PassportElementErrorSelfie>(object));
+ } else if (object->source == PassportElementErrorFile::SOURCE) {
+ result += parsePassportElementErrorFile(static_pointer_cast<PassportElementErrorFile>(object));
+ } else if (object->source == PassportElementErrorFiles::SOURCE) {
+ result += parsePassportElementErrorFiles(static_pointer_cast<PassportElementErrorFiles>(object));
+ } else if (object->source == PassportElementErrorTranslationFile::SOURCE) {
+ result += parsePassportElementErrorTranslationFile(static_pointer_cast<PassportElementErrorTranslationFile>(object));
+ } else if (object->source == PassportElementErrorTranslationFiles::SOURCE) {
+ result += parsePassportElementErrorTranslationFiles(static_pointer_cast<PassportElementErrorTranslationFiles>(object));
+ } else if (object->source == PassportElementErrorUnspecified::SOURCE) {
+ result += parsePassportElementErrorUnspecified(static_pointer_cast<PassportElementErrorUnspecified>(object));
+ }
+
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+PassportElementErrorDataField::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorDataField(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorDataField>());
+ result->fieldName = data.get<string>("field_name", "");
+ result->dataHash = data.get<string>("data_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorDataField(const PassportElementErrorDataField::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "field_name", object->fieldName);
+ appendToJson(result, "data_hash", object->dataHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorFrontSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFrontSide(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorFrontSide>());
+ result->fileHash = data.get<string>("file_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorFrontSide(const PassportElementErrorFrontSide::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hash", object->fileHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorReverseSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorReverseSide(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorReverseSide>());
+ result->fileHash = data.get<string>("file_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorReverseSide(const PassportElementErrorReverseSide::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hash", object->fileHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorSelfie::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorSelfie(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorSelfie>());
+ result->fileHash = data.get<string>("file_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorSelfie(const PassportElementErrorSelfie::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hash", object->fileHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFile(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorFile>());
+ result->fileHash = data.get<string>("file_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorFile(const PassportElementErrorFile::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hash", object->fileHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFiles(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorFiles>());
+ result->fileHashes = parseJsonAndGetArray<std::string>(
+ [] (const ptree& innerData)->std::string {
+ return innerData.get<std::string>("");
+ }, data, "file_hashes");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorFiles(const PassportElementErrorFiles::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hashes",
+ parseArray<std::string>([] (const std::string& s)->std::string {
+ return s;
+ }, object->fileHashes));
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorTranslationFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFile(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorTranslationFile>());
+ result->fileHash = data.get<string>("file_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorTranslationFile(const PassportElementErrorTranslationFile::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hash", object->fileHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorTranslationFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFiles(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorTranslationFiles>());
+ result->fileHashes = parseJsonAndGetArray<std::string>(
+ [] (const ptree& innerData)->std::string {
+ return innerData.get<std::string>("");
+ }, data, "file_hashes");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorTranslationFiles(const PassportElementErrorTranslationFiles::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "file_hashes",
+ parseArray<std::string>([] (const std::string& s)->std::string {
+ return s;
+ }, object->fileHashes));
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
+PassportElementErrorUnspecified::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorUnspecified(const ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetPassportElementError().
+ auto result(make_shared<PassportElementErrorUnspecified>());
+ result->elementHash = data.get<string>("element_hash", "");
+ return result;
+}
+
+string TgTypeParser::parsePassportElementErrorUnspecified(const PassportElementErrorUnspecified::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parsePassportElementError(), so I don't add
+ // curly brackets to the result string.
+ string result;
+ appendToJson(result, "element_hash", object->elementHash);
+ // The last comma will be erased by parsePassportElementError().
+ return result;
+}
+
void TgTypeParser::appendToJson(string& json, const string& varName, const string& value) const {
if (value.empty()) {
diff --git a/src/types/PassportElementError.cpp b/src/types/PassportElementError.cpp
new file mode 100644
index 0000000..d0156a9
--- /dev/null
+++ b/src/types/PassportElementError.cpp
@@ -0,0 +1,23 @@
+#include "tgbot/types/PassportElementErrorDataField.h"
+#include "tgbot/types/PassportElementErrorFrontSide.h"
+#include "tgbot/types/PassportElementErrorReverseSide.h"
+#include "tgbot/types/PassportElementErrorSelfie.h"
+#include "tgbot/types/PassportElementErrorFile.h"
+#include "tgbot/types/PassportElementErrorFiles.h"
+#include "tgbot/types/PassportElementErrorTranslationFile.h"
+#include "tgbot/types/PassportElementErrorTranslationFiles.h"
+#include "tgbot/types/PassportElementErrorUnspecified.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string PassportElementErrorDataField::SOURCE = "data";
+const std::string PassportElementErrorFrontSide::SOURCE = "front_side";
+const std::string PassportElementErrorReverseSide::SOURCE = "reverse_side";
+const std::string PassportElementErrorSelfie::SOURCE = "selfie";
+const std::string PassportElementErrorFile::SOURCE = "file";
+const std::string PassportElementErrorFiles::SOURCE = "files";
+const std::string PassportElementErrorTranslationFile::SOURCE = "translation_file";
+const std::string PassportElementErrorTranslationFiles::SOURCE = "translation_files";
+const std::string PassportElementErrorUnspecified::SOURCE = "unspecified";