|
| 1 | +import 'package:flutter_deriv_api/api/authorize/account.dart'; |
| 2 | +import 'package:flutter_deriv_api/api/models/authorize_model.dart'; |
| 3 | +import 'package:flutter_deriv_api/api/models/local_currency_model.dart'; |
| 4 | + |
| 5 | +/// Authorize class |
| 6 | +class Authorize extends AuthorizeModel { |
| 7 | + /// Class constructor |
| 8 | + Authorize({ |
| 9 | + List<Account> accountList, |
| 10 | + double balance, |
| 11 | + String country, |
| 12 | + String currency, |
| 13 | + String email, |
| 14 | + String fullname, |
| 15 | + bool isVirtual, |
| 16 | + String landingCompanyFullname, |
| 17 | + String landingCompanyName, |
| 18 | + List<LocalCurrencyModel> localCurrencies, |
| 19 | + String loginid, |
| 20 | + List<String> scopes, |
| 21 | + List<String> upgradeableLandingCompanies, |
| 22 | + int userId, |
| 23 | + }) : super( |
| 24 | + accountList: accountList, |
| 25 | + balance: balance, |
| 26 | + country: country, |
| 27 | + currency: currency, |
| 28 | + email: email, |
| 29 | + fullname: fullname, |
| 30 | + isVirtual: isVirtual, |
| 31 | + landingCompanyFullname: landingCompanyFullname, |
| 32 | + landingCompanyName: landingCompanyName, |
| 33 | + localCurrencies: localCurrencies, |
| 34 | + loginid: loginid, |
| 35 | + scopes: scopes, |
| 36 | + upgradeableLandingCompanies: upgradeableLandingCompanies, |
| 37 | + userId: userId, |
| 38 | + ); |
| 39 | + |
| 40 | + /// Generate instance from json |
| 41 | + factory Authorize.fromJson(Map<String, dynamic> json) => Authorize( |
| 42 | + accountList: json['account_list'] == null |
| 43 | + ? null |
| 44 | + : json['account_list'] |
| 45 | + .map<Account>((dynamic item) => Account.fromJson(item)) |
| 46 | + .toList(), |
| 47 | + balance: json['balance'].toDouble(), |
| 48 | + country: json['country'], |
| 49 | + currency: json['currency'], |
| 50 | + email: json['email'], |
| 51 | + fullname: json['fullname'], |
| 52 | + isVirtual: json['is_virtual'] == 1, |
| 53 | + landingCompanyFullname: json['landing_company_fullname'], |
| 54 | + landingCompanyName: json['landing_company_name'], |
| 55 | + localCurrencies: json['local_currencies'] == null |
| 56 | + ? null |
| 57 | + : json['local_currencies'] |
| 58 | + .entries |
| 59 | + .map<LocalCurrencyModel>( |
| 60 | + (dynamic entry) => LocalCurrencyModel.fromJson( |
| 61 | + <String, dynamic>{ |
| 62 | + 'key': entry.key, |
| 63 | + 'values': entry.value, |
| 64 | + }, |
| 65 | + ), |
| 66 | + ) |
| 67 | + .toList(), |
| 68 | + loginid: json['loginid'], |
| 69 | + scopes: json['scopes'] == null |
| 70 | + ? null |
| 71 | + : json['scopes'] |
| 72 | + .map<String>((dynamic item) => item.toString()) |
| 73 | + .toList(), |
| 74 | + upgradeableLandingCompanies: |
| 75 | + json['upgradeable_landing_companies'] == null |
| 76 | + ? null |
| 77 | + : json['upgradeable_landing_companies'] |
| 78 | + .map<String>((dynamic item) => item.toString()) |
| 79 | + .toList(), |
| 80 | + userId: json['user_id'], |
| 81 | + ); |
| 82 | + |
| 83 | + /// Generate copy of instance with given parameters |
| 84 | + Authorize copyWith({ |
| 85 | + List<Account> accountList, |
| 86 | + double balance, |
| 87 | + String country, |
| 88 | + String currency, |
| 89 | + String email, |
| 90 | + String fullname, |
| 91 | + bool isVirtual, |
| 92 | + String landingCompanyFullname, |
| 93 | + String landingCompanyName, |
| 94 | + List<LocalCurrencyModel> localCurrencies, |
| 95 | + String loginid, |
| 96 | + List<String> scopes, |
| 97 | + List<String> upgradeableLandingCompanies, |
| 98 | + int userId, |
| 99 | + }) => |
| 100 | + Authorize( |
| 101 | + accountList: accountList ?? this.accountList, |
| 102 | + balance: balance ?? this.balance, |
| 103 | + country: country ?? this.country, |
| 104 | + currency: currency ?? this.currency, |
| 105 | + email: email ?? this.email, |
| 106 | + fullname: fullname ?? this.fullname, |
| 107 | + isVirtual: isVirtual ?? this.isVirtual, |
| 108 | + landingCompanyFullname: |
| 109 | + landingCompanyFullname ?? this.landingCompanyFullname, |
| 110 | + landingCompanyName: landingCompanyName ?? this.landingCompanyName, |
| 111 | + localCurrencies: localCurrencies ?? this.localCurrencies, |
| 112 | + loginid: loginid ?? this.loginid, |
| 113 | + scopes: scopes ?? this.scopes, |
| 114 | + upgradeableLandingCompanies: |
| 115 | + upgradeableLandingCompanies ?? this.upgradeableLandingCompanies, |
| 116 | + userId: userId ?? this.userId, |
| 117 | + ); |
| 118 | +} |
0 commit comments