class ServiceListHistoryModel {
  final String? status;
  final dynamic draw;
  final int? recordsTotal;
  final int? recordsFiltered;
  final List<ServiceHistoryData>? data;

  ServiceListHistoryModel({
    this.status,
    this.draw,
    this.recordsTotal,
    this.recordsFiltered,
    this.data,
  });

  factory ServiceListHistoryModel.fromJson(Map<String, dynamic> json) {
    return ServiceListHistoryModel(
      status: json['status'] as String?,
      draw: json['draw'],
      recordsTotal: json['recordsTotal'] is int
          ? json['recordsTotal']
          : int.tryParse(json['recordsTotal']?.toString() ?? ''),
      recordsFiltered: json['recordsFiltered'] is int
          ? json['recordsFiltered']
          : int.tryParse(json['recordsFiltered']?.toString() ?? ''),
      data: (json['data'] as List?)
          ?.map((e) => ServiceHistoryData.fromJson(e))
          .toList(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'status': status,
      'draw': draw,
      'recordsTotal': recordsTotal,
      'recordsFiltered': recordsFiltered,
      'data': data?.map((e) => e.toJson()).toList(),
    };
  }
}

class ServiceHistoryData {
  final int? id;
  final String? paymentStatus;
  final String? paymentAmount;
  final String? status;
  final String? service;
  final String? message;
  final String? createdDate;
  final String? createdTime;

  ServiceHistoryData({
    this.id,
    this.paymentStatus,
    this.paymentAmount,
    this.status,
    this.service,
    this.message,
    this.createdDate,
    this.createdTime,
  });

  factory ServiceHistoryData.fromJson(Map<String, dynamic> json) {
    return ServiceHistoryData(
      id: json['id'] is int
          ? json['id']
          : int.tryParse(json['id']?.toString() ?? ''),
      paymentStatus: json['payment_status']?.toString(),
      paymentAmount: json['payment_amount']?.toString(),
      status: json['status']?.toString(),
      service: json['service']?.toString(),
      message: json['message']?.toString(),
      createdDate: json['created_date']?.toString(),
      createdTime: json['created_time']?.toString(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'payment_status': paymentStatus,
      'payment_amount': paymentAmount,
      'status': status,
      'service': service,
      'message': message,
      'created_date': createdDate,
      'created_time': createdTime,
    };
  }
}
