You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_common_app/lib/models/advertisment_models/ad_details_model.dart

412 lines
11 KiB
Dart

import 'dart:math';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/advertisment_models/special_service_model.dart';
import 'package:mc_common_app/utils/enums.dart';
class AdDetailsModel {
int? id;
String? startdate;
String? enddate;
Vehicle? vehicle;
List<SpecialServiceModelForAds>? specialservice;
// List<Null>? reserved;
int? statusID;
String? statuslabel;
double? adsDurationPrice;
double? adsDurationDiscount;
double? adsDurationDiscountPrice;
String? comment;
bool? active;
bool? isPaid;
bool? isSubscription;
bool? isVerified;
double? netPrice;
double? specialServiceTotalPrice;
double? taxPrice;
double? totalPrice;
String? userID;
int? vehiclePostingID;
String? qrCodePath;
bool? isCustomerAcknowledged;
int? createdByRole;
int? totalViews;
String? createdOn;
double? priceExcludingDiscount;
double? reservePrice;
bool? isMCHandled;
String? modifiedOn;
AdPostStatus? adPostStatus;
AdReserveStatus? adReserveStatus;
bool? isMyAd;
bool? isReservedByMe;
String? phoneNo;
String? whatsAppNo;
CreatedByRoleEnum? createdByRoleEnum;
AdDetailsModel(
{this.id,
this.startdate,
this.enddate,
this.vehicle,
this.specialservice,
// this.reserved,
this.statusID,
this.statuslabel,
this.adsDurationPrice,
this.adsDurationDiscount,
this.adsDurationDiscountPrice,
this.comment,
this.active,
this.isPaid,
this.isSubscription,
this.isVerified,
this.netPrice,
this.specialServiceTotalPrice,
this.taxPrice,
this.totalPrice,
this.userID,
this.vehiclePostingID,
this.qrCodePath,
this.isCustomerAcknowledged,
this.createdByRole,
this.totalViews,
this.createdOn,
this.priceExcludingDiscount,
this.reservePrice,
this.isMCHandled,
this.adPostStatus,
this.adReserveStatus,
this.isMyAd,
this.isReservedByMe,
this.phoneNo,
this.whatsAppNo,
this.createdByRoleEnum,
this.modifiedOn});
int getRandomValue({required int min, required int max}) {
Random random = Random();
int randomNumber = random.nextInt(max - min);
return randomNumber;
}
AdDetailsModel.fromJson(Map<String, dynamic> json, bool isMyAds) {
id = json['id'];
startdate = json['startdate'];
enddate = json['enddate'];
vehicle = json['vehicle'] != null ? Vehicle.fromJson(json['vehicle']) : null;
if (json['specialservice'] != null) {
specialservice = <SpecialServiceModelForAds>[];
json['specialservice'].forEach((v) {
specialservice!.add(SpecialServiceModelForAds.fromJson(v));
});
}
statusID = json['statusID'];
statuslabel = json['statuslabel'];
adsDurationPrice = json['adsDurationPrice'];
adsDurationDiscount = json['adsDurationDiscount'];
adsDurationDiscountPrice = json['adsDurationDiscountPrice'];
comment = json['comment'];
active = json['active'];
isPaid = json['isPaid'];
isSubscription = json['isSubscription'];
isVerified = json['isVerified'];
netPrice = json['netPrice'];
specialServiceTotalPrice = json['specialServiceTotalPrice'];
taxPrice = json['taxPrice'];
totalPrice = json['totalPrice'];
userID = json['userID'];
vehiclePostingID = json['vehiclePostingID'];
qrCodePath = json['qrCodePath'];
isCustomerAcknowledged = json['isCustomerAcknowledged'];
createdByRole = json['createdByRole'];
totalViews = json['totalViews'];
createdOn = json['createdOn'];
priceExcludingDiscount = json['priceExcludingDiscount'];
reservePrice = json['reservePrice'];
isMCHandled = json['isMCHandled'];
modifiedOn = json['modifiedOn'];
whatsAppNo = json['phoneNo'];
modifiedOn = json['whatsAppNo'];
// adPostStatus = AdPostStatus.expired;
adPostStatus = (json['statusID'] as int).toAdPostEnum();
//TODO: THIS ID SHOULD BE UPDATED!
adReserveStatus = AdReserveStatus.defaultStatus;
// createdByRoleEnum = CreatedByRoleEnum.admin;
createdByRoleEnum = (json['createdByRole'] as int).toCreatedByRoleEnum();
isMyAd = isMyAds;
isReservedByMe = false;
}
}
class Vehicle {
int? id;
int? cityID;
String? cityName;
double? demandAmount;
bool? isActive;
bool? isFinanceAvailable;
int? status;
String? statustext;
Category? category;
Category? color;
Condition? condition;
Mileage? mileage;
Condition? model;
ModelYear? modelyear;
Condition? sellertype;
Condition? transmission;
Duration? duration;
List<AdImage>? image;
List<DamageReport>? damagereport;
String? vehicleDescription;
String? vehicleTitle;
int? vehicleType;
String? vehicleVIN;
int? countryID;
String? currency;
Vehicle(
{this.id,
this.cityID,
this.cityName,
this.demandAmount,
this.isActive,
this.isFinanceAvailable,
this.status,
this.statustext,
this.category,
this.color,
this.condition,
this.mileage,
this.model,
this.modelyear,
this.sellertype,
this.transmission,
this.duration,
this.image,
this.damagereport,
this.vehicleDescription,
this.vehicleTitle,
this.vehicleType,
this.vehicleVIN,
this.countryID,
this.currency});
Vehicle.fromJson(Map<String, dynamic> json) {
id = json['id'];
cityID = json['cityID'];
cityName = json['cityName'];
demandAmount = json['demandAmount'];
isActive = json['isActive'];
isFinanceAvailable = json['isFinanceAvailable'];
status = json['status'];
statustext = json['statustext'];
category = json['category'] != null ? Category.fromJson(json['category']) : null;
color = json['color'] != null ? Category.fromJson(json['color']) : null;
condition = json['condition'] != null ? Condition.fromJson(json['condition']) : null;
mileage = json['mileage'] != null ? Mileage.fromJson(json['mileage']) : null;
model = json['model'] != null ? Condition.fromJson(json['model']) : null;
modelyear = json['modelyear'] != null ? ModelYear.fromJson(json['modelyear']) : null;
sellertype = json['sellertype'] != null ? Condition.fromJson(json['sellertype']) : null;
transmission = json['transmission'] != null ? Condition.fromJson(json['transmission']) : null;
duration = json['duration'] != null ? Duration.fromJson(json['duration']) : null;
if (json['image'] != null) {
image = <AdImage>[];
json['image'].forEach((v) {
image!.add(AdImage.fromJson(v));
});
}
if (json['damagereport'] != null) {
damagereport = <DamageReport>[];
json['damagereport'].forEach((v) {
damagereport!.add(DamageReport.fromJson(v));
});
}
vehicleDescription = json['vehicleDescription'];
vehicleTitle = json['vehicleTitle'];
vehicleType = json['vehicleType'];
vehicleVIN = json['vehicleVIN'];
countryID = json['countryID'];
currency = json['currency'];
}
}
class Category {
int? id;
String? label;
String? labelN;
bool? isActive;
Category({this.id, this.label, this.labelN, this.isActive});
Category.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
labelN = json['labelN'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['labelN'] = labelN;
data['isActive'] = isActive;
return data;
}
}
class Condition {
int? id;
String? label;
String? labelN;
Condition({this.id, this.label, this.labelN});
Condition.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
labelN = json['labelN'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['labelN'] = labelN;
return data;
}
}
class Mileage {
int? id;
String? mileageStart;
String? mileageEnd;
String? label;
Mileage({this.id, this.mileageStart, this.mileageEnd, this.label});
Mileage.fromJson(Map<String, dynamic> json) {
id = json['id'];
mileageStart = json['mileageStart'];
mileageEnd = json['mileageEnd'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['mileageStart'] = mileageStart;
data['mileageEnd'] = mileageEnd;
data['label'] = label;
return data;
}
}
class ModelYear {
int? id;
String? label;
ModelYear({this.id, this.label});
ModelYear.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
return data;
}
}
class Duration {
int? id;
String? label;
int? days;
double? price;
ModelYear? country;
Duration({this.id, this.label, this.days, this.price, this.country});
Duration.fromJson(Map<String, dynamic> json) {
id = json['id'];
label = json['label'];
days = json['days'];
price = json['price'];
country = json['country'] != null ? ModelYear.fromJson(json['country']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['label'] = label;
data['days'] = days;
data['price'] = price;
if (country != null) {
data['country'] = country!.toJson();
}
return data;
}
}
class AdImage {
int? id;
String? imageName;
String? imageUrl;
bool? isActive;
AdImage({this.id, this.imageName, this.imageUrl, this.isActive});
AdImage.fromJson(Map<String, dynamic> json) {
id = json['id'];
imageName = json['imageName'];
imageUrl = json['imageUrl'];
isActive = json['isActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['imageName'] = imageName;
data['imageUrl'] = imageUrl;
data['isActive'] = isActive;
return data;
}
}
class DamageReport {
int? id;
String? comment;
String? imageUrl;
bool? isActive;
int? vehicleDamagePartID;
String? partName;
DamageReport({this.id, this.comment, this.imageUrl, this.isActive, this.vehicleDamagePartID, this.partName});
DamageReport.fromJson(Map<String, dynamic> json) {
id = json['id'];
comment = json['comment'];
imageUrl = json['imageUrl'];
isActive = json['isActive'];
vehicleDamagePartID = json['vehicleDamagePartID'];
partName = json['partName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['comment'] = comment;
data['imageUrl'] = imageUrl;
data['isActive'] = isActive;
data['vehicleDamagePartID'] = vehicleDamagePartID;
data['partName'] = partName;
return data;
}
}