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

RewardsMyDetailEntity $RewardsMyDetailEntityFromJson(Map<String, dynamic> json) {
  final RewardsMyDetailEntity rewardsMyDetailEntity = RewardsMyDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsMyDetailEntity.id = id;
  }
  final int? redemptionCode = jsonConvert.convert<int>(json['redemption_code']);
  if (redemptionCode != null) {
    rewardsMyDetailEntity.redemptionCode = redemptionCode;
  }
  final String? usedAt = jsonConvert.convert<String>(json['used_at']);
  if (usedAt != null) {
    rewardsMyDetailEntity.usedAt = usedAt;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    rewardsMyDetailEntity.createdAt = createdAt;
  }
  final String? expiredAt = jsonConvert.convert<String>(json['expired_at']);
  if (expiredAt != null) {
    rewardsMyDetailEntity.expiredAt = expiredAt;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    rewardsMyDetailEntity.quantity = quantity;
  }
  final RewardsMyDetailReward? reward = jsonConvert.convert<RewardsMyDetailReward>(json['reward']);
  if (reward != null) {
    rewardsMyDetailEntity.reward = reward;
  }
  final RewardsMyDetailAccount? account = jsonConvert.convert<RewardsMyDetailAccount>(json['account']);
  if (account != null) {
    rewardsMyDetailEntity.account = account;
  }
  return rewardsMyDetailEntity;
}

Map<String, dynamic> $RewardsMyDetailEntityToJson(RewardsMyDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['redemption_code'] = entity.redemptionCode;
  data['used_at'] = entity.usedAt;
  data['created_at'] = entity.createdAt;
  data['expired_at'] = entity.expiredAt;
  data['quantity'] = entity.quantity;
  data['reward'] = entity.reward.toJson();
  data['account'] = entity.account.toJson();
  return data;
}

extension RewardsMyDetailEntityExtension on RewardsMyDetailEntity {
  RewardsMyDetailEntity copyWith({
    int? id,
    int? redemptionCode,
    String? usedAt,
    String? createdAt,
    String? expiredAt,
    int? quantity,
    RewardsMyDetailReward? reward,
    RewardsMyDetailAccount? account,
  }) {
    return RewardsMyDetailEntity()
      ..id = id ?? this.id
      ..redemptionCode = redemptionCode ?? this.redemptionCode
      ..usedAt = usedAt ?? this.usedAt
      ..createdAt = createdAt ?? this.createdAt
      ..expiredAt = expiredAt ?? this.expiredAt
      ..quantity = quantity ?? this.quantity
      ..reward = reward ?? this.reward
      ..account = account ?? this.account;
  }
}

RewardsMyDetailAccount $RewardsMyDetailAccountFromJson(Map<String, dynamic> json) {
  final RewardsMyDetailAccount rewardsMyDetailAccount = RewardsMyDetailAccount();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsMyDetailAccount.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    rewardsMyDetailAccount.name = name;
  }
  final int? phone = jsonConvert.convert<int>(json['phone']);
  if (phone != null) {
    rewardsMyDetailAccount.phone = phone;
  }
  return rewardsMyDetailAccount;
}

Map<String, dynamic> $RewardsMyDetailAccountToJson(RewardsMyDetailAccount entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['phone'] = entity.phone;
  return data;
}

extension RewardsMyDetailAccountExtension on RewardsMyDetailAccount {
  RewardsMyDetailAccount copyWith({
    int? id,
    String? name,
    int? phone,
  }) {
    return RewardsMyDetailAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..phone = phone ?? this.phone;
  }
}

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

Map<String, dynamic> $RewardsMyDetailRewardToJson(RewardsMyDetailReward 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 RewardsMyDetailRewardExtension on RewardsMyDetailReward {
  RewardsMyDetailReward copyWith({
    int? id,
    String? title,
    List<String>? resources,
    int? originalPoint,
    int? point,
    String? redeemedStart,
    String? redeemedEnd,
  }) {
    return RewardsMyDetailReward()
      ..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;
  }
}