

class EControlModel {
  int? id;
  String? name;
  Location? location;
  Contact? contact;
  List<OpeningHours>? openingHours;
  OfferInformation? offerInformation;
  PaymentMethods? paymentMethods;
  PaymentArrangements? paymentArrangements;
  int? position;
  bool? open;
  double? distance;
  List<Prices>? prices;

  EControlModel(
      {this.id,
      this.name,
      this.location,
      this.contact,
      this.openingHours,
      this.offerInformation,
      this.paymentMethods,
      this.paymentArrangements,
      this.position,
      this.open,
      this.distance,
      this.prices});

  EControlModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    location = json['location'] != null
        ? Location.fromJson(json['location'])
        : null;
    contact =
        json['contact'] != null ? Contact.fromJson(json['contact']) : null;
    if (json['openingHours'] != null) {
      openingHours = <OpeningHours>[];
      json['openingHours'].forEach((v) {
        openingHours!.add(OpeningHours.fromJson(v));
      });
    }
    offerInformation = json['offerInformation'] != null
        ? OfferInformation.fromJson(json['offerInformation'])
        : null;
    paymentMethods = json['paymentMethods'] != null
        ? PaymentMethods.fromJson(json['paymentMethods'])
        : null;
    paymentArrangements = json['paymentArrangements'] != null
        ? PaymentArrangements.fromJson(json['paymentArrangements'])
        : null;
    position = json['position'];
    open = json['open'];
    distance = json['distance'];
    if (json['prices'] != null) {
      prices = <Prices>[];
      json['prices'].forEach((v) {
        prices!.add(Prices.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    if (location != null) {
      data['location'] = location!.toJson();
    }
    if (contact != null) {
      data['contact'] = contact!.toJson();
    }
    if (openingHours != null) {
      data['openingHours'] = openingHours!.map((v) => v.toJson()).toList();
    }
    if (offerInformation != null) {
      data['offerInformation'] = offerInformation!.toJson();
    }
    if (paymentMethods != null) {
      data['paymentMethods'] = paymentMethods!.toJson();
    }
    if (paymentArrangements != null) {
      data['paymentArrangements'] = paymentArrangements!.toJson();
    }
    data['position'] = position;
    data['open'] = open;
    data['distance'] = distance;
    if (prices != null) {
      data['prices'] = prices!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Location {
  String? address;
  String? postalCode;
  String? city;
  double? latitude;
  double? longitude;

  Location(
      {this.address,
      this.postalCode,
      this.city,
      this.latitude,
      this.longitude});

  Location.fromJson(Map<String, dynamic> json) {
    address = json['address'];
    postalCode = json['postalCode'];
    city = json['city'];
    latitude = json['latitude'];
    longitude = json['longitude'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['address'] = address;
    data['postalCode'] = postalCode;
    data['city'] = city;
    data['latitude'] = latitude;
    data['longitude'] = longitude;
    return data;
  }
}

class Contact {
  String? telephone;
  String? fax;
  String? mail;
  String? website;

  Contact({this.telephone, this.fax, this.mail, this.website});

  Contact.fromJson(Map<String, dynamic> json) {
    telephone = json['telephone'];
    fax = json['fax'];
    mail = json['mail'];
    website = json['website'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['telephone'] = telephone;
    data['fax'] = fax;
    data['mail'] = mail;
    data['website'] = website;
    return data;
  }
}

class OpeningHours {
  String? day;
  String? label;
  int? order;
  String? from;
  String? to;

  OpeningHours({this.day, this.label, this.order, this.from, this.to});

  OpeningHours.fromJson(Map<String, dynamic> json) {
    day = json['day'];
    label = json['label'];
    order = json['order'];
    from = json['from'];
    to = json['to'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['day'] = day;
    data['label'] = label;
    data['order'] = order;
    data['from'] = from;
    data['to'] = to;
    return data;
  }
}

class OfferInformation {
  bool? service;
  bool? selfService;
  bool? unattended;

  OfferInformation({this.service, this.selfService, this.unattended});

  OfferInformation.fromJson(Map<String, dynamic> json) {
    service = json['service'];
    selfService = json['selfService'];
    unattended = json['unattended'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['service'] = service;
    data['selfService'] = selfService;
    data['unattended'] = unattended;
    return data;
  }
}

class PaymentMethods {
  bool? cash;
  bool? debitCard;
  bool? creditCard;
  String? others;

  PaymentMethods({this.cash, this.debitCard, this.creditCard, this.others});

  PaymentMethods.fromJson(Map<String, dynamic> json) {
    cash = json['cash'];
    debitCard = json['debitCard'];
    creditCard = json['creditCard'];
    others = json['others'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['cash'] = cash;
    data['debitCard'] = debitCard;
    data['creditCard'] = creditCard;
    data['others'] = others;
    return data;
  }
}

class PaymentArrangements {
  bool? cooperative;
  bool? clubCard;

  PaymentArrangements({this.cooperative, this.clubCard});

  PaymentArrangements.fromJson(Map<String, dynamic> json) {
    cooperative = json['cooperative'];
    clubCard = json['clubCard'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['cooperative'] = cooperative;
    data['clubCard'] = clubCard;
    return data;
  }
}

class Prices {
  String? fuelType;
  double? amount;
  String? label;

  Prices({this.fuelType, this.amount, this.label});

  Prices.fromJson(Map<String, dynamic> json) {
    fuelType = json['fuelType'];
    amount = json['amount'];
    label = json['label'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['fuelType'] = fuelType;
    data['amount'] = amount;
    data['label'] = label;
    return data;
  }
}
