// To parse this JSON data, do
//
//     final locationModel = locationModelFromJson(jsonString);

import 'dart:convert';

List<LocationModel> locationModelFromJson(String str) => List<LocationModel>.from(json.decode(str).map((x) => LocationModel.fromJson(x)));

String locationModelToJson(List<LocationModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class LocationModel {
  LocationModel({
    this.expiryDate,
    this.sellingPrice,
    this.quantity,
    this.itemId,
    this.locationId,
    this.projectId,
    this.setupId,
    this.locationDescription,
    this.locationDescriptionN,
    this.itemDescription,
    this.itemDescriptionN,
    this.alias,
    this.locationTypeId,
    this.barcode,
    this.companybarcode,
    this.cityId,
    this.cityName,
    this.distanceInKilometers,
    this.latitude,
    this.locationType,
    this.longitude,
    this.phoneNumber,
    this.projectImageUrl,
    this.sortOrder,
  });

  ExpiryDate expiryDate;
  double sellingPrice;
  int quantity;
  int itemId;
  int locationId;
  int projectId;
  String setupId;
  String locationDescription;
  dynamic locationDescriptionN;
  ItemDescription itemDescription;
  dynamic itemDescriptionN;
  Alias alias;
  int locationTypeId;
  int barcode;
  dynamic companybarcode;
  int cityId;
  CityName cityName;
  int distanceInKilometers;
  String latitude;
  int locationType;
  String longitude;
  String phoneNumber;
  String projectImageUrl;
  int sortOrder;

  factory LocationModel.fromJson(Map<String, dynamic> json) => LocationModel(
    expiryDate: expiryDateValues.map[json["ExpiryDate"]],
    sellingPrice: json["SellingPrice"].toDouble(),
    quantity: json["Quantity"],
    itemId: json["ItemID"],
    locationId: json["LocationID"],
    projectId: json["ProjectID"],
    setupId: json["SetupID"],
    locationDescription: json["LocationDescription"],
    locationDescriptionN: json["LocationDescriptionN"],
    itemDescription: itemDescriptionValues.map[json["ItemDescription"]],
    itemDescriptionN: json["ItemDescriptionN"],
    alias: aliasValues.map[json["Alias"]],
    locationTypeId: json["LocationTypeID"],
    barcode: json["Barcode"],
    companybarcode: json["Companybarcode"],
    cityId: json["CityID"],
    cityName: cityNameValues.map[json["CityName"]],
    distanceInKilometers: json["DistanceInKilometers"],
    latitude: json["Latitude"],
    locationType: json["LocationType"],
    longitude: json["Longitude"],
    phoneNumber: json["PhoneNumber"],
    projectImageUrl: json["ProjectImageURL"],
    sortOrder: json["SortOrder"],
  );

  Map<String, dynamic> toJson() => {
    "ExpiryDate": expiryDateValues.reverse[expiryDate],
    "SellingPrice": sellingPrice,
    "Quantity": quantity,
    "ItemID": itemId,
    "LocationID": locationId,
    "ProjectID": projectId,
    "SetupID": setupId,
    "LocationDescription": locationDescription,
    "LocationDescriptionN": locationDescriptionN,
    "ItemDescription": itemDescriptionValues.reverse[itemDescription],
    "ItemDescriptionN": itemDescriptionN,
    "Alias": aliasValues.reverse[alias],
    "LocationTypeID": locationTypeId,
    "Barcode": barcode,
    "Companybarcode": companybarcode,
    "CityID": cityId,
    "CityName": cityNameValues.reverse[cityName],
    "DistanceInKilometers": distanceInKilometers,
    "Latitude": latitude,
    "LocationType": locationType,
    "Longitude": longitude,
    "PhoneNumber": phoneNumber,
    "ProjectImageURL": projectImageUrl,
    "SortOrder": sortOrder,
  };
}

enum Alias { CAPSULE }

final aliasValues = EnumValues({
  "CAPSULE": Alias.CAPSULE
});

enum CityName { RIYADH, KHOBAR, QASSIM }

final cityNameValues = EnumValues({
  "Khobar": CityName.KHOBAR,
  "Qassim": CityName.QASSIM,
  "Riyadh": CityName.RIYADH
});

enum ExpiryDate { DATE_16223220000000300, DATE_16250004000000300, DATE_16538580000000300 }

final expiryDateValues = EnumValues({
  "/Date(1622322000000+0300)/": ExpiryDate.DATE_16223220000000300,
  "/Date(1625000400000+0300)/": ExpiryDate.DATE_16250004000000300,
  "/Date(1653858000000+0300)/": ExpiryDate.DATE_16538580000000300
});

enum ItemDescription { XERACTAN_20_MG_CAP_30_S }

final itemDescriptionValues = EnumValues({
  "XERACTAN 20 MG CAP 30'S": ItemDescription.XERACTAN_20_MG_CAP_30_S
});

class EnumValues<T> {
  Map<String, T> map;
  Map<T, String> reverseMap;

  EnumValues(this.map);

  Map<T, String> get reverse {
    if (reverseMap == null) {
      reverseMap = map.map((k, v) => new MapEntry(v, k));
    }
    return reverseMap;
  }
}
