import '../../domain/entities/kline.dart';

class KlineModel extends Kline {
  const KlineModel({
    required super.time,
    required super.open,
    required super.high,
    required super.low,
    required super.close,
    required super.volume,
  });

  factory KlineModel.fromJson(Map<String, dynamic> json) {
    return KlineModel(
      time: json['time'] != null ? DateTime.parse(json['time']) : DateTime.now(),
      open: json['open']?.toString() ?? '0',
      high: json['high']?.toString() ?? '0',
      low: json['low']?.toString() ?? '0',
      close: json['close']?.toString() ?? '0',
      volume: json['volume']?.toString() ?? '0',
    );
  }
}
