Untitled
unknown
dart
3 years ago
6.5 kB
5
Indexable
import 'package:iketfaa_delivery/App/Delivery/Models/Main/OrderAddress.dart'; import 'package:iketfaa_delivery/App/Delivery/Models/Main/OrderCanceled.dart'; class Cart { String? orderID; int? paymentType, orderType, orderStatus; String? customerName, customerID, customerMobileNumber, offerID; OrderAddress? customerAddress; OrderCanceled? orderCanceled; double? firstEstimatePrice, secondEstimatePrice, rate, totalPrice; List<StoreOrder>? orders; bool? arrived, moneyReceived; DateTime? date; Cart( {this.customerID, this.customerName, this.customerAddress, this.customerMobileNumber, this.orderStatus, this.orders, this.orderType, this.orderID, this.paymentType, this.firstEstimatePrice, this.secondEstimatePrice, this.rate, this.totalPrice, this.arrived, this.moneyReceived, this.offerID, this.orderCanceled, this.date}); Cart.fromJson(Map<String, dynamic> json) { orderType = json['orderType']; orderID = json['orderID']; offerID = json['offerID']; customerID = json['customerID']; customerName = json['customerName']; customerMobileNumber = json['customerMobileNumber']; customerAddress = json['customerAddress'] == null ? null : OrderAddress.fromMap(json['customerAddress']); orderStatus = json['orderStatus']; paymentType = json['paymentType']; if (json['orders'] != null) { orders = <StoreOrder>[]; json['orders'].forEach((v) { orders!.add(new StoreOrder.fromJson(v)); }); } firstEstimatePrice = json['firstEstimatePrice']; secondEstimatePrice = json['secondEstimatePrice']; rate = json['rate'] == null ? null : json['rate'].toDouble(); totalPrice = json['totalPrice']; arrived = json['arrived']; moneyReceived = json['moneyReceived']; orderCanceled = json['orderCanceled'] == null ? null : OrderCanceled.fromJson(json['orderCanceled']); date = json['date'] == null ? json['date'] : json['date'].toString().contains(':') ? json['date'] : json['date'].toDate(); } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['orderType'] = this.orderType; data['orderID'] = this.orderID; data['offerID'] = this.offerID; data['customerID'] = this.customerID; data['customerName'] = this.customerName; data['customerAddress'] = this.customerAddress == null ? null : this.customerAddress!.toMap(); data['customerMobileNumber'] = this.customerMobileNumber; data['orderStatus'] = this.orderStatus; data['paymentType'] = this.paymentType; if (this.orders!.isNotEmpty) { data['orders'] = this.orders!.map((v) => v.toJson()).toList(); } data['firstEstimatePrice'] = this.firstEstimatePrice; data['secondEstimatePrice'] = this.secondEstimatePrice; data['rate'] = this.rate; data['totalPrice'] = this.totalPrice; data['arrived'] = this.arrived; data['moneyReceived'] = this.moneyReceived; data['orderCanceled'] = this.orderCanceled; data['date'] = this.date; return data; } } class StoreOrder { String? storeID; String? storeName; String? storeCategory; String? storeImageRef; String? reason; double? rating; int? storeType; StoreLocation? storeLocation; List<String>? images; List<OrderItem>? orderItems; bool? done; StoreOrder( {this.storeID, this.storeName, this.storeCategory, this.storeImageRef, this.storeLocation, this.reason, this.images, this.orderItems, this.storeType, this.rating, this.done}); StoreOrder.fromJson(Map<String, dynamic> json) { storeID = json['storeID']; storeName = json['storeName']; storeCategory = json['storeCategory']; storeImageRef = json['storeImageRef']; storeLocation = StoreLocation.fromJson(json['storeLocation']); reason = json['reason']; images = json['images'].cast<String>(); storeType = json['storeType']; rating = json['rating']; if (json['orderItems'] != null) { orderItems = <OrderItem>[]; json['orderItems'].forEach((v) { orderItems!.add(new OrderItem.fromJson(v)); }); } done = json['done']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['storeID'] = this.storeID; data['storeName'] = this.storeName; data['storeCategory'] = this.storeCategory; data['storeImageRef'] = this.storeImageRef; data['storeLocation'] = this.storeLocation!.toJson(); data['reason'] = this.reason; data['images'] = this.images; data['storeType'] = this.storeType; data['rating'] = this.rating; if (this.orderItems!.isNotEmpty) { data['orderItems'] = this.orderItems!.map((v) => v.toJson()).toList(); } data['done'] = this.done; return data; } } class StoreLocation { double? lat; double? lng; String? street; String? city; double? distanceFromUser; StoreLocation( {this.lat, this.lng, this.street, this.city, this.distanceFromUser}); StoreLocation.fromJson(Map<String, dynamic> json) { lat = json['lat']; lng = json['lng']; street = json['street']; city = json['city']; distanceFromUser = json['distanceFromUser']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['lat'] = this.lat; data['lng'] = this.lng; data['street'] = this.street; data['city'] = this.city; data['distanceFromUser'] = this.distanceFromUser; return data; } } class OrderImage { late String url; OrderImage({required this.url}); OrderImage.fromJson(Map<String, dynamic> json) { url = json['url']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['url'] = this.url; return data; } } class OrderItem { late String description; late int quantity; OrderItem({required this.description, required this.quantity}); OrderItem.fromJson(Map<String, dynamic> json) { description = json['description']; quantity = json['quantity']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['description'] = this.description; data['quantity'] = this.quantity; return data; } }
Editor is loading...