api integration
This commit is contained in:
28
lib/data/models/transaction.dart
Normal file
28
lib/data/models/transaction.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
class Transaction {
|
||||
final String? id;
|
||||
final String? name;
|
||||
final String? date;
|
||||
final int? amount;
|
||||
final String? type;
|
||||
|
||||
Transaction({this.id, this.name, this.date, this.amount, this.type});
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'date': date,
|
||||
'amount': amount,
|
||||
'type': type,
|
||||
};
|
||||
}
|
||||
|
||||
factory Transaction.fromJson(Map<String, dynamic> json) {
|
||||
return Transaction(
|
||||
id: json['id'] as String?,
|
||||
name: json['name'] as String?,
|
||||
date: json['date'] as String?,
|
||||
amount: json['amount'] as int?,
|
||||
type: json['type'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,25 +1,30 @@
|
||||
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? 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 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,
|
||||
required this.bookingNumber,
|
||||
this.bookingNumber,
|
||||
required this.branchId,
|
||||
required this.currency,
|
||||
this.productType,
|
||||
@@ -30,14 +35,42 @@ class User extends Equatable {
|
||||
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['stBranchId'],
|
||||
branchId: json['stBranchNo'],
|
||||
currency: json['stCurrency'],
|
||||
productType: json['stProductType'],
|
||||
approvedAmount: json['stApprovedAmount'],
|
||||
@@ -47,9 +80,34 @@ class User extends Equatable {
|
||||
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];
|
||||
List<Object?> get props => [
|
||||
accountNo,
|
||||
accountType,
|
||||
bookingNumber,
|
||||
branchId,
|
||||
currency,
|
||||
productType,
|
||||
approvedAmount,
|
||||
availableBalance,
|
||||
currentBalance,
|
||||
name,
|
||||
mobileNo,
|
||||
address,
|
||||
picode,
|
||||
transactions,
|
||||
activeAccounts,
|
||||
cifNumber,
|
||||
primaryId,
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user