
import 'dart:convert';

import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyImageObject.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

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

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

class OrderModel {

  String id;
  dynamic storeId;
  String orderGuid;
  bool pickUpInStore;
  PaymentMethodSystemName paymentMethodSystemName;
  PaymentName paymentName;
  PaymentName paymentNamen;
  CustomerCurrencyCode customerCurrencyCode;
  dynamic currencyRate;
  dynamic customerTaxDisplayTypeId;
  dynamic vatNumber;
  double orderSubtotalInclTax;
  double orderSubtotalExclTax;
  dynamic orderSubTotalDiscountInclTax;
  dynamic orderSubTotalDiscountExclTax;
  double orderShippingInclTax;
  dynamic orderShippingExclTax;
  dynamic paymentMethodAdditionalFeeInclTax;
  dynamic paymentMethodAdditionalFeeExclTax;
  String taxRates;
  double orderTax;
  dynamic orderDiscount;
  dynamic productCount;
  double orderTotal;
  dynamic refundedAmount;
  dynamic rewardPointsWereAdded;
  String rxAttachments;
  CheckoutAttributeDescription checkoutAttributeDescription;
  dynamic customerLanguageId;
  dynamic affiliateId;
  CustomerIp customerIp;
  String authorizationTransactionId;
  dynamic authorizationTransactionCode;
  dynamic authorizationTransactionResult;
  dynamic captureTransactionId;
  dynamic captureTransactionResult;
  dynamic subscriptionTransactionId;
  DateTime paidDateUtc;
  ShippingMethod shippingMethod;
  ShippingRateComputationMethodSystemName shippingRateComputationMethodSystemName;
  String customValuesXml;
  bool deleted;
  DateTime createdOnUtc;
  OrderModelCustomer customer;
  dynamic customerId;
  IngAddress billingAddress;
  IngAddress shippingAddress;
  List<OrderItem> orderItems;
  dynamic orderStatusId;
  OrderStatus orderStatus;
  OrderStatusn orderStatusn;
  dynamic paymentStatusId;
  PaymentStatus paymentStatus;
  PaymentStatusn paymentStatusn;
  ShippingStatus shippingStatus;
  ShippingStatusn shippingStatusn;
  CustomerTaxDisplayType customerTaxDisplayType;
  bool canCancel;
  bool canRefund;
  dynamic lakumAmount;
  DateTime preferDeliveryDate;
  PreferDeliveryTime preferDeliveryTime;
  PreferDeliveryTimen preferDeliveryTimen;
  String driverOTP;
  String driverID;

  OrderModel({
    this.id,
    this.storeId,
    this.orderGuid,
    this.pickUpInStore,
    this.paymentMethodSystemName,
    this.paymentName,
    this.paymentNamen,
    this.customerCurrencyCode,
    this.currencyRate,
    this.customerTaxDisplayTypeId,
    this.vatNumber,
    this.orderSubtotalInclTax,
    this.orderSubtotalExclTax,
    this.orderSubTotalDiscountInclTax,
    this.orderSubTotalDiscountExclTax,
    this.orderShippingInclTax,
    this.orderShippingExclTax,
    this.paymentMethodAdditionalFeeInclTax,
    this.paymentMethodAdditionalFeeExclTax,
    this.taxRates,
    this.orderTax,
    this.orderDiscount,
    this.productCount,
    this.orderTotal,
    this.refundedAmount,
    this.rewardPointsWereAdded,
    this.rxAttachments,
    this.checkoutAttributeDescription,
    this.customerLanguageId,
    this.affiliateId,
    this.customerIp,
    this.authorizationTransactionId,
    this.authorizationTransactionCode,
    this.authorizationTransactionResult,
    this.captureTransactionId,
    this.captureTransactionResult,
    this.subscriptionTransactionId,
    this.paidDateUtc,
    this.shippingMethod,
    this.shippingRateComputationMethodSystemName,
    this.customValuesXml,
    this.deleted,
    this.createdOnUtc,
    this.customer,
    this.customerId,
    this.billingAddress,
    this.shippingAddress,
    this.orderItems,
    this.orderStatusId,
    this.orderStatus,
    this.orderStatusn,
    this.paymentStatusId,
    this.paymentStatus,
    this.paymentStatusn,
    this.shippingStatus,
    this.shippingStatusn,
    this.customerTaxDisplayType,
    this.canCancel,
    this.canRefund,
    this.lakumAmount,
    this.preferDeliveryDate,
    this.preferDeliveryTime,
    this.preferDeliveryTimen,
    this.driverID,
    this.driverOTP,
  });

