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

RewardsListEntity $RewardsListEntityFromJson(Map<String, dynamic> json) {
  final RewardsListEntity rewardsListEntity = RewardsListEntity();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    rewardsListEntity.count = count;
  }
  final int? page = jsonConvert.convert<int>(json['page']);
  if (page != null) {
    rewardsListEntity.page = page;
  }
  final int? limit = jsonConvert.convert<int>(json['limit']);
  if (limit != null) {
    rewardsListEntity.limit = limit;
  }
  final int? countPage = jsonConvert.convert<int>(json['count_page']);
  if (countPage != null) {
    rewardsListEntity.countPage = countPage;
  }
  final List<RewardsListList>? list = (json['list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RewardsListList>(e) as RewardsListList).toList();
  if (list != null) {
    rewardsListEntity.list = list;
  }
  return rewardsListEntity;
}

Map<String, dynamic> $RewardsListEntityToJson(RewardsListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['page'] = entity.page;
  data['limit'] = entity.limit;
  data['count_page'] = entity.countPage;
  data['list'] = entity.list.map((v) => v.toJson()).toList();
  return data;
}

extension RewardsListEntityExtension on RewardsListEntity {
  RewardsListEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<RewardsListList>? list,
  }) {
    return RewardsListEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

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

Map<String, dynamic> $RewardsListListToJson(RewardsListList 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 RewardsListListExtension on RewardsListList {
  RewardsListList copyWith({
    int? id,
    String? name,
    List<String>? resources,
    int? originalPoint,
    int? point,
  }) {
    return RewardsListList()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..resources = resources ?? this.resources
      ..originalPoint = originalPoint ?? this.originalPoint
      ..point = point ?? this.point;
  }
}