refactor: polymorphism can be used without manual switch statement

This commit is contained in:
Lukas Lihotzki 2021-05-05 12:05:26 +02:00
parent 4069f0a02f
commit 2fdf3e8284
1 changed files with 1 additions and 17 deletions

View File

@ -68,23 +68,7 @@ class AuthenticationPassword extends AuthenticationData {
final data = super.toJson();
if (user != null) data['user'] = user;
data['password'] = password;
switch (identifier.type) {
case AuthenticationIdentifierTypes.userId:
data['identifier'] =
(identifier as AuthenticationUserIdentifier).toJson();
break;
case AuthenticationIdentifierTypes.phone:
data['identifier'] =
(identifier as AuthenticationPhoneIdentifier).toJson();
break;
case AuthenticationIdentifierTypes.thirdParty:
data['identifier'] =
(identifier as AuthenticationThirdPartyIdentifier).toJson();
break;
default:
data['identifier'] = identifier.toJson();
break;
}
data['identifier'] = identifier.toJson();
return data;
}
}