2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-10-03 16:30:50 +00:00
|
|
|
import 'package:decimal/decimal.dart';
|
|
|
|
import 'package:stackwallet/utilities/logger.dart';
|
|
|
|
|
|
|
|
class Estimate {
|
|
|
|
final Decimal estimatedAmount;
|
|
|
|
final bool fixedRate;
|
|
|
|
final bool reversed;
|
|
|
|
final String? warningMessage;
|
|
|
|
final String? rateId;
|
2023-05-01 22:26:12 +00:00
|
|
|
final String exchangeProvider;
|
|
|
|
final String? kycRating;
|
2022-10-03 16:30:50 +00:00
|
|
|
|
|
|
|
Estimate({
|
|
|
|
required this.estimatedAmount,
|
|
|
|
required this.fixedRate,
|
|
|
|
required this.reversed,
|
|
|
|
this.warningMessage,
|
|
|
|
this.rateId,
|
2023-05-01 22:26:12 +00:00
|
|
|
required this.exchangeProvider,
|
|
|
|
this.kycRating,
|
2022-10-03 16:30:50 +00:00
|
|
|
});
|
|
|
|
|
2023-05-01 22:26:12 +00:00
|
|
|
factory Estimate.fromMap(
|
|
|
|
Map<String, dynamic> map, {
|
|
|
|
required String exchangeProvider,
|
|
|
|
String? kycRating,
|
|
|
|
}) {
|
2022-10-03 16:30:50 +00:00
|
|
|
try {
|
|
|
|
return Estimate(
|
|
|
|
estimatedAmount: Decimal.parse(map["estimatedAmount"] as String),
|
|
|
|
fixedRate: map["fixedRate"] as bool,
|
|
|
|
reversed: map["reversed"] as bool,
|
|
|
|
warningMessage: map["warningMessage"] as String?,
|
|
|
|
rateId: map["rateId"] as String?,
|
2023-05-01 22:26:12 +00:00
|
|
|
exchangeProvider: exchangeProvider,
|
|
|
|
kycRating: kycRating,
|
2022-10-03 16:30:50 +00:00
|
|
|
);
|
|
|
|
} catch (e, s) {
|
|
|
|
Logging.instance.log("Estimate.fromMap(): $e\n$s", level: LogLevel.Error);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"estimatedAmount": estimatedAmount.toString(),
|
|
|
|
"fixedRate": fixedRate,
|
|
|
|
"reversed": reversed,
|
|
|
|
"warningMessage": warningMessage,
|
|
|
|
"rateId": rateId,
|
2023-04-28 20:29:10 +00:00
|
|
|
"exchangeProvider": exchangeProvider,
|
2023-05-01 22:26:12 +00:00
|
|
|
"kycRating": kycRating,
|
2022-10-03 16:30:50 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => "Estimate: ${toMap()}";
|
|
|
|
}
|