  factory OrderModel.fromJson(Map<String, dynamic> json) => OrderModel(
    id: json["id"],
    storeId: json["store_id"],
    orderGuid: json["order_guid"],
    pickUpInStore: json["pick_up_in_store"],
    paymentMethodSystemName: paymentMethodSystemNameValues.map[json["payment_method_system_name"]],
    paymentName: paymentNameValues.map[json["payment_name"]],
    paymentNamen: paymentNameValues.map[json["payment_namen"]],
    customerCurrencyCode: customerCurrencyCodeValues.map[json["customer_currency_code"]],
    currencyRate: json["currency_rate"],
    customerTaxDisplayTypeId: json["customer_tax_display_type_id"],
    vatNumber: json["vat_number"],
    orderSubtotalInclTax: json["order_subtotal_incl_tax"].toDouble(),
    orderSubtotalExclTax: json["order_subtotal_excl_tax"].toDouble(),
    orderSubTotalDiscountInclTax: json["order_sub_total_discount_incl_tax"],
    orderSubTotalDiscountExclTax: json["order_sub_total_discount_excl_tax"],
    orderShippingInclTax: json["order_shipping_incl_tax"].toDouble(),
    orderShippingExclTax: json["order_shipping_excl_tax"],
    paymentMethodAdditionalFeeInclTax: json["payment_method_additional_fee_incl_tax"],
    paymentMethodAdditionalFeeExclTax: json["payment_method_additional_fee_excl_tax"],
    taxRates: json["tax_rates"],
    orderTax: json["order_tax"].toDouble(),
    orderDiscount: json["order_discount"],
    productCount: json["product_count"],
    orderTotal: json["order_total"].toDouble(),
    refundedAmount: json["refunded_amount"],
    rewardPointsWereAdded: json["reward_points_were_added"],
    rxAttachments: json["rx_attachments"] == null ? null : json["rx_attachments"],
    checkoutAttributeDescription: checkoutAttributeDescriptionValues.map[json["checkout_attribute_description"]],
    customerLanguageId: json["customer_language_id"],
    affiliateId: json["affiliate_id"],
    customerIp: customerIpValues.map[json["customer_ip"]],
    authorizationTransactionId: json["authorization_transaction_id"] == null ? null : json["authorization_transaction_id"],
    authorizationTransactionCode: json["authorization_transaction_code"],
    authorizationTransactionResult: json["authorization_transaction_result"],
    captureTransactionId: json["capture_transaction_id"],
    captureTransactionResult: json["capture_transaction_result"],
    subscriptionTransactionId: json["subscription_transaction_id"],
    paidDateUtc: json["paid_date_utc"] == null ? null : DateTime.parse(json["paid_date_utc"]),
    shippingMethod: shippingMethodValues.map[json["shipping_method"]],
    shippingRateComputationMethodSystemName: shippingRateComputationMethodSystemNameValues.map[json["shipping_rate_computation_method_system_name"]],
    customValuesXml: json["custom_values_xml"],
    deleted: json["deleted"],
    createdOnUtc: DateTime.parse(json["created_on_utc"]),
    customer: OrderModelCustomer.fromJson(json["customer"]),
    customerId: json["customer_id"],
    billingAddress: IngAddress.fromJson(json["billing_address"]),
    shippingAddress: IngAddress.fromJson(json["shipping_address"]),
    orderItems: List<OrderItem>.from(json["order_items"].map((x) => OrderItem.fromJson(x))),
    orderStatusId: json["order_status_id"],
    orderStatus: orderStatusValues.map[json["order_status"]],
    orderStatusn: orderStatusnValues.map[json["order_statusn"]],
    paymentStatusId: json["payment_status_id"],
    paymentStatus: paymentStatusValues.map[json["payment_status"]],
    paymentStatusn: paymentStatusnValues.map[json["payment_statusn"]],
    shippingStatus: shippingStatusValues.map[json["shipping_status"]],
    shippingStatusn: shippingStatusnValues.map[json["shipping_statusn"]],
    customerTaxDisplayType: customerTaxDisplayTypeValues.map[json["customer_tax_display_type"]],
    canCancel: json["can_cancel"],
    canRefund: json["can_refund"],
    lakumAmount: json["lakum_amount"],
    preferDeliveryDate: json["prefer_delivery_date"] == null ? null : DateTime.parse(json["prefer_delivery_date"]),
    preferDeliveryTime: json["prefer_delivery_time"] == null ? null : preferDeliveryTimeValues.map[json["prefer_delivery_time"]],
    preferDeliveryTimen: json["prefer_delivery_timen"] == null ? null : preferDeliveryTimenValues.map[json["prefer_delivery_timen"]],

    // Driver Detail
    driverID: json["DriverID"],
    driverOTP: json["DriverOTP"],

  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "store_id": storeId,
    "order_guid": orderGuid,
    "pick_up_in_store": pickUpInStore,
    "payment_method_system_name": paymentMethodSystemNameValues.reverse[paymentMethodSystemName],
    "payment_name": paymentNameValues.reverse[paymentName],
    "payment_namen": paymentNameValues.reverse[paymentNamen],
    "customer_currency_code": customerCurrencyCodeValues.reverse[customerCurrencyCode],
    "currency_rate": currencyRate,
    "customer_tax_display_type_id": customerTaxDisplayTypeId,
    "vat_number": vatNumber,
    "order_subtotal_incl_tax": orderSubtotalInclTax,
    "order_subtotal_excl_tax": orderSubtotalExclTax,
    "order_sub_total_discount_incl_tax": orderSubTotalDiscountInclTax,
    "order_sub_total_discount_excl_tax": orderSubTotalDiscountExclTax,
    "order_shipping_incl_tax": orderShippingInclTax,
    "order_shipping_excl_tax": orderShippingExclTax,
    "payment_method_additional_fee_incl_tax": paymentMethodAdditionalFeeInclTax,
    "payment_method_additional_fee_excl_tax": paymentMethodAdditionalFeeExclTax,
    "tax_rates": taxRates,
    "order_tax": orderTax,
    "order_discount": orderDiscount,
    "order_total": orderTotal,
    "refunded_amount": refundedAmount,
    "reward_points_were_added": rewardPointsWereAdded,
    "rx_attachments": rxAttachments == null ? null : rxAttachments,
    "checkout_attribute_description": checkoutAttributeDescriptionValues.reverse[checkoutAttributeDescription],
    "customer_language_id": customerLanguageId,
    "affiliate_id": affiliateId,
    "customer_ip": customerIpValues.reverse[customerIp],
    "authorization_transaction_id": authorizationTransactionId == null ? null : authorizationTransactionId,
    "authorization_transaction_code": authorizationTransactionCode,
    "authorization_transaction_result": authorizationTransactionResult,
    "capture_transaction_id": captureTransactionId,
    "capture_transaction_result": captureTransactionResult,
    "subscription_transaction_id": subscriptionTransactionId,
    "paid_date_utc": paidDateUtc == null ? null : paidDateUtc.toIso8601String(),
    "shipping_method": shippingMethodValues.reverse[shippingMethod],
    "shipping_rate_computation_method_system_name": shippingRateComputationMethodSystemNameValues.reverse[shippingRateComputationMethodSystemName],
    "custom_values_xml": customValuesXml,
    "deleted": deleted,
    "created_on_utc": createdOnUtc.toIso8601String(),
    "customer": customer.toJson(),
    "customer_id": customerId,
    "billing_address": billingAddress.toJson(),
    "shipping_address": shippingAddress.toJson(),
    "order_items": List<dynamic>.from(orderItems.map((x) => x.toJson())),
    "order_status_id": orderStatusId,
    "order_status": orderStatusValues.reverse[orderStatus],
    "order_statusn": orderStatusnValues.reverse[orderStatusn],
    "payment_status_id": paymentStatusId,
    "payment_status": paymentStatusValues.reverse[paymentStatus],
    "payment_statusn": paymentStatusnValues.reverse[paymentStatusn],
    "shipping_status": shippingStatusValues.reverse[shippingStatus],
    "shipping_statusn": shippingStatusnValues.reverse[shippingStatusn],
    "customer_tax_display_type": customerTaxDisplayTypeValues.reverse[customerTaxDisplayType],
    "can_cancel": canCancel,
    "can_refund": canRefund,
    "lakum_amount": lakumAmount,
    "prefer_delivery_date": preferDeliveryDate == null ? null : "${preferDeliveryDate.year.toString().padLeft(4, '0')}-${preferDeliveryDate.month.toString().padLeft(2, '0')}-${preferDeliveryDate.day.toString().padLeft(2, '0')}",
    "prefer_delivery_time": preferDeliveryTime == null ? null : preferDeliveryTimeValues.reverse[preferDeliveryTime],
    "prefer_delivery_timen": preferDeliveryTimen == null ? null : preferDeliveryTimenValues.reverse[preferDeliveryTimen],
  };
}

class IngAddress {
  IngAddress({
    this.id,
    this.firstName,
    this.lastName,
    this.email,
    this.company,
    this.countryId,
    this.country,
    this.stateProvinceId,
    this.city,
    this.address1,
    this.address2,
    this.zipPostalCode,
    this.phoneNumber,
    this.faxNumber,
    this.customerAttributes,
    this.createdOnUtc,
    this.province,
    this.latLong,
  });

  String id;
  FirstName firstName;
  LastName lastName;
  BillingAddressEmail email;
  dynamic company;
  dynamic countryId;
  Country country;
  dynamic stateProvinceId;
  City city;
  Address1 address1;
  Address2 address2;
  String zipPostalCode;
  String phoneNumber;
  dynamic faxNumber;
  String customerAttributes;
  DateTime createdOnUtc;
  dynamic province;
  String latLong;

  LatLng getLocation(){
    if(latLong.contains(',')){
      var parts = latLong.trim().split(',');
      if(parts.length == 2){
        var lat = double.tryParse(parts.first);
        var lng = double.tryParse(parts.last);
        if(lat != null || lng != null) {
          var location = LatLng(lat, lng);
          return location;
        }
      }
    }
    return null;
  }

