import 'package:diplomaticquarterapp/generated/json/base/json_convert_content.dart';
import 'package:diplomaticquarterapp/generated/json/base/json_field.dart';

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

  String getName() {
    if(localizedNames.length == 2){
      if(localizedNames.first.languageId == 2)
        return localizedNames.first.localizedName ?? name;

      else if(localizedNames.first.languageId == 1)
        return localizedNames.last.localizedName ?? name;
    }
    return name;
  }
}

class OfferProductsResponseModelLocalizedName with JsonConvert<OfferProductsResponseModelLocalizedName> {
  @JSONField(name: "language_id")
  int languageId;
  @JSONField(name: "localized_name")
  String localizedName;
}

class OfferProductsResponseModelImage with JsonConvert<OfferProductsResponseModelImage> {
  int id;
  int position;
  String src;
  String thumb;
  String attachment;
}

class OfferProductsResponseModelSpecification with JsonConvert<OfferProductsResponseModelSpecification> {
  int id;
  @JSONField(name: "display_order")
  int displayOrder;
  @JSONField(name: "default_value")
  String defaultValue;
  @JSONField(name: "default_valuen")
  String defaultValuen;
  String name;
  String nameN;
}
