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

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

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

RewardsMyList $RewardsMyListFromJson(Map<String, dynamic> json) {
  final RewardsMyList rewardsMyList = RewardsMyList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsMyList.id = id;
  }
  final int? redemptionCode = jsonConvert.convert<int>(json['redemption_code']);
  if (redemptionCode != null) {
    rewardsMyList.redemptionCode = redemptionCode;
  }
  final String? usedAt = jsonConvert.convert<String>(json['used_at']);
  if (usedAt != null) {
    rewardsMyList.usedAt = usedAt;
  }
  final RewardsMyListReward? reward = jsonConvert.convert<RewardsMyListReward>(json['reward']);
  if (reward != null) {
    rewardsMyList.reward = reward;
  }
  return rewardsMyList;
}

Map<String, dynamic> $RewardsMyListToJson(RewardsMyList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['redemption_code'] = entity.redemptionCode;
  data['used_at'] = entity.usedAt;
  data['reward'] = entity.reward.toJson();
  return data;
}

extension RewardsMyListExtension on RewardsMyList {
  RewardsMyList copyWith({
    int? id,
    int? redemptionCode,
    String? usedAt,
    RewardsMyListReward? reward,
  }) {
    return RewardsMyList()
      ..id = id ?? this.id
      ..redemptionCode = redemptionCode ?? this.redemptionCode
      ..usedAt = usedAt ?? this.usedAt
      ..reward = reward ?? this.reward;
  }
}

RewardsMyListReward $RewardsMyListRewardFromJson(Map<String, dynamic> json) {
  final RewardsMyListReward rewardsMyListReward = RewardsMyListReward();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsMyListReward.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    rewardsMyListReward.title = title;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    rewardsMyListReward.resources = resources;
  }
  final int? originalPoint = jsonConvert.convert<int>(json['original_point']);
  if (originalPoint != null) {
    rewardsMyListReward.originalPoint = originalPoint;
  }
  final int? point = jsonConvert.convert<int>(json['point']);
  if (point != null) {
    rewardsMyListReward.point = point;
  }
  final String? redeemedStart = jsonConvert.convert<String>(json['redeemed_start']);
  if (redeemedStart != null) {
    rewardsMyListReward.redeemedStart = redeemedStart;
  }
  final String? redeemedEnd = jsonConvert.convert<String>(json['redeemed_end']);
  if (redeemedEnd != null) {
    rewardsMyListReward.redeemedEnd = redeemedEnd;
  }
  return rewardsMyListReward;
}

Map<String, dynamic> $RewardsMyListRewardToJson(RewardsMyListReward entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['resources'] = entity.resources;
  data['original_point'] = entity.originalPoint;
  data['point'] = entity.point;
  data['redeemed_start'] = entity.redeemedStart;
  data['redeemed_end'] = entity.redeemedEnd;
  return data;
}

extension RewardsMyListRewardExtension on RewardsMyListReward {
  RewardsMyListReward copyWith({
    int? id,
    String? title,
    List<String>? resources,
    int? originalPoint,
    int? point,
    String? redeemedStart,
    String? redeemedEnd,
  }) {
    return RewardsMyListReward()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..resources = resources ?? this.resources
      ..originalPoint = originalPoint ?? this.originalPoint
      ..point = point ?? this.point
      ..redeemedStart = redeemedStart ?? this.redeemedStart
      ..redeemedEnd = redeemedEnd ?? this.redeemedEnd;
  }
}