  factory IngAddress.fromJson(Map<String, dynamic> json) => IngAddress(
    id: json["id"],
    firstName: firstNameValues.map[json["first_name"]],
    lastName: lastNameValues.map[json["last_name"]],
    email: billingAddressEmailValues.map[json["email"]],
    company: json["company"],
    countryId: json["country_id"],
    country: countryValues.map[json["country"]],
    stateProvinceId: json["state_province_id"],
    city: cityValues.map[json["city"]],
    address1: address1Values.map[json["address1"]],
    address2: address2Values.map[json["address2"]],
    zipPostalCode: json["zip_postal_code"],
    phoneNumber: json["phone_number"],
    faxNumber: json["fax_number"],
    customerAttributes: json["customer_attributes"],
    createdOnUtc: DateTime.parse(json["created_on_utc"]),
    province: json["province"],
    latLong: json["lat_long"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "first_name": firstNameValues.reverse[firstName],
    "last_name": lastNameValues.reverse[lastName],
    "email": billingAddressEmailValues.reverse[email],
    "company": company,
    "country_id": countryId,
    "country": countryValues.reverse[country],
    "state_province_id": stateProvinceId,
    "city": cityValues.reverse[city],
    "address1": address1Values.reverse[address1],
    "address2": address2Values.reverse[address2],
    "zip_postal_code": zipPostalCode,
    "phone_number": phoneNumber,
    "fax_number": faxNumber,
    "customer_attributes": customerAttributes,
    "created_on_utc": createdOnUtc.toIso8601String(),
    "province": province,
    "lat_long": latLong,
  };
}

enum Address1 { THE_7960_MOSAB_IBN_UMAIR_STREET_AL_RIYADH, THE_6500_AL_AMEEN_ABDULLAH_AL_ALI_AL_NAEEM_STREET_AL_RIYADH, THE_6603_IBRAHIM_IBN_AL_HAMASI_AR_RIYAD, THE_9626_SALAH_AD_DIN_AL_AYYUBI_ROAD_AL_RIYADH, THE_3075_PRINCE_MANSUR_BIN_ABDULAZIZ_STREET_AL_RIYADH, THE_40, THE_7801_AL_IHSA_AL_RIYADH }

final address1Values = EnumValues({
  "3075, Prince Mansur Bin Abdulaziz Street, Al Riyadh, ": Address1.THE_3075_PRINCE_MANSUR_BIN_ABDULAZIZ_STREET_AL_RIYADH,
  "40,": Address1.THE_40,
  "6500, Al Ameen Abdullah Al Ali Al Naeem Street, Al Riyadh, ": Address1.THE_6500_AL_AMEEN_ABDULLAH_AL_ALI_AL_NAEEM_STREET_AL_RIYADH,
  "6603, Ibrahim Ibn Al Hamasi, Ar-Riyad, ": Address1.THE_6603_IBRAHIM_IBN_AL_HAMASI_AR_RIYAD,
  "7801, Al Ihsa, Al Riyadh, ": Address1.THE_7801_AL_IHSA_AL_RIYADH,
  "7960, Mosab Ibn Umair Street, Al Riyadh, ": Address1.THE_7960_MOSAB_IBN_UMAIR_STREET_AL_RIYADH,
  "9626, Salah Ad Din Al Ayyubi Road, Al Riyadh, ": Address1.THE_9626_SALAH_AD_DIN_AL_AYYUBI_ROAD_AL_RIYADH
});

enum Address2 { AL_MALAZ_RIYADH_PROVINCE_3460, AL_MALAZ_RIYADH_PROVINCE_2817, AR_RAHMANIYYAH_RIYADH_PROVINCE_3816, AL_MALAZ_RIYADH_PROVINCE_3815, AL_WIZARAT_RIYADH_PROVINCE_7039, EASTERN_PROVINCE, AL_MALAZ_RIYADH_PROVINCE_3084 }

final address2Values = EnumValues({
  "Al Malaz, Riyadh Province, 2817, ": Address2.AL_MALAZ_RIYADH_PROVINCE_2817,
  "Al Malaz, Riyadh Province, 3084, ": Address2.AL_MALAZ_RIYADH_PROVINCE_3084,
  "Al Malaz, Riyadh Province, 3460, ": Address2.AL_MALAZ_RIYADH_PROVINCE_3460,
  "Al Malaz, Riyadh Province, 3815, ": Address2.AL_MALAZ_RIYADH_PROVINCE_3815,
  "Al Wizarat, Riyadh Province, 7039, ": Address2.AL_WIZARAT_RIYADH_PROVINCE_7039,
  "Ar Rahmaniyyah, Riyadh Province, 3816, ": Address2.AR_RAHMANIYYAH_RIYADH_PROVINCE_3816,
  "Eastern Province,": Address2.EASTERN_PROVINCE
});

enum City { RIYADH, DAMMAM }

final cityValues = EnumValues({
  "Dammam": City.DAMMAM,
  "Riyadh": City.RIYADH
});

enum Country { SAUDI_ARABIA }

final countryValues = EnumValues({
  "Saudi Arabia": Country.SAUDI_ARABIA
});

enum BillingAddressEmail { TAMER_FANASHEH_GMAIL_COM, TAMER_DASDASDAS_GMAIL_COM, TAMER_FANASHEH_DRSULAIMANALHABIB_COM }

final billingAddressEmailValues = EnumValues({
  "Tamer.dasdasdas@gmail.com": BillingAddressEmail.TAMER_DASDASDAS_GMAIL_COM,
  "tamer.fanasheh@drsulaimanalhabib.com": BillingAddressEmail.TAMER_FANASHEH_DRSULAIMANALHABIB_COM,
  "Tamer.fanasheh@gmail.com": BillingAddressEmail.TAMER_FANASHEH_GMAIL_COM
});

enum FirstName { TAMER, TAMER_FANASHEH, FIRST_NAME_TAMER }

final firstNameValues = EnumValues({
  "tamer": FirstName.FIRST_NAME_TAMER,
  "TAMER": FirstName.TAMER,
  "TAMER FANASHEH": FirstName.TAMER_FANASHEH
});

enum LastName { FANASHEH, MUSA, LAST_NAME_FANASHEH }

final lastNameValues = EnumValues({
  "FANASHEH": LastName.FANASHEH,
  "Fanasheh": LastName.LAST_NAME_FANASHEH,
  "MUSA": LastName.MUSA
});

enum LatLong { THE_246784385694919524674091019299842, THE_24664749106968054673501121876645, THE_2470993657522702246664724647270134, THE_246626170308533764673348444086107, THE_24664875225999005467347443322574, THE_24674331807435784671024726818286, THE_263430228396836664991113909164471, THE_246767400793488074673774399406786, THE_24665374673515 }

final latLongValues = EnumValues({
  "24.662617030853376,46.73348444086107": LatLong.THE_246626170308533764673348444086107,
  "24.66474910696805,46.73501121876645": LatLong.THE_24664749106968054673501121876645,
  "24.664875225999005,46.7347443322574": LatLong.THE_24664875225999005467347443322574,
  "24.66537,46.73515": LatLong.THE_24665374673515,
  "24.67433180743578,46.71024726818286": LatLong.THE_24674331807435784671024726818286,
  "24.676740079348807,46.73774399406786": LatLong.THE_246767400793488074673774399406786,
  "24.678438569491952,46.74091019299842": LatLong.THE_246784385694919524674091019299842,
  "24.709936575227022,46.664724647270134": LatLong.THE_2470993657522702246664724647270134,
  "26.343022839683666, 49.91113909164471": LatLong.THE_263430228396836664991113909164471
});

enum CheckoutAttributeDescription { EMPTY, CHECKOUT_ATTRIBUTE_DESCRIPTION }

final checkoutAttributeDescriptionValues = EnumValues({
  "ارفاق وصفة: ": CheckoutAttributeDescription.CHECKOUT_ATTRIBUTE_DESCRIPTION,
  "": CheckoutAttributeDescription.EMPTY
});

class OrderModelCustomer {
  OrderModelCustomer({
    this.id,
    this.username,
    this.email,
    this.firstName,
    this.lastName,
    this.languageId,
    this.adminComment,
    this.isTaxExempt,
    this.hasShoppingCartItems,
    this.active,
    this.deleted,
    this.isSystemAccount,
    this.systemName,
    this.lastIpAddress,
    this.createdOnUtc,
    this.lastLoginDateUtc,
    this.lastActivityDateUtc,
    this.registeredInStoreId,
    this.roleIds,
  });

