class ExpenseTypeResponse {
  final bool success;
  final String message;
  final List<ExpenseTypeData> data;
  final dynamic errors;
  final int statusCode;
  final DateTime timestamp;

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

  factory ExpenseTypeResponse.fromJson(Map<String, dynamic> json) {
    return ExpenseTypeResponse(
      success: json['success'] ?? false,
      message: json['message'] ?? '',
      data: json['data'] != null
          ? List<ExpenseTypeData>.from(
              json['data'].map((x) => ExpenseTypeData.fromJson(x)))
          : [],
      errors: json['errors'],
      statusCode: json['statusCode'] ?? 0,
      timestamp: DateTime.parse(json['timestamp']),
    );
  }

  Map<String, dynamic> toJson() => {
        'success': success,
        'message': message,
        'data': data.map((x) => x.toJson()).toList(),
        'errors': errors,
        'statusCode': statusCode,
        'timestamp': timestamp.toIso8601String(),
      };
}

class ExpenseTypeData {
  final String id;
  final String name;
  final bool noOfPersonsRequired;
  final bool isAttachmentRequried;
  final String description;

  ExpenseTypeData({
    required this.id,
    required this.name,
    required this.noOfPersonsRequired,
    required this.isAttachmentRequried,
    required this.description,
  });

  factory ExpenseTypeData.fromJson(Map<String, dynamic> json) {
    return ExpenseTypeData(
      id: json['id'] ?? '',
      name: json['name'] ?? '',
      noOfPersonsRequired: json['noOfPersonsRequired'] ?? false,
      isAttachmentRequried: json['isAttachmentRequried'] ?? false,
      description: json['description'] ?? '',
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
        'noOfPersonsRequired': noOfPersonsRequired,
        'isAttachmentRequried': isAttachmentRequried,
        'description': description,
      };
}
