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

RewardsBuyEntity $RewardsBuyEntityFromJson(Map<String, dynamic> json) {
  final RewardsBuyEntity rewardsBuyEntity = RewardsBuyEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsBuyEntity.id = id;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    rewardsBuyEntity.createdAt = createdAt;
  }
  final RewardsBuyReward? reward = jsonConvert.convert<RewardsBuyReward>(json['reward']);
  if (reward != null) {
    rewardsBuyEntity.reward = reward;
  }
  return rewardsBuyEntity;
}

Map<String, dynamic> $RewardsBuyEntityToJson(RewardsBuyEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['created_at'] = entity.createdAt;
  data['reward'] = entity.reward.toJson();
  return data;
}

extension RewardsBuyEntityExtension on RewardsBuyEntity {
  RewardsBuyEntity copyWith({
    int? id,
    String? createdAt,
    RewardsBuyReward? reward,
  }) {
    return RewardsBuyEntity()
      ..id = id ?? this.id
      ..createdAt = createdAt ?? this.createdAt
      ..reward = reward ?? this.reward;
  }
}

RewardsBuyReward $RewardsBuyRewardFromJson(Map<String, dynamic> json) {
  final RewardsBuyReward rewardsBuyReward = RewardsBuyReward();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    rewardsBuyReward.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    rewardsBuyReward.title = title;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    rewardsBuyReward.resources = resources;
  }
  final int? originalPoint = jsonConvert.convert<int>(json['original_point']);
  if (originalPoint != null) {
    rewardsBuyReward.originalPoint = originalPoint;
  }
  final int? point = jsonConvert.convert<int>(json['point']);
  if (point != null) {
    rewardsBuyReward.point = point;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    rewardsBuyReward.description = description;
  }
  final bool? reservation = jsonConvert.convert<bool>(json['reservation']);
  if (reservation != null) {
    rewardsBuyReward.reservation = reservation;
  }
  final String? start = jsonConvert.convert<String>(json['start']);
  if (start != null) {
    rewardsBuyReward.start = start;
  }
  final String? end = jsonConvert.convert<String>(json['end']);
  if (end != null) {
    rewardsBuyReward.end = end;
  }
  final String? redeemedStart = jsonConvert.convert<String>(json['redeemed_start']);
  if (redeemedStart != null) {
    rewardsBuyReward.redeemedStart = redeemedStart;
  }
  final String? redeemedEnd = jsonConvert.convert<String>(json['redeemed_end']);
  if (redeemedEnd != null) {
    rewardsBuyReward.redeemedEnd = redeemedEnd;
  }
  final String? package = jsonConvert.convert<String>(json['package']);
  if (package != null) {
    rewardsBuyReward.package = package;
  }
  final String? notice = jsonConvert.convert<String>(json['notice']);
  if (notice != null) {
    rewardsBuyReward.notice = notice;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    rewardsBuyReward.createdAt = createdAt;
  }
  final List<RewardsBuyRewardRedeemable>? redeemable = (json['redeemable'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RewardsBuyRewardRedeemable>(e) as RewardsBuyRewardRedeemable).toList();
  if (redeemable != null) {
    rewardsBuyReward.redeemable = redeemable;
  }
  return rewardsBuyReward;
}

Map<String, dynamic> $RewardsBuyRewardToJson(RewardsBuyReward 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['description'] = entity.description;
  data['reservation'] = entity.reservation;
  data['start'] = entity.start;
  data['end'] = entity.end;
  data['redeemed_start'] = entity.redeemedStart;
  data['redeemed_end'] = entity.redeemedEnd;
  data['package'] = entity.package;
  data['notice'] = entity.notice;
  data['created_at'] = entity.createdAt;
  data['redeemable'] = entity.redeemable.map((v) => v.toJson()).toList();
  return data;
}

extension RewardsBuyRewardExtension on RewardsBuyReward {
  RewardsBuyReward copyWith({
    int? id,
    String? title,
    List<String>? resources,
    int? originalPoint,
    int? point,
    String? description,
    bool? reservation,
    String? start,
    String? end,
    String? redeemedStart,
    String? redeemedEnd,
    String? package,
    String? notice,
    String? createdAt,
    List<RewardsBuyRewardRedeemable>? redeemable,
  }) {
    return RewardsBuyReward()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..resources = resources ?? this.resources
      ..originalPoint = originalPoint ?? this.originalPoint
      ..point = point ?? this.point
      ..description = description ?? this.description
      ..reservation = reservation ?? this.reservation
      ..start = start ?? this.start
      ..end = end ?? this.end
      ..redeemedStart = redeemedStart ?? this.redeemedStart
      ..redeemedEnd = redeemedEnd ?? this.redeemedEnd
      ..package = package ?? this.package
      ..notice = notice ?? this.notice
      ..createdAt = createdAt ?? this.createdAt
      ..redeemable = redeemable ?? this.redeemable;
  }
}

RewardsBuyRewardRedeemable $RewardsBuyRewardRedeemableFromJson(Map<String, dynamic> json) {
  final RewardsBuyRewardRedeemable rewardsBuyRewardRedeemable = RewardsBuyRewardRedeemable();
  final String? day = jsonConvert.convert<String>(json['day']);
  if (day != null) {
    rewardsBuyRewardRedeemable.day = day;
  }
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    rewardsBuyRewardRedeemable.time = time;
  }
  return rewardsBuyRewardRedeemable;
}

Map<String, dynamic> $RewardsBuyRewardRedeemableToJson(RewardsBuyRewardRedeemable entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['day'] = entity.day;
  data['time'] = entity.time;
  return data;
}

extension RewardsBuyRewardRedeemableExtension on RewardsBuyRewardRedeemable {
  RewardsBuyRewardRedeemable copyWith({
    String? day,
    String? time,
  }) {
    return RewardsBuyRewardRedeemable()
      ..day = day ?? this.day
      ..time = time ?? this.time;
  }
}