import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/enums.dart';

class ShippingRequestModel {
  int? id;
  int? requestID;
  Request? request;
  int? shippingStatus;
  ShippingRequestStatusEnum? shippingStatusEnum;
  String? deliveredOn;
  String? comment;
  String? createdOn;
  int? customerID;
  String? customerName;

  ShippingRequestModel({this.id, this.requestID, this.request, this.shippingStatus, this.deliveredOn, this.comment, this.createdOn, this.customerID, this.customerName});

  ShippingRequestModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    requestID = json['requestID'];
    request = json['request'] != null ? Request.fromJson(json['request']) : null;
    shippingStatus = json['shippingStatus'];
    shippingStatusEnum = json['shippingStatus'] != null ? (json['shippingStatus'] as int).toShippingStatusEnum() : ShippingRequestStatusEnum.initiated;
    deliveredOn = json['deliveredOn'];
    comment = json['comment'];
    createdOn = json['createdOn'];
    customerID = json['customerID'];
    customerName = json['customerName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['requestID'] = requestID;
    if (request != null) {
      data['request'] = request!.toJson();
    }
    data['shippingStatus'] = shippingStatus;
    data['deliveredOn'] = deliveredOn;
    data['comment'] = comment;
    data['createdOn'] = createdOn;
    data['customerID'] = customerID;
    data['customerName'] = customerName;
    return data;
  }
}

class Request {
  int? requestType;
  String? brand;
  String? model;
  int? year;
  bool? isNew;
  String? description;
  double? price;

  Request({this.requestType, this.brand, this.model, this.year, this.isNew, this.description, this.price});

  Request.fromJson(Map<String, dynamic> json) {
    requestType = json['requestType'];
    brand = json['brand'];
    model = json['model'];
    year = json['year'];
    isNew = json['isNew'];
    description = json['description'];
    price = json['price'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['requestType'] = requestType;
    data['brand'] = brand;
    data['model'] = model;
    data['year'] = year;
    data['isNew'] = isNew;
    data['description'] = description;
    data['price'] = price;
    return data;
  }
}
