63 lines
1.5 KiB
Dart
63 lines
1.5 KiB
Dart
class UserShippingAddress {
|
|
final String id;
|
|
final String street;
|
|
final String city;
|
|
final String state;
|
|
final String postalCode;
|
|
final String country;
|
|
String? panNumber;
|
|
final String tradeName;
|
|
String? gstNumber;
|
|
bool? isDefault;
|
|
|
|
UserShippingAddress({
|
|
required this.id,
|
|
required this.street,
|
|
required this.city,
|
|
required this.state,
|
|
required this.postalCode,
|
|
required this.country,
|
|
this.panNumber,
|
|
required this.tradeName,
|
|
this.gstNumber,
|
|
this.isDefault,
|
|
});
|
|
|
|
factory UserShippingAddress.fromJson(Map<String, dynamic> json) {
|
|
return UserShippingAddress(
|
|
id: json['_id'],
|
|
street: json['street'],
|
|
city: json['city'],
|
|
state: json['state'],
|
|
postalCode: json['postalCode'],
|
|
country: json['country'],
|
|
panNumber: json['panNumber'],
|
|
tradeName: json['tradeName'],
|
|
gstNumber: json['gstNumber'],
|
|
isDefault: json['isDefault'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'_id': id,
|
|
'street': street,
|
|
'city': city,
|
|
'state': state,
|
|
'postalCode': postalCode,
|
|
'country': country,
|
|
'panNumber': panNumber,
|
|
'tradeName': tradeName,
|
|
'gstNumber': gstNumber,
|
|
'isDefault': isDefault,
|
|
};
|
|
}
|
|
|
|
|
|
// Utility method in UserShippingAddress model to get full address as a string
|
|
//extension UserShippingAddressExtensions on UserShippingAddress {
|
|
String toStringFullAddress() {
|
|
return "$street, $city, $state, $postalCode, $country";
|
|
}
|
|
}
|