114 lines
3.1 KiB
Dart
114 lines
3.1 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import 'package:kmobile/data/models/transaction.dart';
|
|
|
|
class User extends Equatable {
|
|
final String? accountNo;
|
|
final String? accountType;
|
|
final String? bookingNumber;
|
|
final String? branchId;
|
|
final String? currency;
|
|
final String? productType;
|
|
final String? approvedAmount;
|
|
final String? availableBalance;
|
|
final String? currentBalance;
|
|
final String? name;
|
|
final String? mobileNo;
|
|
final String? address;
|
|
final String? picode;
|
|
final int? activeAccounts;
|
|
final String? cifNumber;
|
|
final String? primaryId;
|
|
final String? dateOfBirth;
|
|
final List<Transaction>? transactions;
|
|
|
|
const User({
|
|
required this.accountNo,
|
|
required this.accountType,
|
|
this.bookingNumber,
|
|
required this.branchId,
|
|
required this.currency,
|
|
this.productType,
|
|
this.approvedAmount,
|
|
required this.availableBalance,
|
|
required this.currentBalance,
|
|
required this.name,
|
|
required this.mobileNo,
|
|
required this.address,
|
|
required this.picode,
|
|
this.transactions,
|
|
this.activeAccounts,
|
|
this.cifNumber,
|
|
this.primaryId,
|
|
this.dateOfBirth,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'stAccountNo': accountNo,
|
|
'stAccountType': accountType,
|
|
'stBookingNumber': bookingNumber,
|
|
'stBranchId': branchId,
|
|
'stCurrency': currency,
|
|
'stProductType': productType,
|
|
'stApprovedAmount': approvedAmount,
|
|
'stAvailableBalance': availableBalance,
|
|
'stCurrentBalance': currentBalance,
|
|
'custname': name,
|
|
'mobileno': mobileNo,
|
|
'custaddress': address,
|
|
'picode': picode,
|
|
'transactions': transactions?.map((tx) => tx.toJson()).toList(),
|
|
'activeAccounts': activeAccounts,
|
|
'cifNumber': cifNumber,
|
|
'primaryId': primaryId,
|
|
'dateOfBirth': dateOfBirth,
|
|
};
|
|
}
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
return User(
|
|
accountNo: json['stAccountNo'],
|
|
accountType: json['stAccountType'],
|
|
bookingNumber: json['stBookingNumber'],
|
|
branchId: json['stBranchNo'],
|
|
currency: json['stCurrency'],
|
|
productType: json['stProductType'],
|
|
approvedAmount: json['stApprovedAmount'],
|
|
availableBalance: json['stAvailableBalance'],
|
|
currentBalance: json['stCurrentBalance'],
|
|
name: json['custname'],
|
|
mobileNo: json['mobileno'],
|
|
address: json['custaddress'],
|
|
picode: json['picode'],
|
|
cifNumber: json['cifNumber'],
|
|
primaryId: json['id'],
|
|
activeAccounts: json['activeAccounts'] as int?,
|
|
dateOfBirth: json['custdob'],
|
|
transactions: (json['transactions'] as List<dynamic>?)
|
|
?.map((tx) => Transaction.fromJson(tx))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
accountNo,
|
|
accountType,
|
|
bookingNumber,
|
|
branchId,
|
|
currency,
|
|
productType,
|
|
approvedAmount,
|
|
availableBalance,
|
|
currentBalance,
|
|
name,
|
|
mobileNo,
|
|
address,
|
|
picode,
|
|
transactions,
|
|
activeAccounts,
|
|
cifNumber,
|
|
primaryId,
|
|
];
|
|
}
|