class DocumentFiltersResponse {
  final bool success;
  final String message;
  final DocumentFiltersData? data;
  final dynamic errors;
  final int statusCode;
  final DateTime timestamp;

  DocumentFiltersResponse({
    required this.success,
    required this.message,
    this.data,
    this.errors,
    required this.statusCode,
    required this.timestamp,
  });

  factory DocumentFiltersResponse.fromJson(Map<String, dynamic> json) {
    return DocumentFiltersResponse(
      success: json['success'],
      message: json['message'],
      data: json['data'] != null
          ? DocumentFiltersData.fromJson(json['data'])
          : null,
      errors: json['errors'],
      statusCode: json['statusCode'],
      timestamp: DateTime.parse(json['timestamp']),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "success": success,
      "message": message,
      "data": data?.toJson(),
      "errors": errors,
      "statusCode": statusCode,
      "timestamp": timestamp.toIso8601String(),
    };
  }
}

class DocumentFiltersData {
  final List<FilterItem> uploadedBy;
  final List<FilterItem> documentCategory;
  final List<FilterItem> documentType;
  final List<FilterItem> documentTag;

  DocumentFiltersData({
    required this.uploadedBy,
    required this.documentCategory,
    required this.documentType,
    required this.documentTag,
  });

  factory DocumentFiltersData.fromJson(Map<String, dynamic> json) {
    return DocumentFiltersData(
      uploadedBy: (json['uploadedBy'] as List<dynamic>)
          .map((e) => FilterItem.fromJson(e))
          .toList(),
      documentCategory: (json['documentCategory'] as List<dynamic>)
          .map((e) => FilterItem.fromJson(e))
          .toList(),
      documentType: (json['documentType'] as List<dynamic>)
          .map((e) => FilterItem.fromJson(e))
          .toList(),
      documentTag: (json['documentTag'] as List<dynamic>)
          .map((e) => FilterItem.fromJson(e))
          .toList(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "uploadedBy": uploadedBy.map((e) => e.toJson()).toList(),
      "documentCategory": documentCategory.map((e) => e.toJson()).toList(),
      "documentType": documentType.map((e) => e.toJson()).toList(),
      "documentTag": documentTag.map((e) => e.toJson()).toList(),
    };
  }
}

class FilterItem {
  final String id;
  final String name;

  FilterItem({
    required this.id,
    required this.name,
  });

  factory FilterItem.fromJson(Map<String, dynamic> json) {
    return FilterItem(
      id: json['id'],
      name: json['name'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "id": id,
      "name": name,
    };
  }
}
