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

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

Map<String, dynamic> $RewardsHistoryEarnedEntityToJson(RewardsHistoryEarnedEntity 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 RewardsHistoryEarnedEntityExtension on RewardsHistoryEarnedEntity {
  RewardsHistoryEarnedEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<RewardsHistoryEarnedList>? list,
  }) {
    return RewardsHistoryEarnedEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

RewardsHistoryEarnedList $RewardsHistoryEarnedListFromJson(Map<String, dynamic> json) {
  final RewardsHistoryEarnedList rewardsHistoryEarnedList = RewardsHistoryEarnedList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsHistoryEarnedList.id = id;
  }
  final int? point = jsonConvert.convert<int>(json['point']);
  if (point != null) {
    rewardsHistoryEarnedList.point = point;
  }
  final String? shortDescription = jsonConvert.convert<String>(json['short_description']);
  if (shortDescription != null) {
    rewardsHistoryEarnedList.shortDescription = shortDescription;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    rewardsHistoryEarnedList.createdAt = createdAt;
  }
  return rewardsHistoryEarnedList;
}

Map<String, dynamic> $RewardsHistoryEarnedListToJson(RewardsHistoryEarnedList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['point'] = entity.point;
  data['short_description'] = entity.shortDescription;
  data['created_at'] = entity.createdAt;
  return data;
}

extension RewardsHistoryEarnedListExtension on RewardsHistoryEarnedList {
  RewardsHistoryEarnedList copyWith({
    int? id,
    int? point,
    String? shortDescription,
    String? createdAt,
  }) {
    return RewardsHistoryEarnedList()
      ..id = id ?? this.id
      ..point = point ?? this.point
      ..shortDescription = shortDescription ?? this.shortDescription
      ..createdAt = createdAt ?? this.createdAt;
  }
}