Skip to content

Commit 987703e

Browse files
authored
zohreh/update_auth_schema (#259)
- update auth schema
1 parent 101b851 commit 987703e

File tree

1 file changed

+5
-37
lines changed

1 file changed

+5
-37
lines changed

lib/api/response/authorize_response_result.dart

+5-37
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,6 @@ class AuthorizeResponse extends AuthorizeResponseModel {
9393
);
9494
}
9595

96-
/// AccountTypeEnum mapper.
97-
final Map<String, AccountTypeEnum> accountTypeEnumMapper =
98-
<String, AccountTypeEnum>{
99-
"trading": AccountTypeEnum.trading,
100-
"wallet": AccountTypeEnum.wallet,
101-
};
102-
103-
/// AccountType Enum.
104-
enum AccountTypeEnum {
105-
/// trading.
106-
trading,
107-
108-
/// wallet.
109-
wallet,
110-
}
111-
11296
/// PlatformEnum mapper.
11397
final Map<String, PlatformEnum> platformEnumMapper = <String, PlatformEnum>{
11498
"deriv": PlatformEnum.deriv,
@@ -127,7 +111,6 @@ enum PlatformEnum {
127111
/// mt5.
128112
mt5,
129113
}
130-
131114
/// Authorize model class.
132115
abstract class AuthorizeModel {
133116
/// Initializes Authorize model class .
@@ -385,7 +368,6 @@ class Authorize extends AuthorizeModel {
385368
wallet: wallet ?? this.wallet,
386369
);
387370
}
388-
389371
/// Account list item model class.
390372
abstract class AccountListItemModel {
391373
/// Initializes Account list item model class .
@@ -403,7 +385,7 @@ abstract class AccountListItemModel {
403385
});
404386

405387
/// Account type.
406-
final AccountTypeEnum? accountType;
388+
final String? accountType;
407389

408390
/// Creation time of the account as epoch.
409391
final DateTime? createdAt;
@@ -437,7 +419,7 @@ abstract class AccountListItemModel {
437419
class AccountListItem extends AccountListItemModel {
438420
/// Initializes Account list item class.
439421
const AccountListItem({
440-
AccountTypeEnum? accountType,
422+
String? accountType,
441423
DateTime? createdAt,
442424
String? currency,
443425
DateTime? excludedUntil,
@@ -463,9 +445,7 @@ class AccountListItem extends AccountListItemModel {
463445
/// Creates an instance from JSON.
464446
factory AccountListItem.fromJson(Map<String, dynamic> json) =>
465447
AccountListItem(
466-
accountType: json['account_type'] == null
467-
? null
468-
: accountTypeEnumMapper[json['account_type']],
448+
accountType: json['account_type'],
469449
createdAt: getDateTime(json['created_at']),
470450
currency: json['currency'],
471451
excludedUntil: getDateTime(json['excluded_until']),
@@ -482,10 +462,7 @@ class AccountListItem extends AccountListItemModel {
482462
Map<String, dynamic> toJson() {
483463
final Map<String, dynamic> resultMap = <String, dynamic>{};
484464

485-
resultMap['account_type'] = accountTypeEnumMapper.entries
486-
.firstWhere((MapEntry<String, AccountTypeEnum> entry) =>
487-
entry.value == accountType)
488-
.key;
465+
resultMap['account_type'] = accountType;
489466
resultMap['created_at'] = getSecondsSinceEpochDateTime(createdAt);
490467
resultMap['currency'] = currency;
491468
resultMap['excluded_until'] = getSecondsSinceEpochDateTime(excludedUntil);
@@ -505,7 +482,7 @@ class AccountListItem extends AccountListItemModel {
505482

506483
/// Creates a copy of instance with given parameters.
507484
AccountListItem copyWith({
508-
AccountTypeEnum? accountType,
485+
String? accountType,
509486
DateTime? createdAt,
510487
String? currency,
511488
DateTime? excludedUntil,
@@ -529,7 +506,6 @@ class AccountListItem extends AccountListItemModel {
529506
wallet: wallet ?? this.wallet,
530507
);
531508
}
532-
533509
/// Trading model class.
534510
abstract class TradingModel {
535511
/// Initializes Trading model class .
@@ -584,7 +560,6 @@ class Trading extends TradingModel {
584560
linkedTo: linkedTo ?? this.linkedTo,
585561
);
586562
}
587-
588563
/// Linked to item model class.
589564
abstract class LinkedToItemModel {
590565
/// Initializes Linked to item model class .
@@ -657,7 +632,6 @@ class LinkedToItem extends LinkedToItemModel {
657632
paymentMethod: paymentMethod ?? this.paymentMethod,
658633
);
659634
}
660-
661635
/// Wallet model class.
662636
abstract class WalletModel {
663637
/// Initializes Wallet model class .
@@ -752,7 +726,6 @@ class Wallet extends WalletModel {
752726
paymentMethod: paymentMethod ?? this.paymentMethod,
753727
);
754728
}
755-
756729
/// Wallet linked to item model class.
757730
abstract class WalletLinkedToItemModel {
758731
/// Initializes Wallet linked to item model class .
@@ -831,7 +804,6 @@ class WalletLinkedToItem extends WalletLinkedToItemModel {
831804
platform: platform ?? this.platform,
832805
);
833806
}
834-
835807
/// Local currencies property model class.
836808
abstract class LocalCurrenciesPropertyModel {
837809
/// Initializes Local currencies property model class .
@@ -875,7 +847,6 @@ class LocalCurrenciesProperty extends LocalCurrenciesPropertyModel {
875847
fractionalDigits: fractionalDigits ?? this.fractionalDigits,
876848
);
877849
}
878-
879850
/// Authorize trading model class.
880851
abstract class AuthorizeTradingModel {
881852
/// Initializes Authorize trading model class .
@@ -931,7 +902,6 @@ class AuthorizeTrading extends AuthorizeTradingModel {
931902
linkedTo: linkedTo ?? this.linkedTo,
932903
);
933904
}
934-
935905
/// Trading linked to item model class.
936906
abstract class TradingLinkedToItemModel {
937907
/// Initializes Trading linked to item model class .
@@ -1005,7 +975,6 @@ class TradingLinkedToItem extends TradingLinkedToItemModel {
1005975
paymentMethod: paymentMethod ?? this.paymentMethod,
1006976
);
1007977
}
1008-
1009978
/// Authorize wallet model class.
1010979
abstract class AuthorizeWalletModel {
1011980
/// Initializes Authorize wallet model class .
@@ -1101,7 +1070,6 @@ class AuthorizeWallet extends AuthorizeWalletModel {
11011070
paymentMethod: paymentMethod ?? this.paymentMethod,
11021071
);
11031072
}
1104-
11051073
/// Wallet linked to item8 model class.
11061074
abstract class WalletLinkedToItem8Model {
11071075
/// Initializes Wallet linked to item8 model class .

0 commit comments

Comments
 (0)