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

StaffReviewHistorySGEntity $StaffReviewHistorySGEntityFromJson(Map<String, dynamic> json) {
  final StaffReviewHistorySGEntity staffReviewHistorySGEntity = StaffReviewHistorySGEntity();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    staffReviewHistorySGEntity.count = count;
  }
  final String? avgScore = jsonConvert.convert<String>(json['avg_score']);
  if (avgScore != null) {
    staffReviewHistorySGEntity.avgScore = avgScore;
  }
  final List<StaffReviewHistorySGReviews>? reviews = (json['reviews'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<StaffReviewHistorySGReviews>(e) as StaffReviewHistorySGReviews).toList();
  if (reviews != null) {
    staffReviewHistorySGEntity.reviews = reviews;
  }
  final int? memberId = jsonConvert.convert<int>(json['member_id']);
  if (memberId != null) {
    staffReviewHistorySGEntity.memberId = memberId;
  }
  final String? labourerName = jsonConvert.convert<String>(json['labourer_name']);
  if (labourerName != null) {
    staffReviewHistorySGEntity.labourerName = labourerName;
  }
  return staffReviewHistorySGEntity;
}

Map<String, dynamic> $StaffReviewHistorySGEntityToJson(StaffReviewHistorySGEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['avg_score'] = entity.avgScore;
  data['reviews'] = entity.reviews.map((v) => v.toJson()).toList();
  data['member_id'] = entity.memberId;
  data['labourer_name'] = entity.labourerName;
  return data;
}

extension StaffReviewHistorySGEntityExtension on StaffReviewHistorySGEntity {
  StaffReviewHistorySGEntity copyWith({
    int? count,
    String? avgScore,
    List<StaffReviewHistorySGReviews>? reviews,
    int? memberId,
    String? labourerName,
  }) {
    return StaffReviewHistorySGEntity()
      ..count = count ?? this.count
      ..avgScore = avgScore ?? this.avgScore
      ..reviews = reviews ?? this.reviews
      ..memberId = memberId ?? this.memberId
      ..labourerName = labourerName ?? this.labourerName;
  }
}

StaffReviewHistorySGReviews $StaffReviewHistorySGReviewsFromJson(Map<String, dynamic> json) {
  final StaffReviewHistorySGReviews staffReviewHistorySGReviews = StaffReviewHistorySGReviews();
  final String? employerName = jsonConvert.convert<String>(json['employer_name']);
  if (employerName != null) {
    staffReviewHistorySGReviews.employerName = employerName;
  }
  final double? attitudeRate = jsonConvert.convert<double>(json['attitude_rate']);
  if (attitudeRate != null) {
    staffReviewHistorySGReviews.attitudeRate = attitudeRate;
  }
  final double? groomingRate = jsonConvert.convert<double>(json['grooming_rate']);
  if (groomingRate != null) {
    staffReviewHistorySGReviews.groomingRate = groomingRate;
  }
  final double? performanceRate = jsonConvert.convert<double>(json['performance_rate']);
  if (performanceRate != null) {
    staffReviewHistorySGReviews.performanceRate = performanceRate;
  }
  final double? experienceRate = jsonConvert.convert<double>(json['experience_rate']);
  if (experienceRate != null) {
    staffReviewHistorySGReviews.experienceRate = experienceRate;
  }
  final String? feedback = jsonConvert.convert<String>(json['feedback']);
  if (feedback != null) {
    staffReviewHistorySGReviews.feedback = feedback;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    staffReviewHistorySGReviews.createdAt = createdAt;
  }
  return staffReviewHistorySGReviews;
}

Map<String, dynamic> $StaffReviewHistorySGReviewsToJson(StaffReviewHistorySGReviews entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['employer_name'] = entity.employerName;
  data['attitude_rate'] = entity.attitudeRate;
  data['grooming_rate'] = entity.groomingRate;
  data['performance_rate'] = entity.performanceRate;
  data['experience_rate'] = entity.experienceRate;
  data['feedback'] = entity.feedback;
  data['created_at'] = entity.createdAt;
  return data;
}

extension StaffReviewHistorySGReviewsExtension on StaffReviewHistorySGReviews {
  StaffReviewHistorySGReviews copyWith({
    String? employerName,
    double? attitudeRate,
    double? groomingRate,
    double? performanceRate,
    double? experienceRate,
    String? feedback,
    String? createdAt,
  }) {
    return StaffReviewHistorySGReviews()
      ..employerName = employerName ?? this.employerName
      ..attitudeRate = attitudeRate ?? this.attitudeRate
      ..groomingRate = groomingRate ?? this.groomingRate
      ..performanceRate = performanceRate ?? this.performanceRate
      ..experienceRate = experienceRate ?? this.experienceRate
      ..feedback = feedback ?? this.feedback
      ..createdAt = createdAt ?? this.createdAt;
  }
}