2022-08-26 08:11:35 +00:00
|
|
|
class Currency {
|
|
|
|
/// Currency ticker
|
|
|
|
final String ticker;
|
|
|
|
|
|
|
|
/// Currency name
|
|
|
|
final String name;
|
|
|
|
|
2022-10-02 19:37:11 +00:00
|
|
|
/// Currency network
|
|
|
|
final String network;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
/// Currency logo url
|
|
|
|
final String image;
|
|
|
|
|
|
|
|
/// Indicates if a currency has an Extra ID
|
|
|
|
final bool hasExternalId;
|
|
|
|
|
2022-10-02 19:37:11 +00:00
|
|
|
/// external id if it exists
|
|
|
|
final String? externalId;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
/// Indicates if a currency is a fiat currency (EUR, USD)
|
|
|
|
final bool isFiat;
|
|
|
|
|
|
|
|
/// Indicates if a currency is popular
|
|
|
|
final bool featured;
|
|
|
|
|
|
|
|
/// Indicates if a currency is stable
|
|
|
|
final bool isStable;
|
|
|
|
|
|
|
|
/// Indicates if a currency is available on a fixed-rate flow
|
|
|
|
final bool supportsFixedRate;
|
|
|
|
|
|
|
|
/// (Optional - based on api call) Indicates whether the pair is
|
|
|
|
/// currently supported by change now
|
|
|
|
final bool? isAvailable;
|
|
|
|
|
|
|
|
Currency({
|
|
|
|
required this.ticker,
|
|
|
|
required this.name,
|
2022-10-02 19:37:11 +00:00
|
|
|
required this.network,
|
2022-08-26 08:11:35 +00:00
|
|
|
required this.image,
|
|
|
|
required this.hasExternalId,
|
2022-10-02 19:37:11 +00:00
|
|
|
this.externalId,
|
2022-08-26 08:11:35 +00:00
|
|
|
required this.isFiat,
|
|
|
|
required this.featured,
|
|
|
|
required this.isStable,
|
|
|
|
required this.supportsFixedRate,
|
|
|
|
this.isAvailable,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory Currency.fromJson(Map<String, dynamic> json) {
|
|
|
|
try {
|
|
|
|
return Currency(
|
|
|
|
ticker: json["ticker"] as String,
|
|
|
|
name: json["name"] as String,
|
2022-10-03 00:49:12 +00:00
|
|
|
network: json["network"] as String? ?? "",
|
2022-08-26 08:11:35 +00:00
|
|
|
image: json["image"] as String,
|
|
|
|
hasExternalId: json["hasExternalId"] as bool,
|
2022-10-02 19:37:11 +00:00
|
|
|
externalId: json["externalId"] as String?,
|
2022-08-26 08:11:35 +00:00
|
|
|
isFiat: json["isFiat"] as bool,
|
|
|
|
featured: json["featured"] as bool,
|
|
|
|
isStable: json["isStable"] as bool,
|
|
|
|
supportsFixedRate: json["supportsFixedRate"] as bool,
|
|
|
|
isAvailable: json["isAvailable"] as bool?,
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
final map = {
|
|
|
|
"ticker": ticker,
|
|
|
|
"name": name,
|
2022-10-02 19:37:11 +00:00
|
|
|
"network": network,
|
2022-08-26 08:11:35 +00:00
|
|
|
"image": image,
|
|
|
|
"hasExternalId": hasExternalId,
|
2022-10-02 19:37:11 +00:00
|
|
|
"externalId": externalId,
|
2022-08-26 08:11:35 +00:00
|
|
|
"isFiat": isFiat,
|
|
|
|
"featured": featured,
|
|
|
|
"isStable": isStable,
|
|
|
|
"supportsFixedRate": supportsFixedRate,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isAvailable != null) {
|
|
|
|
map["isAvailable"] = isAvailable!;
|
|
|
|
}
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
Currency copyWith({
|
|
|
|
String? ticker,
|
|
|
|
String? name,
|
2022-10-02 19:37:11 +00:00
|
|
|
String? network,
|
2022-08-26 08:11:35 +00:00
|
|
|
String? image,
|
|
|
|
bool? hasExternalId,
|
2022-10-02 19:37:11 +00:00
|
|
|
String? externalId,
|
2022-08-26 08:11:35 +00:00
|
|
|
bool? isFiat,
|
|
|
|
bool? featured,
|
|
|
|
bool? isStable,
|
|
|
|
bool? supportsFixedRate,
|
|
|
|
bool? isAvailable,
|
|
|
|
}) {
|
|
|
|
return Currency(
|
|
|
|
ticker: ticker ?? this.ticker,
|
|
|
|
name: name ?? this.name,
|
2022-10-02 19:37:11 +00:00
|
|
|
network: network ?? this.network,
|
2022-08-26 08:11:35 +00:00
|
|
|
image: image ?? this.image,
|
|
|
|
hasExternalId: hasExternalId ?? this.hasExternalId,
|
2022-10-02 19:37:11 +00:00
|
|
|
externalId: externalId ?? this.externalId,
|
2022-08-26 08:11:35 +00:00
|
|
|
isFiat: isFiat ?? this.isFiat,
|
|
|
|
featured: featured ?? this.featured,
|
|
|
|
isStable: isStable ?? this.isStable,
|
|
|
|
supportsFixedRate: supportsFixedRate ?? this.supportsFixedRate,
|
|
|
|
isAvailable: isAvailable ?? this.isAvailable,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "Currency: ${toJson()}";
|
|
|
|
}
|
|
|
|
}
|