import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCategoriesResponseModel.dart';

offerCategoriesResponseModelFromJson(PackagesCategoriesResponseModel data, Map<String, dynamic> json) {
  if (json['id'] != null) {
    data.id = json['id'];
  }
  if (json['name'] != null) {
    data.name = json['name']?.toString();
  }
  if (json['namen'] != null) {
    data.namen = json['namen']?.toString();
  }
  if (json['localized_names'] != null) {
    data.localizedNames = new List<OfferCategoriesResponseModelLocalizedName>();
    (json['localized_names'] as List).forEach((v) {
      data.localizedNames.add(new OfferCategoriesResponseModelLocalizedName().fromJson(v));
    });
  }
  if (json['description'] != null) {
    data.description = json['description'];
  }
  if (json['category_template_id'] != null) {
    data.categoryTemplateId = json['category_template_id']?.toInt();
  }
  if (json['meta_keywords'] != null) {
    data.metaKeywords = json['meta_keywords']?.toString();
  }
  if (json['meta_description'] != null) {
    data.metaDescription = json['meta_description']?.toString();
  }
  if (json['meta_title'] != null) {
    data.metaTitle = json['meta_title']?.toString();
  }
  if (json['parent_category_id'] != null) {
    data.parentCategoryId = json['parent_category_id']?.toInt();
  }
  if (json['page_size'] != null) {
    data.pageSize = json['page_size']?.toInt();
  }
  if (json['page_size_options'] != null) {
    data.pageSizeOptions = json['page_size_options']?.toString();
  }
  if (json['price_ranges'] != null) {
    data.priceRanges = json['price_ranges'];
  }
  if (json['show_on_home_page'] != null) {
    data.showOnHomePage = json['show_on_home_page'];
  }
  if (json['include_in_top_menu'] != null) {
    data.includeInTopMenu = json['include_in_top_menu'];
  }
  if (json['has_discounts_applied'] != null) {
    data.hasDiscountsApplied = json['has_discounts_applied'];
  }
  if (json['published'] != null) {
    data.published = json['published'];
  }
  if (json['deleted'] != null) {
    data.deleted = json['deleted'];
  }
  if (json['display_order'] != null) {
    data.displayOrder = json['display_order']?.toInt();
  }
  if (json['created_on_utc'] != null) {
    data.createdOnUtc = json['created_on_utc']?.toString();
  }
  if (json['updated_on_utc'] != null) {
    data.updatedOnUtc = json['updated_on_utc']?.toString();
  }
  if (json['role_ids'] != null) {
    data.roleIds = new List<dynamic>();
    data.roleIds.addAll(json['role_ids']);
  }
  if (json['discount_ids'] != null) {
    data.discountIds = new List<dynamic>();
    data.discountIds.addAll(json['discount_ids']);
  }
  if (json['store_ids'] != null) {
    data.storeIds = new List<dynamic>();
    data.storeIds.addAll(json['store_ids']);
  }
  if (json['image'] != null) {
    data.image = new OfferCategoriesResponseModelImage().fromJson(json['image']);
  }
  if (json['se_name'] != null) {
    data.seName = json['se_name']?.toString();
  }
  if (json['is_leaf'] != null) {
    data.isLeaf = json['is_leaf'];
  }
  return data;
}

Map<String, dynamic> offerCategoriesResponseModelToJson(PackagesCategoriesResponseModel entity) {
  final Map<String, dynamic> data = new Map<String, dynamic>();
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['namen'] = entity.namen;
  if (entity.localizedNames != null) {
    data['localized_names'] = entity.localizedNames.map((v) => v.toJson()).toList();
  }
  data['description'] = entity.description;
  data['category_template_id'] = entity.categoryTemplateId;
  data['meta_keywords'] = entity.metaKeywords;
  data['meta_description'] = entity.metaDescription;
  data['meta_title'] = entity.metaTitle;
  data['parent_category_id'] = entity.parentCategoryId;
  data['page_size'] = entity.pageSize;
  data['page_size_options'] = entity.pageSizeOptions;
  data['price_ranges'] = entity.priceRanges;
  data['show_on_home_page'] = entity.showOnHomePage;
  data['include_in_top_menu'] = entity.includeInTopMenu;
  data['has_discounts_applied'] = entity.hasDiscountsApplied;
  data['published'] = entity.published;
  data['deleted'] = entity.deleted;
  data['display_order'] = entity.displayOrder;
  data['created_on_utc'] = entity.createdOnUtc;
  data['updated_on_utc'] = entity.updatedOnUtc;
  if (entity.roleIds != null) {
    data['role_ids'] = [];
  }
  if (entity.discountIds != null) {
    data['discount_ids'] = [];
  }
  if (entity.storeIds != null) {
    data['store_ids'] = [];
  }
  if (entity.image != null) {
    data['image'] = entity.image.toJson();
  }
  data['se_name'] = entity.seName;
  data['is_leaf'] = entity.isLeaf;
  return data;
}

offerCategoriesResponseModelLocalizedNameFromJson(OfferCategoriesResponseModelLocalizedName data, Map<String, dynamic> json) {
  if (json['language_id'] != null) {
    data.languageId = json['language_id']?.toInt();
  }
  if (json['localized_name'] != null) {
    data.localizedName = json['localized_name']?.toString();
  }
  return data;
}

Map<String, dynamic> offerCategoriesResponseModelLocalizedNameToJson(OfferCategoriesResponseModelLocalizedName entity) {
  final Map<String, dynamic> data = new Map<String, dynamic>();
  data['language_id'] = entity.languageId;
  data['localized_name'] = entity.localizedName;
  return data;
}

offerCategoriesResponseModelImageFromJson(OfferCategoriesResponseModelImage data, Map<String, dynamic> json) {
  if (json['src'] != null) {
    data.src = json['src']?.toString();
  }
  if (json['thumb'] != null) {
    data.thumb = json['thumb'];
  }
  if (json['attachment'] != null) {
    data.attachment = json['attachment'];
  }
  return data;
}

Map<String, dynamic> offerCategoriesResponseModelImageToJson(OfferCategoriesResponseModelImage entity) {
  final Map<String, dynamic> data = new Map<String, dynamic>();
  data['src'] = entity.src;
  data['thumb'] = entity.thumb;
  data['attachment'] = entity.attachment;
  return data;
}