  String id;
  dynamic username;
  dynamic email;
  dynamic firstName;
  dynamic lastName;
  String languageId;
  dynamic adminComment;
  bool isTaxExempt;
  bool hasShoppingCartItems;
  bool active;
  bool deleted;
  bool isSystemAccount;
  dynamic systemName;
  dynamic lastIpAddress;
  dynamic createdOnUtc;
  dynamic lastLoginDateUtc;
  dynamic lastActivityDateUtc;
  dynamic registeredInStoreId;
  List<dynamic> roleIds;

  factory OrderModelCustomer.fromJson(Map<String, dynamic> json) => OrderModelCustomer(
    id: json["id"],
    username: usernameValues.map[json["username"]],
    email: billingAddressEmailValues.map[json["email"]],
    firstName: firstNameValues.map[json["first_name"]],
    lastName: lastNameValues.map[json["last_name"]],
    languageId: json["language_id"],
    adminComment: json["admin_comment"],
    isTaxExempt: json["is_tax_exempt"],
    hasShoppingCartItems: json["has_shopping_cart_items"],
    active: json["active"],
    deleted: json["deleted"],
    isSystemAccount: json["is_system_account"],
    systemName: json["system_name"],
    lastIpAddress: lastIpAddressValues.map[json["last_ip_address"]],
    createdOnUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["created_on_utc"]) : null,
    lastLoginDateUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["last_login_date_utc"]) : null,
    lastActivityDateUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["last_activity_date_utc"]) : null,
    registeredInStoreId: json["registered_in_store_id"],
    roleIds: List<int>.from(json["role_ids"].map((x) => x)),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "username": usernameValues.reverse[username],
    "email": billingAddressEmailValues.reverse[email],
    "first_name": firstNameValues.reverse[firstName],
    "last_name": lastNameValues.reverse[lastName],
    "language_id": languageId,
    "admin_comment": adminComment,
    "is_tax_exempt": isTaxExempt,
    "has_shopping_cart_items": hasShoppingCartItems,
    "active": active,
    "deleted": deleted,
    "is_system_account": isSystemAccount,
    "system_name": systemName,
    "last_ip_address": lastIpAddressValues.reverse[lastIpAddress],
    "created_on_utc": createdOnUtc.toIso8601String(),
    "last_login_date_utc": lastLoginDateUtc.toIso8601String(),
    "last_activity_date_utc": lastActivityDateUtc.toIso8601String(),
    "registered_in_store_id": registeredInStoreId,
    "role_ids": List<dynamic>.from(roleIds.map((x) => x)),
  };
}

enum LastIpAddress { THE_1050220126 }

final lastIpAddressValues = EnumValues({
  "10.50.220.126": LastIpAddress.THE_1050220126
});

enum Username { TAMERF }

final usernameValues = EnumValues({
  "tamerf": Username.TAMERF
});

enum CustomerCurrencyCode { SAR }

final customerCurrencyCodeValues = EnumValues({
  "SAR": CustomerCurrencyCode.SAR
});

enum CustomerIp { THE_105010210, THE_127001, THE_1020200101, THE_102020041, THE_10501028, THE_102020033, THE_1020200170, THE_102020011 }

final customerIpValues = EnumValues({
  "10.20.200.101": CustomerIp.THE_1020200101,
  "10.20.200.11": CustomerIp.THE_102020011,
  "10.20.200.170": CustomerIp.THE_1020200170,
  "10.20.200.33": CustomerIp.THE_102020033,
  "10.20.200.41": CustomerIp.THE_102020041,
  "10.50.102.10": CustomerIp.THE_105010210,
  "10.50.102.8": CustomerIp.THE_10501028,
  "127.0.0.1": CustomerIp.THE_127001
});

enum CustomerTaxDisplayType { EXCLUDING_TAX }

final customerTaxDisplayTypeValues = EnumValues({
  "ExcludingTax": CustomerTaxDisplayType.EXCLUDING_TAX
});


class OrderItem {
  OrderItem({
    this.quantity,
    this.unitPriceInclTax,
    this.unitPriceExclTax,
    this.priceInclTax,
    this.priceExclTax,
    this.discountAmountInclTax,
    this.discountAmountExclTax,
    this.originalProductCost,
    this.attributeDescription,
    this.downloadCount,
    this.isDownloadActivated,
    this.licenseDownloadId,
    this.itemWeight,
    this.rentalStartDateUtc,
    this.rentalEndDateUtc,
    this.product,
    this.productId,
  });

  dynamic quantity;
  double unitPriceInclTax;
  double unitPriceExclTax;
  double priceInclTax;
  double priceExclTax;
  double discountAmountInclTax;
  double discountAmountExclTax;
  double originalProductCost;
  String attributeDescription;
  dynamic downloadCount;
  bool isDownloadActivated;
  dynamic licenseDownloadId;
  double itemWeight;
  dynamic rentalStartDateUtc;
  dynamic rentalEndDateUtc;
  Product product;
  dynamic productId;

  factory OrderItem.fromJson(Map<String, dynamic> json) => OrderItem(
    quantity: json["quantity"],
    unitPriceInclTax: json["unit_price_incl_tax"].toDouble(),
    unitPriceExclTax: json["unit_price_excl_tax"].toDouble(),
    priceInclTax: json["price_incl_tax"].toDouble(),
    priceExclTax: json["price_excl_tax"].toDouble(),
    discountAmountInclTax: json["discount_amount_incl_tax"].toDouble(),
    discountAmountExclTax: json["discount_amount_excl_tax"].toDouble(),
    originalProductCost: json["original_product_cost"].toDouble(),
    attributeDescription: json["attribute_description"],
    downloadCount: json["download_count"],
    isDownloadActivated: json["isDownload_activated"],
    licenseDownloadId: json["license_download_id"],
    itemWeight: json["item_weight"].toDouble(),
    rentalStartDateUtc: json["rental_start_date_utc"],
    rentalEndDateUtc: json["rental_end_date_utc"],
    product: Product.fromJson(json["product"]),
    productId: json["product_id"],
  );

  Map<String, dynamic> toJson() => {
    "quantity": quantity,
    "unit_price_incl_tax": unitPriceInclTax,
    "unit_price_excl_tax": unitPriceExclTax,
    "price_incl_tax": priceInclTax,
    "price_excl_tax": priceExclTax,
    "discount_amount_incl_tax": discountAmountInclTax,
    "discount_amount_excl_tax": discountAmountExclTax,
    "original_product_cost": originalProductCost,
    "attribute_description": attributeDescription,
    "download_count": downloadCount,
    "isDownload_activated": isDownloadActivated,
    "license_download_id": licenseDownloadId,
    "item_weight": itemWeight,
    "rental_start_date_utc": rentalStartDateUtc,
    "rental_end_date_utc": rentalEndDateUtc,
    "product": product.toJson(),
    "product_id": productId,
  };
}

