import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/rewards_home_entity.dart';

RewardsHomeEntity $RewardsHomeEntityFromJson(Map<String, dynamic> json) {
  final RewardsHomeEntity rewardsHomeEntity = RewardsHomeEntity();
  final List<RewardsHomeData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RewardsHomeData>(e) as RewardsHomeData).toList();
  if (data != null) {
    rewardsHomeEntity.data = data;
  }
  final String? message = jsonConvert.convert<String>(json['message']);
  if (message != null) {
    rewardsHomeEntity.message = message;
  }
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    rewardsHomeEntity.code = code;
  }
  return rewardsHomeEntity;
}

Map<String, dynamic> $RewardsHomeEntityToJson(RewardsHomeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  data['message'] = entity.message;
  data['code'] = entity.code;
  return data;
}

extension RewardsHomeEntityExtension on RewardsHomeEntity {
  RewardsHomeEntity copyWith({
    List<RewardsHomeData>? data,
    String? message,
    int? code,
  }) {
    return RewardsHomeEntity()
      ..data = data ?? this.data
      ..message = message ?? this.message
      ..code = code ?? this.code;
  }
}

RewardsHomeData $RewardsHomeDataFromJson(Map<String, dynamic> json) {
  final RewardsHomeData rewardsHomeData = RewardsHomeData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsHomeData.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    rewardsHomeData.name = name;
  }
  final List<RewardsHomeDataRewards>? rewards = (json['rewards'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RewardsHomeDataRewards>(e) as RewardsHomeDataRewards).toList();
  if (rewards != null) {
    rewardsHomeData.rewards = rewards;
  }
  return rewardsHomeData;
}

Map<String, dynamic> $RewardsHomeDataToJson(RewardsHomeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['rewards'] = entity.rewards.map((v) => v.toJson()).toList();
  return data;
}

extension RewardsHomeDataExtension on RewardsHomeData {
  RewardsHomeData copyWith({
    int? id,
    String? name,
    List<RewardsHomeDataRewards>? rewards,
  }) {
    return RewardsHomeData()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..rewards = rewards ?? this.rewards;
  }
}

RewardsHomeDataRewards $RewardsHomeDataRewardsFromJson(Map<String, dynamic> json) {
  final RewardsHomeDataRewards rewardsHomeDataRewards = RewardsHomeDataRewards();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsHomeDataRewards.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    rewardsHomeDataRewards.name = name;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    rewardsHomeDataRewards.resources = resources;
  }
  final int? originalPoint = jsonConvert.convert<int>(json['original_point']);
  if (originalPoint != null) {
    rewardsHomeDataRewards.originalPoint = originalPoint;
  }
  final int? point = jsonConvert.convert<int>(json['point']);
  if (point != null) {
    rewardsHomeDataRewards.point = point;
  }
  return rewardsHomeDataRewards;
}

Map<String, dynamic> $RewardsHomeDataRewardsToJson(RewardsHomeDataRewards entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['resources'] = entity.resources;
  data['original_point'] = entity.originalPoint;
  data['point'] = entity.point;
  return data;
}

extension RewardsHomeDataRewardsExtension on RewardsHomeDataRewards {
  RewardsHomeDataRewards copyWith({
    int? id,
    String? name,
    List<String>? resources,
    int? originalPoint,
    int? point,
  }) {
    return RewardsHomeDataRewards()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..resources = resources ?? this.resources
      ..originalPoint = originalPoint ?? this.originalPoint
      ..point = point ?? this.point;
  }
}