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

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

  factory CurrencyListResponse.fromJson(Map<String, dynamic> json) {
    return CurrencyListResponse(
      success: json['success'] ?? false,
      message: json['message'] ?? '',
      data: (json['data'] as List<dynamic>? ?? [])
          .map((e) => Currency.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 Currency {
  final String id;
  final String currencyCode;
  final String currencyName;
  final String symbol;
  final bool isActive;

  Currency({
    required this.id,
    required this.currencyCode,
    required this.currencyName,
    required this.symbol,
    required this.isActive,
  });

  factory Currency.fromJson(Map<String, dynamic> json) {
    return Currency(
      id: json['id'] ?? '',
      currencyCode: json['currencyCode'] ?? '',
      currencyName: json['currencyName'] ?? '',
      symbol: json['symbol'] ?? '',
      isActive: json['isActive'] ?? false,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'currencyCode': currencyCode,
      'currencyName': currencyName,
      'symbol': symbol,
      'isActive': isActive,
    };
  }
}
