68 lines
2.0 KiB
Dart
68 lines
2.0 KiB
Dart
|
|
import 'dart:convert';
|
|
|
|
import 'stripe_payment_method.dart';
|
|
|
|
class User {
|
|
int id;
|
|
String username;
|
|
String nickname;
|
|
String mobile;
|
|
String email;
|
|
String avatarUrl;
|
|
int lastAddressId;
|
|
String passCode;
|
|
double credit;
|
|
double wallet;
|
|
int coupon;
|
|
int points;
|
|
int orderNum;
|
|
double pointsToCreditsConversionRate;
|
|
String contactNumber;
|
|
String flutterMiniStoreToken;
|
|
List<StripePaymentMethod> stripePaymentMethods;
|
|
|
|
User.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'],
|
|
username = json['username'],
|
|
nickname = json['nickname'],
|
|
mobile = json['mobile'],
|
|
email = json['email'],
|
|
avatarUrl = json['avatar_url'],
|
|
lastAddressId = json['last_address_id'],
|
|
passCode = json['pass_code'],
|
|
credit = double.parse(json['credit'].toString()),
|
|
wallet = double.parse((json['wallet'] == null) ? "0": json['wallet'].toString()),
|
|
coupon = json['coupon'],
|
|
points = json['points'],
|
|
orderNum = json['order_num'],
|
|
pointsToCreditsConversionRate = double.parse(json['points_to_credits_conversion_rate'].toString()),
|
|
contactNumber = json['contact_number'],
|
|
flutterMiniStoreToken = json['flutter_ministore_token'],
|
|
stripePaymentMethods = (json['stripe_payment_methods'] as List).map((e) => StripePaymentMethod.fromJson(e)).toList();
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'username': username,
|
|
'nickname': nickname,
|
|
'mobile': mobile,
|
|
'email': email,
|
|
'avatar_url': avatarUrl,
|
|
'last_address_id': lastAddressId,
|
|
'pass_code': passCode,
|
|
'credit': credit,
|
|
'wallet': wallet,
|
|
'coupon': coupon,
|
|
'points': points,
|
|
'order_num': orderNum,
|
|
'points_to_credits_conversion_rate': pointsToCreditsConversionRate,
|
|
'contact_number': contactNumber,
|
|
'flutter_ministore_token': flutterMiniStoreToken,
|
|
'stripe_payment_methods': stripePaymentMethods,
|
|
};
|
|
|
|
@override
|
|
String toString() {
|
|
return json.encode(this);
|
|
}
|
|
} |