class Product {
  Product({
    this.id,
    this.visibleIndividually,
    this.name,
    this.namen,
    this.localizedNames,
    this.shortDescription,
    this.shortDescriptionn,
    this.fullDescription,
    this.fullDescriptionn,
    this.markasNew,
    this.showOnHomePage,
    this.metaKeywords,
    this.metaDescription,
    this.metaTitle,
    this.allowCustomerReviews,
    this.approvedRatingSum,
    this.notApprovedRatingSum,
    this.approvedTotalReviews,
    this.notApprovedTotalReviews,
    this.sku,
    this.isRx,
    this.prescriptionRequired,
    this.rxMessage,
    this.rxMessagen,
    this.manufacturerPartNumber,
    this.gtin,
    this.isGiftCard,
    this.requireOtherProducts,
    this.automaticallyAddRequiredProducts,
    this.isDownload,
    this.unlimitedDownloads,
    this.maxNumberOfDownloads,
    this.downloadExpirationDays,
    this.hasSampleDownload,
    this.hasUserAgreement,
    this.isRecurring,
    this.recurringCycleLength,
    this.recurringTotalCycles,
    this.isRental,
    this.rentalPriceLength,
    this.isShipEnabled,
    this.isFreeShipping,
    this.shipSeparately,
    this.additionalShippingCharge,
    this.isTaxExempt,
    this.isTelecommunicationsOrBroadcastingOrElectronicServices,
    this.useMultipleWarehouses,
    this.manageInventoryMethodId,
    this.stockQuantity,
    this.stockAvailability,
    this.stockAvailabilityn,
    this.displayStockAvailability,
    this.displayStockQuantity,
    this.minStockQuantity,
    this.notifyAdminForQuantityBelow,
    this.allowBackInStockSubscriptions,
    this.orderMinimumQuantity,
    this.orderMaximumQuantity,
    this.allowedQuantities,
    this.allowAddingOnlyExistingAttributeCombinations,
    this.disableBuyButton,
    this.disableWishlistButton,
    this.availableForPreOrder,
    this.preOrderAvailabilityStartDateTimeUtc,
    this.callForPrice,
    this.price,
    this.oldPrice,
    this.productCost,
    this.specialPrice,
    this.specialPriceStartDateTimeUtc,
    this.specialPriceEndDateTimeUtc,
    this.customerEntersPrice,
    this.minimumCustomerEnteredPrice,
    this.maximumCustomerEnteredPrice,
    this.basepriceEnabled,
    this.basepriceAmount,
    this.basepriceBaseAmount,
    this.hasTierPrices,
    this.hasDiscountsApplied,
    this.discountName,
    this.discountNamen,
    this.discountDescription,
    this.discountDescriptionn,
    this.discountPercentage,
    this.currency,
    this.currencyn,
    this.weight,
    this.length,
    this.width,
    this.height,
    this.availableStartDateTimeUtc,
    this.availableEndDateTimeUtc,
    this.displayOrder,
    this.published,
    this.deleted,
    this.createdOnUtc,
    this.updatedOnUtc,
    this.productType,
    this.parentGroupedProductId,
    this.roleIds,
    this.discountIds,
    this.storeIds,
    this.manufacturerIds,
    this.reviews,
    this.images,
    this.attributes,
    this.specifications,
    this.associatedProductIds,
    this.tags,
    this.vendorId,
    this.seName,
  });

  String id;
  bool visibleIndividually;
  String name;
  String namen;
  dynamic localizedNames;
  String shortDescription;
  String shortDescriptionn;
  String fullDescription;
  String fullDescriptionn;
  bool markasNew;
  bool showOnHomePage;
  String metaKeywords;
  String metaDescription;
  String metaTitle;
  bool allowCustomerReviews;
  dynamic approvedRatingSum;
  dynamic notApprovedRatingSum;
  dynamic approvedTotalReviews;
  dynamic notApprovedTotalReviews;
  String sku;
  bool isRx;
  bool prescriptionRequired;
  dynamic rxMessage;
  dynamic rxMessagen;
  dynamic manufacturerPartNumber;
  dynamic gtin;
  bool isGiftCard;
  bool requireOtherProducts;
  bool automaticallyAddRequiredProducts;
  bool isDownload;
  bool unlimitedDownloads;
  dynamic maxNumberOfDownloads;
  dynamic downloadExpirationDays;
  bool hasSampleDownload;
  bool hasUserAgreement;
  bool isRecurring;
  dynamic recurringCycleLength;
  dynamic recurringTotalCycles;
  bool isRental;
  dynamic rentalPriceLength;
  bool isShipEnabled;
  bool isFreeShipping;
  bool shipSeparately;
  dynamic additionalShippingCharge;
  bool isTaxExempt;
  bool isTelecommunicationsOrBroadcastingOrElectronicServices;
  bool useMultipleWarehouses;
  dynamic manageInventoryMethodId;
  dynamic stockQuantity;
  dynamic stockAvailability;
  dynamic stockAvailabilityn;
  bool displayStockAvailability;
  bool displayStockQuantity;
  dynamic minStockQuantity;
  dynamic notifyAdminForQuantityBelow;
  bool allowBackInStockSubscriptions;
  dynamic orderMinimumQuantity;
  dynamic orderMaximumQuantity;
  dynamic allowedQuantities;
  bool allowAddingOnlyExistingAttributeCombinations;
  bool disableBuyButton;
  bool disableWishlistButton;
  bool availableForPreOrder;
  dynamic preOrderAvailabilityStartDateTimeUtc;
  bool callForPrice;
  double price;
  dynamic oldPrice;
  double productCost;
  dynamic specialPrice;
  dynamic specialPriceStartDateTimeUtc;
  dynamic specialPriceEndDateTimeUtc;
  bool customerEntersPrice;
  dynamic minimumCustomerEnteredPrice;
  dynamic maximumCustomerEnteredPrice;
  bool basepriceEnabled;
  dynamic basepriceAmount;
  dynamic basepriceBaseAmount;
  bool hasTierPrices;
  bool hasDiscountsApplied;
  dynamic discountName;
  dynamic discountNamen;
  dynamic discountDescription;
  dynamic discountDescriptionn;
  dynamic discountPercentage;
  dynamic currency;
  dynamic currencyn;
  double weight;
  dynamic length;
  dynamic width;
  dynamic height;
  dynamic availableStartDateTimeUtc;
  dynamic availableEndDateTimeUtc;
  dynamic displayOrder;
  bool published;
  bool deleted;
  dynamic createdOnUtc;
  dynamic updatedOnUtc;
  dynamic productType;
  dynamic parentGroupedProductId;
  dynamic roleIds;
  dynamic discountIds;
  dynamic storeIds;
  dynamic manufacturerIds;
  List<Review> reviews;
  List<PharmacyImageObject> images;
  dynamic attributes;
  dynamic specifications;
  dynamic associatedProductIds;
  List<dynamic> tags;
  dynamic vendorId;
  String seName;

