278 lines
7.4 KiB
Dart
278 lines
7.4 KiB
Dart
import 'dart:convert';
|
|
|
|
/// ---------- MAIN RESPONSE ----------
|
|
MyPassesCartModel myPassesCartModelFromJson(String str) =>
|
|
MyPassesCartModel.fromJson(json.decode(str));
|
|
|
|
String myPassesCartModelToJson(MyPassesCartModel data) =>
|
|
json.encode(data.toJson());
|
|
|
|
class MyPassesCartModel {
|
|
CartCity city;
|
|
List<CartItem> cartItems;
|
|
|
|
MyPassesCartModel({
|
|
required this.city,
|
|
required this.cartItems,
|
|
});
|
|
|
|
factory MyPassesCartModel.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
|
|
return MyPassesCartModel(
|
|
city: CartCity.fromJson(json['city']),
|
|
cartItems: json['cartItems'] == null
|
|
? []
|
|
: List<Map<String, dynamic>>.from(json['cartItems'])
|
|
.map((e) => CartItem.fromJson(e))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"city": city.toJson(),
|
|
"cartItems": cartItems.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|
|
|
|
/// ---------- TOP LEVEL CITY ----------
|
|
class CartCity {
|
|
int id;
|
|
String name;
|
|
String bannerImage;
|
|
|
|
CartCity({
|
|
required this.id,
|
|
required this.name,
|
|
required this.bannerImage,
|
|
});
|
|
|
|
factory CartCity.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
|
|
return CartCity(
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
|
name: json['name']?.toString() ?? "",
|
|
bannerImage: json['bannerImage']?.toString() ?? "",
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"name": name,
|
|
"bannerImage": bannerImage,
|
|
};
|
|
}
|
|
|
|
/// ---------- CART ITEM ----------
|
|
class CartItem {
|
|
int id;
|
|
String bookingNumber;
|
|
String cardMode;
|
|
String displayCardMode;
|
|
int noOfDays;
|
|
int noOfAttractions;
|
|
int totalAdult;
|
|
int totalChild;
|
|
num baseAmount;
|
|
num totalTaxAmount;
|
|
num totalAmount;
|
|
String bookingStatus;
|
|
bool isForSelf;
|
|
|
|
String recipientFirstName;
|
|
String recipientLastName;
|
|
String recipientEmail;
|
|
String recipientPhone;
|
|
String recipientCity;
|
|
String recipientCountry;
|
|
String giftMessage;
|
|
|
|
bool isPaymentRequired;
|
|
int couponXid;
|
|
num couponDiscountAmount;
|
|
num couponDiscountPercent;
|
|
String paymentStatus;
|
|
String createdAt;
|
|
|
|
Coupon? coupon;
|
|
ItemCity city;
|
|
|
|
CartItem({
|
|
required this.id,
|
|
required this.bookingNumber,
|
|
required this.cardMode,
|
|
required this.displayCardMode,
|
|
required this.noOfDays,
|
|
required this.noOfAttractions,
|
|
required this.totalAdult,
|
|
required this.totalChild,
|
|
required this.baseAmount,
|
|
required this.totalTaxAmount,
|
|
required this.totalAmount,
|
|
required this.bookingStatus,
|
|
required this.isForSelf,
|
|
required this.recipientFirstName,
|
|
required this.recipientLastName,
|
|
required this.recipientEmail,
|
|
required this.recipientPhone,
|
|
required this.recipientCity,
|
|
required this.recipientCountry,
|
|
required this.giftMessage,
|
|
required this.isPaymentRequired,
|
|
required this.couponXid,
|
|
required this.couponDiscountAmount,
|
|
required this.couponDiscountPercent,
|
|
required this.paymentStatus,
|
|
required this.createdAt,
|
|
required this.coupon,
|
|
required this.city,
|
|
});
|
|
|
|
factory CartItem.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
|
|
return CartItem(
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
|
bookingNumber: json['bookingNumber']?.toString() ?? "",
|
|
cardMode: json['cardMode']?.toString() ?? "",
|
|
displayCardMode: json['displayCardMode']?.toString() ?? "",
|
|
noOfDays: (json['noOfDays'] as num?)?.toInt() ?? 0,
|
|
noOfAttractions: (json['noOfAttractions'] as num?)?.toInt() ?? 0,
|
|
totalAdult: (json['totalAdult'] as num?)?.toInt() ?? 0,
|
|
totalChild: (json['totalChild'] as num?)?.toInt() ?? 0,
|
|
baseAmount: json['baseAmount'] ?? 0,
|
|
totalTaxAmount: json['totalTaxAmount'] ?? 0,
|
|
totalAmount: json['totalAmount'] ?? 0,
|
|
bookingStatus: json['bookingStatus']?.toString() ?? "",
|
|
isForSelf: json['isForSelf'] ?? false,
|
|
recipientFirstName: json['recipientFirstName']?.toString() ?? "",
|
|
recipientLastName: json['recipientLastName']?.toString() ?? "",
|
|
recipientEmail: json['recipientEmail']?.toString() ?? "",
|
|
recipientPhone: json['recipientPhone']?.toString() ?? "",
|
|
recipientCity: json['recipientCity']?.toString() ?? "",
|
|
recipientCountry: json['recipientCountry']?.toString() ?? "",
|
|
giftMessage: json['giftMessage']?.toString() ?? "",
|
|
isPaymentRequired: json['isPaymentRequired'] ?? false,
|
|
couponXid: (json['couponXid'] as num?)?.toInt() ?? 0,
|
|
couponDiscountAmount: json['couponDiscountAmount'] ?? 0,
|
|
couponDiscountPercent: json['couponDiscountPercent'] ?? 0,
|
|
paymentStatus: json['paymentStatus']?.toString() ?? "",
|
|
createdAt: json['createdAt']?.toString() ?? "",
|
|
coupon:
|
|
json['coupon'] == null ? null : Coupon.fromJson(json['coupon']),
|
|
city: ItemCity.fromJson(json['city']),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"bookingNumber": bookingNumber,
|
|
"cardMode": cardMode,
|
|
"displayCardMode": displayCardMode,
|
|
"noOfDays": noOfDays,
|
|
"noOfAttractions": noOfAttractions,
|
|
"totalAdult": totalAdult,
|
|
"totalChild": totalChild,
|
|
"baseAmount": baseAmount,
|
|
"totalTaxAmount": totalTaxAmount,
|
|
"totalAmount": totalAmount,
|
|
"bookingStatus": bookingStatus,
|
|
"isForSelf": isForSelf,
|
|
"recipientFirstName": recipientFirstName,
|
|
"recipientLastName": recipientLastName,
|
|
"recipientEmail": recipientEmail,
|
|
"recipientPhone": recipientPhone,
|
|
"recipientCity": recipientCity,
|
|
"recipientCountry": recipientCountry,
|
|
"giftMessage": giftMessage,
|
|
"isPaymentRequired": isPaymentRequired,
|
|
"couponXid": couponXid,
|
|
"couponDiscountAmount": couponDiscountAmount,
|
|
"couponDiscountPercent": couponDiscountPercent,
|
|
"paymentStatus": paymentStatus,
|
|
"createdAt": createdAt,
|
|
"coupon": coupon?.toJson(),
|
|
"city": city.toJson(),
|
|
};
|
|
}
|
|
|
|
/// ---------- COUPON ----------
|
|
class Coupon {
|
|
int id;
|
|
String couponCode;
|
|
String title;
|
|
|
|
Coupon({
|
|
required this.id,
|
|
required this.couponCode,
|
|
required this.title,
|
|
});
|
|
|
|
factory Coupon.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
return Coupon(
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
|
couponCode: json['couponCode']?.toString() ?? "",
|
|
title: json['title']?.toString() ?? "",
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"couponCode": couponCode,
|
|
"title": title,
|
|
};
|
|
}
|
|
|
|
/// ---------- ITEM CITY ----------
|
|
class ItemCity {
|
|
int id;
|
|
String cityName;
|
|
List<CityBanner> cityBanners;
|
|
|
|
ItemCity({
|
|
required this.id,
|
|
required this.cityName,
|
|
required this.cityBanners,
|
|
});
|
|
|
|
factory ItemCity.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
|
|
return ItemCity(
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
|
cityName: json['cityName']?.toString() ?? "",
|
|
cityBanners: json['cityBanners'] == null
|
|
? []
|
|
: List<Map<String, dynamic>>.from(json['cityBanners'])
|
|
.map((e) => CityBanner.fromJson(e))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"cityName": cityName,
|
|
"cityBanners": cityBanners.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|
|
|
|
/// ---------- CITY BANNER ----------
|
|
class CityBanner {
|
|
String imageFilePath;
|
|
|
|
CityBanner({required this.imageFilePath});
|
|
|
|
factory CityBanner.fromJson(Map<String, dynamic>? json) {
|
|
json ??= {};
|
|
return CityBanner(
|
|
imageFilePath: json['imageFilePath']?.toString() ?? "",
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"imageFilePath": imageFilePath,
|
|
};
|
|
}
|