diff --git a/CHANGELOG.md b/CHANGELOG.md index 309ec78..3556cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ - support Telegram API 6.9 - **Breaking** Updated function `telegram:Telegram.sendDice` and function `teledart:Message.replyDice` to accept enum of `DiceEmoji` instead of emoji string -- **Breaking** Updated class `Dice`, `InlineQueryResult`, `MenuButton` to use enum for `type` +- **Breaking** Updated class `Dice`, `InlineQueryResult`, `MenuButton`, `PassportElementError` to use enum for `type` ## 0.6.1 diff --git a/lib/src/telegram/models/passport_element_error.dart b/lib/src/telegram/models/passport_element_error.dart index 5e3befb..0ce5fb8 100644 --- a/lib/src/telegram/models/passport_element_error.dart +++ b/lib/src/telegram/models/passport_element_error.dart @@ -18,6 +18,36 @@ part of '../model.dart'; +@JsonEnum() +enum PassportElementErrorType { + @JsonValue('personal_details') + personalDetails, + @JsonValue('passport') + passport, + @JsonValue('driver_license') + driverLicense, + @JsonValue('identity_card') + identityCard, + @JsonValue('internal_passport') + internalPassport, + @JsonValue('address') + address, + @JsonValue('utility_bill') + utilityBill, + @JsonValue('bank_statement') + bankStatement, + @JsonValue('rental_agreement') + rentalAgreement, + @JsonValue('passport_registration') + passportRegistration, + @JsonValue('temporary_registration') + temporaryRegistration, +} + +extension PassportElementErrorTypeExtenson on PassportElementErrorType { + String value() => _$PassportElementErrorTypeEnumMap[this]!; +} + /// This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. /// /// It should be one of: @@ -34,15 +64,8 @@ part of '../model.dart'; /// https://core.telegram.org/bots/api#passportelementerror @JsonSerializable(fieldRename: FieldRename.snake) class PassportElementError { - static const typePersonalDetails = 'personal_details'; - static const typePassport = 'passport'; - static const typeDriverLicense = 'driver_license'; - static const typeIdentityCard = 'identity_card'; - static const typeInternalPassport = 'internal_passport'; - static const typeAddress = 'address'; - String source; - String type; + PassportElementErrorType type; String message; PassportElementError({ required this.source, diff --git a/lib/src/telegram/models/passport_element_error_data_field.dart b/lib/src/telegram/models/passport_element_error_data_field.dart index bf1f3dd..504aedf 100644 --- a/lib/src/telegram/models/passport_element_error_data_field.dart +++ b/lib/src/telegram/models/passport_element_error_data_field.dart @@ -28,7 +28,7 @@ class PassportElementErrorDataField implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fieldName; diff --git a/lib/src/telegram/models/passport_element_error_file.dart b/lib/src/telegram/models/passport_element_error_file.dart index e223ca5..5842b63 100644 --- a/lib/src/telegram/models/passport_element_error_file.dart +++ b/lib/src/telegram/models/passport_element_error_file.dart @@ -28,7 +28,7 @@ class PassportElementErrorFile implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fileHash; diff --git a/lib/src/telegram/models/passport_element_error_files.dart b/lib/src/telegram/models/passport_element_error_files.dart index 8bb8ffa..d1da681 100644 --- a/lib/src/telegram/models/passport_element_error_files.dart +++ b/lib/src/telegram/models/passport_element_error_files.dart @@ -28,7 +28,7 @@ class PassportElementErrorFiles implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; List fileHashes; diff --git a/lib/src/telegram/models/passport_element_error_front_side.dart b/lib/src/telegram/models/passport_element_error_front_side.dart index 81a69ce..85f25bf 100644 --- a/lib/src/telegram/models/passport_element_error_front_side.dart +++ b/lib/src/telegram/models/passport_element_error_front_side.dart @@ -28,7 +28,7 @@ class PassportElementErrorFrontSide implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fileHash; diff --git a/lib/src/telegram/models/passport_element_error_reverse_side.dart b/lib/src/telegram/models/passport_element_error_reverse_side.dart index f5eeced..5e3c49d 100644 --- a/lib/src/telegram/models/passport_element_error_reverse_side.dart +++ b/lib/src/telegram/models/passport_element_error_reverse_side.dart @@ -28,7 +28,7 @@ class PassportElementErrorReverseSide implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fileHash; diff --git a/lib/src/telegram/models/passport_element_error_selfie.dart b/lib/src/telegram/models/passport_element_error_selfie.dart index 1e2ec03..4af63d2 100644 --- a/lib/src/telegram/models/passport_element_error_selfie.dart +++ b/lib/src/telegram/models/passport_element_error_selfie.dart @@ -28,7 +28,7 @@ class PassportElementErrorSelfie implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fileHash; diff --git a/lib/src/telegram/models/passport_element_error_translation_file.dart b/lib/src/telegram/models/passport_element_error_translation_file.dart index 5ece1b9..a25e002 100644 --- a/lib/src/telegram/models/passport_element_error_translation_file.dart +++ b/lib/src/telegram/models/passport_element_error_translation_file.dart @@ -28,7 +28,7 @@ class PassportElementErrorTranslationFile implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String fileHash; diff --git a/lib/src/telegram/models/passport_element_error_translation_files.dart b/lib/src/telegram/models/passport_element_error_translation_files.dart index 98386e1..9ed2c60 100644 --- a/lib/src/telegram/models/passport_element_error_translation_files.dart +++ b/lib/src/telegram/models/passport_element_error_translation_files.dart @@ -28,7 +28,7 @@ class PassportElementErrorTranslationFiles implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; List fileHashes; diff --git a/lib/src/telegram/models/passport_element_error_unspecified.dart b/lib/src/telegram/models/passport_element_error_unspecified.dart index 6b6b71f..811f0e8 100644 --- a/lib/src/telegram/models/passport_element_error_unspecified.dart +++ b/lib/src/telegram/models/passport_element_error_unspecified.dart @@ -28,7 +28,7 @@ class PassportElementErrorUnspecified implements PassportElementError { @override String source; @override - String type; + PassportElementErrorType type; @override String message; String elementHash;