  factory Product.fromJson(Map<String, dynamic> json) => Product(
    id: json["id"],
    visibleIndividually: json["visible_individually"],
    name: json["name"],
    namen: json["namen"],
    localizedNames: json["localized_names"],
    shortDescription: json["short_description"] == null ? null : json["short_description"],
    shortDescriptionn: json["short_descriptionn"] == null ? null : json["short_descriptionn"],
    fullDescription: json["full_description"],
    fullDescriptionn: json["full_descriptionn"],
    markasNew: json["markas_new"],
    showOnHomePage: json["show_on_home_page"],
    metaKeywords: json["meta_keywords"] == null ? null : json["meta_keywords"],
    metaDescription: json["meta_description"] == null ? null : json["meta_description"],
    metaTitle: json["meta_title"] == null ? null : json["meta_title"],
    allowCustomerReviews: json["allow_customer_reviews"],
    approvedRatingSum: json["approved_rating_sum"],
    notApprovedRatingSum: json["not_approved_rating_sum"],
    approvedTotalReviews: json["approved_total_reviews"],
    notApprovedTotalReviews: json["not_approved_total_reviews"],
    sku: json["sku"],
    isRx: json["is_rx"],
    prescriptionRequired: json["prescription_required"],
    rxMessage: json["rx_message"],
    rxMessagen: json["rx_messagen"],
    manufacturerPartNumber: json["manufacturer_part_number"],
    gtin: json["gtin"],
    isGiftCard: json["is_gift_card"],
    requireOtherProducts: json["require_other_products"],
    automaticallyAddRequiredProducts: json["automatically_add_required_products"],
    isDownload: json["is_download"],
    unlimitedDownloads: json["unlimited_downloads"],
    maxNumberOfDownloads: json["max_number_of_downloads"],
    downloadExpirationDays: json["download_expiration_days"],
    hasSampleDownload: json["has_sample_download"],
    hasUserAgreement: json["has_user_agreement"],
    isRecurring: json["is_recurring"],
    recurringCycleLength: json["recurring_cycle_length"],
    recurringTotalCycles: json["recurring_total_cycles"],
    isRental: json["is_rental"],
    rentalPriceLength: json["rental_price_length"],
    isShipEnabled: json["is_ship_enabled"],
    isFreeShipping: json["is_free_shipping"],
    shipSeparately: json["ship_separately"],
    additionalShippingCharge: json["additional_shipping_charge"],
    isTaxExempt: json["is_tax_exempt"],
    isTelecommunicationsOrBroadcastingOrElectronicServices: json["is_telecommunications_or_broadcasting_or_electronic_services"],
    useMultipleWarehouses: json["use_multiple_warehouses"],
    manageInventoryMethodId: json["manage_inventory_method_id"],
    stockQuantity: json["stock_quantity"],
    stockAvailability: json["stock_availability"],
    stockAvailabilityn: json["stock_availabilityn"],
    displayStockAvailability: json["display_stock_availability"],
    displayStockQuantity: json["display_stock_quantity"],
    minStockQuantity: json["min_stock_quantity"],
    notifyAdminForQuantityBelow: json["notify_admin_for_quantity_below"],
    allowBackInStockSubscriptions: json["allow_back_in_stock_subscriptions"],
    orderMinimumQuantity: json["order_minimum_quantity"],
    orderMaximumQuantity: json["order_maximum_quantity"],
    allowedQuantities: json["allowed_quantities"],
    allowAddingOnlyExistingAttributeCombinations: json["allow_adding_only_existing_attribute_combinations"],
    disableBuyButton: json["disable_buy_button"],
    disableWishlistButton: json["disable_wishlist_button"],
    availableForPreOrder: json["available_for_pre_order"],
    preOrderAvailabilityStartDateTimeUtc: json["pre_order_availability_start_date_time_utc"],
    callForPrice: json["call_for_price"],
    price: json["price"].toDouble(),
    oldPrice: json["old_price"],
    productCost: json["product_cost"].toDouble(),
    specialPrice: json["special_price"],
    specialPriceStartDateTimeUtc: json["special_price_start_date_time_utc"],
    specialPriceEndDateTimeUtc: json["special_price_end_date_time_utc"],
    customerEntersPrice: json["customer_enters_price"],
    minimumCustomerEnteredPrice: json["minimum_customer_entered_price"],
    maximumCustomerEnteredPrice: json["maximum_customer_entered_price"],
    basepriceEnabled: json["baseprice_enabled"],
    basepriceAmount: json["baseprice_amount"],
    basepriceBaseAmount: json["baseprice_base_amount"],
    hasTierPrices: json["has_tier_prices"],
    hasDiscountsApplied: json["has_discounts_applied"],
    discountName: json["discount_name"],
    discountNamen: json["discount_namen"],
    discountDescription: json["discount_description"],
    discountDescriptionn: json["discount_Descriptionn"],
    discountPercentage: json["discount_percentage"],
    currency: json["currency"],
    currencyn: json["currencyn"],
    weight: json["weight"].toDouble(),
    length: json["length"],
    width: json["width"],
    height: json["height"],
    availableStartDateTimeUtc: json["available_start_date_time_utc"],
    availableEndDateTimeUtc: json["available_end_date_time_utc"],
    displayOrder: json["display_order"],
    published: json["published"],
    deleted: json["deleted"],
    createdOnUtc: DateTime.parse(json["created_on_utc"]),
    updatedOnUtc: DateTime.parse(json["updated_on_utc"]),
    productType: productTypeValues.map[json["product_type"]],
    parentGroupedProductId: json["parent_grouped_product_id"],
    roleIds: json["role_ids"],
    discountIds: json["discount_ids"],
    storeIds: json["store_ids"],
    manufacturerIds: json["manufacturer_ids"],
    reviews: List<Review>.from(json["reviews"].map((x) => Review.fromJson(x))),
    images: List<PharmacyImageObject>.from(json["images"].map((x) => PharmacyImageObject.fromJson(x))),
    attributes: json["attributes"],
    specifications: json["specifications"],
    associatedProductIds: json["associated_product_ids"],
    tags: List<dynamic>.from(json["tags"].map((x) => x)),
    vendorId: json["vendor_id"],
    seName: json["se_name"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "visible_individually": visibleIndividually,
    "name": name,
    "namen": namen,
    "localized_names": localizedNames,
    "short_description": shortDescription == null ? null : shortDescription,
    "short_descriptionn": shortDescriptionn == null ? null : shortDescriptionn,
    "full_description": fullDescription,
    "full_descriptionn": fullDescriptionn,
    "markas_new": markasNew,
    "show_on_home_page": showOnHomePage,
    "meta_keywords": metaKeywords == null ? null : metaKeywords,
    "meta_description": metaDescription == null ? null : metaDescription,
    "meta_title": metaTitle == null ? null : metaTitle,
    "allow_customer_reviews": allowCustomerReviews,
    "approved_rating_sum": approvedRatingSum,
    "not_approved_rating_sum": notApprovedRatingSum,
    "approved_total_reviews": approvedTotalReviews,
    "not_approved_total_reviews": notApprovedTotalReviews,
    "sku": sku,
    "is_rx": isRx,
    "prescription_required": prescriptionRequired,
    "rx_message": rxMessage,
    "rx_messagen": rxMessagen,
    "manufacturer_part_number": manufacturerPartNumber,
    "gtin": gtin,
    "is_gift_card": isGiftCard,
    "require_other_products": requireOtherProducts,
    "automatically_add_required_products": automaticallyAddRequiredProducts,
    "is_download": isDownload,
    "unlimited_downloads": unlimitedDownloads,
    "max_number_of_downloads": maxNumberOfDownloads,
    "download_expiration_days": downloadExpirationDays,
    "has_sample_download": hasSampleDownload,
    "has_user_agreement": hasUserAgreement,
    "is_recurring": isRecurring,
    "recurring_cycle_length": recurringCycleLength,
    "recurring_total_cycles": recurringTotalCycles,
    "is_rental": isRental,
    "rental_price_length": rentalPriceLength,
    "is_ship_enabled": isShipEnabled,
    "is_free_shipping": isFreeShipping,
    "ship_separately": shipSeparately,
    "additional_shipping_charge": additionalShippingCharge,
    "is_tax_exempt": isTaxExempt,
    "is_telecommunications_or_broadcasting_or_electronic_services": isTelecommunicationsOrBroadcastingOrElectronicServices,
    "use_multiple_warehouses": useMultipleWarehouses,
    "manage_inventory_method_id": manageInventoryMethodId,
    "stock_quantity": stockQuantity,
    "stock_availability": stockAvailability,
    "stock_availabilityn": stockAvailabilityn,
    "display_stock_availability": displayStockAvailability,
    "display_stock_quantity": displayStockQuantity,
    "min_stock_quantity": minStockQuantity,
    "notify_admin_for_quantity_below": notifyAdminForQuantityBelow,
    "allow_back_in_stock_subscriptions": allowBackInStockSubscriptions,
    "order_minimum_quantity": orderMinimumQuantity,
    "order_maximum_quantity": orderMaximumQuantity,
    "allowed_quantities": allowedQuantities,
    "allow_adding_only_existing_attribute_combinations": allowAddingOnlyExistingAttributeCombinations,
    "disable_buy_button": disableBuyButton,
    "disable_wishlist_button": disableWishlistButton,
    "available_for_pre_order": availableForPreOrder,
    "pre_order_availability_start_date_time_utc": preOrderAvailabilityStartDateTimeUtc,
    "call_for_price": callForPrice,
    "price": price,
    "old_price": oldPrice,
    "product_cost": productCost,
    "special_price": specialPrice,
    "special_price_start_date_time_utc": specialPriceStartDateTimeUtc,
    "special_price_end_date_time_utc": specialPriceEndDateTimeUtc,
    "customer_enters_price": customerEntersPrice,
    "minimum_customer_entered_price": minimumCustomerEnteredPrice,
    "maximum_customer_entered_price": maximumCustomerEnteredPrice,
    "baseprice_enabled": basepriceEnabled,
    "baseprice_amount": basepriceAmount,
    "baseprice_base_amount": basepriceBaseAmount,
    "has_tier_prices": hasTierPrices,
    "has_discounts_applied": hasDiscountsApplied,
    "discount_name": discountName,
    "discount_namen": discountNamen,
    "discount_description": discountDescription,
    "discount_Descriptionn": discountDescriptionn,
    "discount_percentage": discountPercentage,
    "currency": currency,
    "currencyn": currencyn,
    "weight": weight,
    "length": length,
    "width": width,
    "height": height,
    "available_start_date_time_utc": availableStartDateTimeUtc,
    "available_end_date_time_utc": availableEndDateTimeUtc,
    "display_order": displayOrder,
    "published": published,
    "deleted": deleted,
    "created_on_utc": createdOnUtc.toIso8601String(),
    "updated_on_utc": updatedOnUtc.toIso8601String(),
    "product_type": productTypeValues.reverse[productType],
    "parent_grouped_product_id": parentGroupedProductId,
    "role_ids": roleIds,
    "discount_ids": discountIds,
    "store_ids": storeIds,
    "manufacturer_ids": manufacturerIds,
    "reviews": List<dynamic>.from(reviews.map((x) => x.toJson())),
    "images": List<dynamic>.from(images.map((x) => x.toJson())),
    "attributes": attributes,
    "specifications": specifications,
    "associated_product_ids": associatedProductIds,
    "tags": List<dynamic>.from(tags.map((x) => x)),
    "vendor_id": vendorId,
    "se_name": seName,
  };
}

enum ProductType { SIMPLE_PRODUCT }

final productTypeValues = EnumValues({
  "SimpleProduct": ProductType.SIMPLE_PRODUCT
});

class Review {
  Review({
    this.id,
    this.position,
    this.reviewId,
    this.customerId,
    this.productId,
    this.storeId,
    this.isApproved,
    this.title,
    this.reviewText,
    this.replyText,
    this.rating,
    this.helpfulYesTotal,
    this.helpfulNoTotal,
    this.createdOnUtc,
    this.customer,
    this.product,
  });

