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

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

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

ServiceInProgressList $ServiceInProgressListFromJson(Map<String, dynamic> json) {
  final ServiceInProgressList serviceInProgressList = ServiceInProgressList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    serviceInProgressList.id = id;
  }
  final String? sn = jsonConvert.convert<String>(json['sn']);
  if (sn != null) {
    serviceInProgressList.sn = sn;
  }
  final String? userNotes = jsonConvert.convert<String>(json['user_notes']);
  if (userNotes != null) {
    serviceInProgressList.userNotes = userNotes;
  }
  final String? merchantNotes = jsonConvert.convert<String>(json['merchant_notes']);
  if (merchantNotes != null) {
    serviceInProgressList.merchantNotes = merchantNotes;
  }
  final String? orderStatus = jsonConvert.convert<String>(json['order_status']);
  if (orderStatus != null) {
    serviceInProgressList.orderStatus = orderStatus;
  }
  final ServiceInProgressListService? service = jsonConvert.convert<ServiceInProgressListService>(json['service']);
  if (service != null) {
    serviceInProgressList.service = service;
  }
  final ServiceInProgressListMerchant? merchant = jsonConvert.convert<ServiceInProgressListMerchant>(json['merchant']);
  if (merchant != null) {
    serviceInProgressList.merchant = merchant;
  }
  final String? staff = jsonConvert.convert<String>(json['staff']);
  if (staff != null) {
    serviceInProgressList.staff = staff;
  }
  return serviceInProgressList;
}

Map<String, dynamic> $ServiceInProgressListToJson(ServiceInProgressList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sn'] = entity.sn;
  data['user_notes'] = entity.userNotes;
  data['merchant_notes'] = entity.merchantNotes;
  data['order_status'] = entity.orderStatus;
  data['service'] = entity.service.toJson();
  data['merchant'] = entity.merchant.toJson();
  data['staff'] = entity.staff;
  return data;
}

extension ServiceInProgressListExtension on ServiceInProgressList {
  ServiceInProgressList copyWith({
    int? id,
    String? sn,
    String? userNotes,
    String? merchantNotes,
    String? orderStatus,
    ServiceInProgressListService? service,
    ServiceInProgressListMerchant? merchant,
    String? staff,
  }) {
    return ServiceInProgressList()
      ..id = id ?? this.id
      ..sn = sn ?? this.sn
      ..userNotes = userNotes ?? this.userNotes
      ..merchantNotes = merchantNotes ?? this.merchantNotes
      ..orderStatus = orderStatus ?? this.orderStatus
      ..service = service ?? this.service
      ..merchant = merchant ?? this.merchant
      ..staff = staff ?? this.staff;
  }
}

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

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

extension ServiceInProgressListServiceExtension on ServiceInProgressListService {
  ServiceInProgressListService copyWith({
    int? id,
    String? name,
  }) {
    return ServiceInProgressListService()
      ..id = id ?? this.id
      ..name = name ?? this.name;
  }
}

ServiceInProgressListMerchant $ServiceInProgressListMerchantFromJson(Map<String, dynamic> json) {
  final ServiceInProgressListMerchant serviceInProgressListMerchant = ServiceInProgressListMerchant();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    serviceInProgressListMerchant.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceInProgressListMerchant.name = name;
  }
  final String? contactPhone = jsonConvert.convert<String>(json['contact_phone']);
  if (contactPhone != null) {
    serviceInProgressListMerchant.contactPhone = contactPhone;
  }
  return serviceInProgressListMerchant;
}

Map<String, dynamic> $ServiceInProgressListMerchantToJson(ServiceInProgressListMerchant entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['contact_phone'] = entity.contactPhone;
  return data;
}

extension ServiceInProgressListMerchantExtension on ServiceInProgressListMerchant {
  ServiceInProgressListMerchant copyWith({
    int? id,
    String? name,
    String? contactPhone,
  }) {
    return ServiceInProgressListMerchant()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..contactPhone = contactPhone ?? this.contactPhone;
  }
}