Skip to content

Commit

Permalink
use enum in passport element error
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoLeung committed Mar 31, 2024
1 parent c48e834 commit 5857f58
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 31 additions & 8 deletions lib/src/telegram/models/passport_element_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorDataField implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fieldName;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/telegram/models/passport_element_error_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorFile implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fileHash;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/telegram/models/passport_element_error_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorFiles implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
List<String> fileHashes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorFrontSide implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fileHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorReverseSide implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fileHash;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/telegram/models/passport_element_error_selfie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorSelfie implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fileHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorTranslationFile implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String fileHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorTranslationFiles implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
List<String> fileHashes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PassportElementErrorUnspecified implements PassportElementError {
@override
String source;
@override
String type;
PassportElementErrorType type;
@override
String message;
String elementHash;
Expand Down

0 comments on commit 5857f58

Please sign in to comment.