  dynamic id;
  dynamic position;
  dynamic reviewId;
  dynamic customerId;
  dynamic productId;
  dynamic storeId;
  bool isApproved;
  dynamic title;
  dynamic reviewText;
  dynamic replyText;
  dynamic rating;
  dynamic helpfulYesTotal;
  dynamic helpfulNoTotal;
  dynamic createdOnUtc;
  dynamic customer;
  dynamic product;

  factory Review.fromJson(Map<String, dynamic> json) => Review(
    id: json["id"],
    position: json["position"],
    reviewId: json["review_id"],
    customerId: json["customer_id"],
    productId: json["product_id"],
    storeId: json["store_id"],
    isApproved: json["is_approved"],
    title: titleValues.map[json["title"]],
    reviewText: reviewTextValues.map[json["review_text"]],
    replyText: json["reply_text"],
    rating: json["rating"],
    helpfulYesTotal: json["helpful_yes_total"],
    helpfulNoTotal: json["helpful_no_total"],
    createdOnUtc: DateTime.parse(json["created_on_utc"]),
    customer: ReviewCustomer.fromJson(json["customer"]),
    product: json["product"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "position": position,
    "review_id": reviewId,
    "customer_id": customerId,
    "product_id": productId,
    "store_id": storeId,
    "is_approved": isApproved,
    "title": titleValues.reverse[title],
    "review_text": reviewTextValues.reverse[reviewText],
    "reply_text": replyText,
    "rating": rating,
    "helpful_yes_total": helpfulYesTotal,
    "helpful_no_total": helpfulNoTotal,
    "created_on_utc": createdOnUtc.toIso8601String(),
    "customer": customer.toJson(),
    "product": product,
  };
}

class ReviewCustomer {
  ReviewCustomer({
    this.fileNumber,
    this.iqamaNumber,
    this.isOutSa,
    this.patientType,
    this.gender,
    this.birthDate,
    this.phone,
    this.countryCode,
    this.yahalaAccountno,
    this.billingAddress,
    this.shippingAddress,
    this.addresses,
    this.id,
    this.username,
    this.email,
    this.firstName,
    this.lastName,
    this.languageId,
    this.adminComment,
    this.isTaxExempt,
    this.hasShoppingCartItems,
    this.active,
    this.deleted,
    this.isSystemAccount,
    this.systemName,
    this.lastIpAddress,
    this.createdOnUtc,
    this.lastLoginDateUtc,
    this.lastActivityDateUtc,
    this.registeredInStoreId,
    this.roleIds,
  });

  dynamic fileNumber;
  dynamic iqamaNumber;
  dynamic isOutSa;
  dynamic patientType;
  dynamic gender;
  dynamic birthDate;
  dynamic phone;
  dynamic countryCode;
  dynamic yahalaAccountno;
  dynamic billingAddress;
  dynamic shippingAddress;
  List<dynamic> addresses;
  String id;
  String username;
  dynamic email;
  dynamic firstName;
  dynamic lastName;
  dynamic languageId;
  dynamic adminComment;
  dynamic isTaxExempt;
  dynamic hasShoppingCartItems;
  dynamic active;
  dynamic deleted;
  dynamic isSystemAccount;
  dynamic systemName;
  dynamic lastIpAddress;
  dynamic createdOnUtc;
  dynamic lastLoginDateUtc;
  dynamic lastActivityDateUtc;
  dynamic registeredInStoreId;
  List<dynamic> roleIds;

  factory ReviewCustomer.fromJson(Map<String, dynamic> json) => ReviewCustomer(
    fileNumber: json["file_number"],
    iqamaNumber: json["iqama_number"],
    isOutSa: json["is_out_sa"],
    patientType: json["patient_type"],
    gender: json["gender"],
    birthDate: DateTime.parse(json["birth_date"]),
    phone: json["phone"],
    countryCode: json["country_code"],
    yahalaAccountno: json["yahala_accountno"],
    billingAddress: json["billing_address"],
    shippingAddress: json["shipping_address"],
    addresses: List<dynamic>.from(json["addresses"].map((x) => x)),
    id: json["id"],
    username: json["username"],
    email: purpleEmailValues.map[json["email"]],
    firstName: json["first_name"],
    lastName: json["last_name"],
    languageId: json["language_id"],
    adminComment: json["admin_comment"],
    isTaxExempt: json["is_tax_exempt"],
    hasShoppingCartItems: json["has_shopping_cart_items"],
    active: json["active"],
    deleted: json["deleted"],
    isSystemAccount: json["is_system_account"],
    systemName: json["system_name"],
    lastIpAddress: json["last_ip_address"],
    createdOnUtc: json["created_on_utc"],
    lastLoginDateUtc: json["last_login_date_utc"],
    lastActivityDateUtc: json["last_activity_date_utc"],
    registeredInStoreId: json["registered_in_store_id"],
    roleIds: List<dynamic>.from(json["role_ids"].map((x) => x)),
  );

