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

RewardsIndexEntity $RewardsIndexEntityFromJson(Map<String, dynamic> json) {
  final RewardsIndexEntity rewardsIndexEntity = RewardsIndexEntity();
  final int? points = jsonConvert.convert<int>(json['points']);
  if (points != null) {
    rewardsIndexEntity.points = points;
  }
  final RewardsIndexContinuous? continuous = jsonConvert.convert<RewardsIndexContinuous>(json['continuous']);
  if (continuous != null) {
    rewardsIndexEntity.continuous = continuous;
  }
  final RewardsIndexTasks? tasks = jsonConvert.convert<RewardsIndexTasks>(json['tasks']);
  if (tasks != null) {
    rewardsIndexEntity.tasks = tasks;
  }
  final List<dynamic>? latest = (json['latest'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (latest != null) {
    rewardsIndexEntity.latest = latest;
  }
  return rewardsIndexEntity;
}

Map<String, dynamic> $RewardsIndexEntityToJson(RewardsIndexEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['points'] = entity.points;
  data['continuous'] = entity.continuous?.toJson();
  data['tasks'] = entity.tasks?.toJson();
  data['latest'] = entity.latest;
  return data;
}

extension RewardsIndexEntityExtension on RewardsIndexEntity {
  RewardsIndexEntity copyWith({
    int? points,
    RewardsIndexContinuous? continuous,
    RewardsIndexTasks? tasks,
    List<dynamic>? latest,
  }) {
    return RewardsIndexEntity()
      ..points = points ?? this.points
      ..continuous = continuous ?? this.continuous
      ..tasks = tasks ?? this.tasks
      ..latest = latest ?? this.latest;
  }
}

RewardsIndexContinuous $RewardsIndexContinuousFromJson(Map<String, dynamic> json) {
  final RewardsIndexContinuous rewardsIndexContinuous = RewardsIndexContinuous();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    rewardsIndexContinuous.count = count;
  }
  final List<dynamic>? currentWeekCheckin = (json['current_week_checkin'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (currentWeekCheckin != null) {
    rewardsIndexContinuous.currentWeekCheckin = currentWeekCheckin;
  }
  return rewardsIndexContinuous;
}

Map<String, dynamic> $RewardsIndexContinuousToJson(RewardsIndexContinuous entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['current_week_checkin'] = entity.currentWeekCheckin;
  return data;
}

extension RewardsIndexContinuousExtension on RewardsIndexContinuous {
  RewardsIndexContinuous copyWith({
    int? count,
    List<dynamic>? currentWeekCheckin,
  }) {
    return RewardsIndexContinuous()
      ..count = count ?? this.count
      ..currentWeekCheckin = currentWeekCheckin ?? this.currentWeekCheckin;
  }
}

RewardsIndexTasks $RewardsIndexTasksFromJson(Map<String, dynamic> json) {
  final RewardsIndexTasks rewardsIndexTasks = RewardsIndexTasks();
  final bool? dailyCheckin = jsonConvert.convert<bool>(json['daily_checkin']);
  if (dailyCheckin != null) {
    rewardsIndexTasks.dailyCheckin = dailyCheckin;
  }
  final bool? newsFeedPost = jsonConvert.convert<bool>(json['news_feed_post']);
  if (newsFeedPost != null) {
    rewardsIndexTasks.newsFeedPost = newsFeedPost;
  }
  final int? give10Likes = jsonConvert.convert<int>(json['give_10_likes']);
  if (give10Likes != null) {
    rewardsIndexTasks.give10Likes = give10Likes;
  }
  return rewardsIndexTasks;
}

Map<String, dynamic> $RewardsIndexTasksToJson(RewardsIndexTasks entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['daily_checkin'] = entity.dailyCheckin;
  data['news_feed_post'] = entity.newsFeedPost;
  data['give_10_likes'] = entity.give10Likes;
  return data;
}

extension RewardsIndexTasksExtension on RewardsIndexTasks {
  RewardsIndexTasks copyWith({
    bool? dailyCheckin,
    bool? newsFeedPost,
    int? give10Likes,
  }) {
    return RewardsIndexTasks()
      ..dailyCheckin = dailyCheckin ?? this.dailyCheckin
      ..newsFeedPost = newsFeedPost ?? this.newsFeedPost
      ..give10Likes = give10Likes ?? this.give10Likes;
  }
}