import 'package:hello_wallpaper/generated/json/base/json_convert_content.dart';
import 'package:hello_wallpaper/models/wallpaper_model.dart';

WallpaperModel $WallpaperModelFromJson(Map<String, dynamic> json) {
  final WallpaperModel wallpaperModel = WallpaperModel();
  final List<WallpaperData>? data = (json['data'] as List<dynamic>?)
      ?.map((e) => jsonConvert.convert<WallpaperData>(e) as WallpaperData)
      .toList();
  if (data != null) {
    wallpaperModel.data = data;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    wallpaperModel.name = name;
  }
  return wallpaperModel;
}

Map<String, dynamic> $WallpaperModelToJson(WallpaperModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['name'] = entity.name;
  return data;
}

extension WallpaperModelExtension on WallpaperModel {
  WallpaperModel copyWith({
    List<WallpaperData>? data,
    String? name,
  }) {
    return WallpaperModel()
      ..data = data ?? this.data
      ..name = name ?? this.name;
  }
}

WallpaperData $WallpaperDataFromJson(Map<String, dynamic> json) {
  final WallpaperData wallpaperData = WallpaperData();
  final String? banner = jsonConvert.convert<String>(json['banner']);
  if (banner != null) {
    wallpaperData.banner = banner;
  }
  final String? original = jsonConvert.convert<String>(json['original']);
  if (original != null) {
    wallpaperData.original = original;
  }
  final String? previewThumb =
      jsonConvert.convert<String>(json['previewThumb']);
  if (previewThumb != null) {
    wallpaperData.previewThumb = previewThumb;
  }
  final String? source = jsonConvert.convert<String>(json['source']);
  if (source != null) {
    wallpaperData.source = source;
  }
  return wallpaperData;
}

Map<String, dynamic> $WallpaperDataToJson(WallpaperData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['banner'] = entity.banner;
  data['original'] = entity.original;
  data['previewThumb'] = entity.previewThumb;
  data['source'] = entity.source;
  return data;
}

extension WallpaperDataExtension on WallpaperData {
  WallpaperData copyWith({
    String? banner,
    String? original,
    String? previewThumb,
    String? source,
  }) {
    return WallpaperData()
      ..banner = banner ?? this.banner
      ..original = original ?? this.original
      ..previewThumb = previewThumb ?? this.previewThumb
      ..source = source ?? this.source;
  }
}