  Map<String, dynamic> toJson() => {
    "file_number": fileNumber,
    "iqama_number": iqamaNumber,
    "is_out_sa": isOutSa,
    "patient_type": patientType,
    "gender": gender,
    "birth_date": birthDate.toIso8601String(),
    "phone": phone,
    "country_code": countryCode,
    "yahala_accountno": yahalaAccountno,
    "billing_address": billingAddress,
    "shipping_address": shippingAddress,
    "addresses": List<dynamic>.from(addresses.map((x) => x)),
    "id": id,
    "username": username,
    "email": purpleEmailValues.reverse[email],
    "first_name": firstName,
    "last_name": lastName,
    "language_id": languageId,
    "admin_comment": adminComment,
    "is_tax_exempt": isTaxExempt,
    "has_shopping_cart_items": hasShoppingCartItems,
    "active": active,
    "deleted": deleted,
    "is_system_account": isSystemAccount,
    "system_name": systemName,
    "last_ip_address": lastIpAddress,
    "created_on_utc": createdOnUtc,
    "last_login_date_utc": lastLoginDateUtc,
    "last_activity_date_utc": lastActivityDateUtc,
    "registered_in_store_id": registeredInStoreId,
    "role_ids": List<dynamic>.from(roleIds.map((x) => x)),
  };
}

enum PurpleEmail { STEVE_GATES_NOP_COMMERCE_COM, TAMER_FANASHEH_DRSULAIMANALHABIB_COM, ASIF_RAZA_DRSULAIMANALHABIB_COM, ABOSAMI_YMAIL_COM }

final purpleEmailValues = EnumValues({
  "abosami@ymail.com": PurpleEmail.ABOSAMI_YMAIL_COM,
  "asif.raza@drsulaimanalhabib.com": PurpleEmail.ASIF_RAZA_DRSULAIMANALHABIB_COM,
  "steve_gates@nopCommerce.com": PurpleEmail.STEVE_GATES_NOP_COMMERCE_COM,
  "tamer.fanasheh@drsulaimanalhabib.com": PurpleEmail.TAMER_FANASHEH_DRSULAIMANALHABIB_COM
});

enum ReviewText { GOOD, NICE_PRICE, GREAT, REVIEW_TEXT_GOOD, GG, ENAD_TEST_REVIEW_001, ENAD, ENADDD, ENAD_TEST_0001, PURPLE_GOOD, EMPTY }

final reviewTextValues = EnumValues({
  "افضل علاج للزكام": ReviewText.EMPTY,
  "ENAD ": ReviewText.ENAD,
  "enaddd": ReviewText.ENADDD,
  "ENAD TEST 0001": ReviewText.ENAD_TEST_0001,
  "Enad Test Review 001": ReviewText.ENAD_TEST_REVIEW_001,
  "gg": ReviewText.GG,
  "good ": ReviewText.GOOD,
  "great": ReviewText.GREAT,
  "nice price": ReviewText.NICE_PRICE,
  "Good": ReviewText.PURPLE_GOOD,
  "good": ReviewText.REVIEW_TEXT_GOOD
});

enum Title { EMPTY, GOOD, TITLE }

final titleValues = EnumValues({
  "": Title.EMPTY,
  "Good": Title.GOOD,
  "ممتاز": Title.TITLE
});

enum OrderStatus { ORDER_SUBMITTED, PENDING, ORDER_IN_PROGRESS,ORDER_SENT_FOR_DELIVERY, ORDER_COMPLETED, CANCELLED, PROCESSING, ORDER_REFUNDED, COMPLETE }

final orderStatusValues = EnumValues({
  "Cancelled": OrderStatus.CANCELLED,
  "Complete": OrderStatus.COMPLETE,
  "OrderCompleted": OrderStatus.ORDER_COMPLETED,
  "OrderInProgress": OrderStatus.ORDER_IN_PROGRESS,
  "OrderRefunded": OrderStatus.ORDER_REFUNDED,
  "OrderSubmitted": OrderStatus.ORDER_SUBMITTED,
  "Pending": OrderStatus.PENDING,
  "Processing": OrderStatus.PROCESSING,
  "orderSentForDelivery": OrderStatus.ORDER_SENT_FOR_DELIVERY
});

enum OrderStatusn { ORDER_SUBMITTED, EMPTY, ORDER_IN_PROGRESS, ORDER_COMPLETED, ORDER_STATUSN, PURPLE, FLUFFY, TENTACLED }

final orderStatusnValues = EnumValues({
  "معلقة": OrderStatusn.EMPTY,
  "تم ارجاع مبلغ الطلبية المدفوع للعميل": OrderStatusn.FLUFFY,
  "Order Completed": OrderStatusn.ORDER_COMPLETED,
  "Order In Progress": OrderStatusn.ORDER_IN_PROGRESS,
  "ملغي": OrderStatusn.ORDER_STATUSN,
  "Order Submitted": OrderStatusn.ORDER_SUBMITTED,
  "قيد التنفيذ": OrderStatusn.PURPLE,
  "مكتمل": OrderStatusn.TENTACLED,
  "مكتمل": OrderStatusn.TENTACLED
});

enum PaymentMethodSystemName { PAYMENTS_PAY_FORT, PAYMENTS_CASH_ON_DELIVERY }

final paymentMethodSystemNameValues = EnumValues({
  "Payments.CashOnDelivery": PaymentMethodSystemName.PAYMENTS_CASH_ON_DELIVERY,
  "Payments.PayFort": PaymentMethodSystemName.PAYMENTS_PAY_FORT
});

enum PaymentName { CREDIT_DEBIT_CARD_PAYFORT, CASH_ON_DELIVERY_COD }

final paymentNameValues = EnumValues({
  "Cash On Delivery (COD)": PaymentName.CASH_ON_DELIVERY_COD,
  "Credit / Debit Card Payfort": PaymentName.CREDIT_DEBIT_CARD_PAYFORT
});

enum PaymentStatus { PAID, PENDING }

final paymentStatusValues = EnumValues({
  "Paid": PaymentStatus.PAID,
  "Pending": PaymentStatus.PENDING
});

enum PaymentStatusn { EMPTY, PAYMENT_STATUSN }

final paymentStatusnValues = EnumValues({
  "تم الدفع": PaymentStatusn.EMPTY,
  "قيد الإنتظار": PaymentStatusn.PAYMENT_STATUSN
});

enum PreferDeliveryTime { THE_1000_AM_330_PM, THE_530_PM_730_PM }

final preferDeliveryTimeValues = EnumValues({
  "10:00 AM - 3:30 PM": PreferDeliveryTime.THE_1000_AM_330_PM,
  "5:30 PM - 7:30 PM": PreferDeliveryTime.THE_530_PM_730_PM
});

enum PreferDeliveryTimen { THE_1000330, THE_530730 }

final preferDeliveryTimenValues = EnumValues({
  "10:00 ص - 3:30 م": PreferDeliveryTimen.THE_1000330,
  "5:30 م - 7:30 م": PreferDeliveryTimen.THE_530730
});

enum ShippingMethod { EMPTY, FIXED_PRICE }

final shippingMethodValues = EnumValues({
  "سعر ثابت ": ShippingMethod.EMPTY,
  "Fixed Price": ShippingMethod.FIXED_PRICE
});

enum ShippingRateComputationMethodSystemName { SHIPPING_FIXED_OR_BY_WEIGHT }

final shippingRateComputationMethodSystemNameValues = EnumValues({
  "Shipping.FixedOrByWeight": ShippingRateComputationMethodSystemName.SHIPPING_FIXED_OR_BY_WEIGHT
});

enum ShippingStatus { NOT_YET_SHIPPED }

final shippingStatusValues = EnumValues({
  "NotYetShipped": ShippingStatus.NOT_YET_SHIPPED
});

enum ShippingStatusn { EMPTY }

final shippingStatusnValues = EnumValues({
  "لم يتم شحنها بعد": ShippingStatusn.EMPTY
});

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;
  }
}