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

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

  factory ExpenseCategoryResponse.fromJson(Map<String, dynamic> json) {
    return ExpenseCategoryResponse(
      success: json['success'] ?? false,
      message: json['message'] ?? '',
      data: (json['data'] as List<dynamic>? ?? [])
          .map((e) => ExpenseCategory.fromJson(e))
          .toList(),
      errors: json['errors'],
      statusCode: json['statusCode'] ?? 0,
      timestamp: DateTime.parse(json['timestamp']),
    );
  }

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

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

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

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

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