2023-01-20 21:45:37 +00:00
|
|
|
import 'package:decimal/decimal.dart';
|
|
|
|
|
2023-01-11 17:49:59 +00:00
|
|
|
class Fiat {
|
|
|
|
/// Fiat ticker
|
|
|
|
final String ticker;
|
|
|
|
|
|
|
|
/// Fiat name
|
|
|
|
final String name;
|
|
|
|
|
2023-01-20 21:45:37 +00:00
|
|
|
/// Fiat name
|
|
|
|
final Decimal min_amount;
|
|
|
|
|
|
|
|
/// Fiat name
|
|
|
|
final Decimal max_amount;
|
|
|
|
|
2023-01-11 17:49:59 +00:00
|
|
|
/// Fiat logo url
|
|
|
|
final String image;
|
|
|
|
|
2023-01-20 21:45:37 +00:00
|
|
|
Fiat(
|
|
|
|
{required this.ticker,
|
|
|
|
required this.name,
|
|
|
|
required this.min_amount,
|
|
|
|
required this.max_amount,
|
|
|
|
required this.image});
|
2023-01-11 17:49:59 +00:00
|
|
|
|
|
|
|
factory Fiat.fromJson(Map<String, dynamic> json) {
|
|
|
|
try {
|
|
|
|
return Fiat(
|
2023-01-20 21:45:37 +00:00
|
|
|
ticker: "${json['ticker']}",
|
|
|
|
name: "${json['name']}", // TODO nameFromTicker
|
|
|
|
min_amount: Decimal.parse("${json['min_amount'] ?? 0}"),
|
|
|
|
max_amount: Decimal.parse("${json['max_amount'] ?? 0}"),
|
|
|
|
image: "${json['image']}",
|
2023-01-11 17:49:59 +00:00
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
final map = {
|
|
|
|
"ticker": ticker,
|
|
|
|
"name": name,
|
2023-01-20 21:45:37 +00:00
|
|
|
"min_amount": min_amount,
|
|
|
|
"max_amount": max_amount,
|
2023-01-11 17:49:59 +00:00
|
|
|
"image": image,
|
|
|
|
};
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fiat copyWith({
|
|
|
|
String? ticker,
|
|
|
|
String? name,
|
2023-01-20 21:45:37 +00:00
|
|
|
Decimal? min_amount,
|
|
|
|
Decimal? max_amount,
|
2023-01-11 17:49:59 +00:00
|
|
|
String? image,
|
|
|
|
}) {
|
|
|
|
return Fiat(
|
|
|
|
ticker: ticker ?? this.ticker,
|
|
|
|
name: name ?? this.name,
|
2023-01-20 21:45:37 +00:00
|
|
|
min_amount: min_amount ?? this.min_amount,
|
|
|
|
max_amount: max_amount ?? this.max_amount,
|
2023-01-11 17:49:59 +00:00
|
|
|
image: image ?? this.image,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "Fiat: ${toJson()}";
|
|
|
|
}
|
|
|
|
}
|