2023-01-11 23:02:57 +00:00
|
|
|
enum BuyExceptionType { generic, serializeResponseError }
|
2023-01-11 15:54:39 +00:00
|
|
|
|
2023-01-11 23:02:57 +00:00
|
|
|
class BuyException implements Exception {
|
2023-01-11 15:54:39 +00:00
|
|
|
String errorMessage;
|
2023-01-11 23:02:57 +00:00
|
|
|
BuyExceptionType type;
|
|
|
|
BuyException(this.errorMessage, this.type);
|
2023-01-11 15:54:39 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return errorMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-11 23:02:57 +00:00
|
|
|
class BuyResponse<T> {
|
2023-01-11 15:54:39 +00:00
|
|
|
late final T? value;
|
2023-01-11 23:02:57 +00:00
|
|
|
late final BuyException? exception;
|
2023-01-11 15:54:39 +00:00
|
|
|
|
2023-01-11 23:02:57 +00:00
|
|
|
BuyResponse({this.value, this.exception});
|
2023-01-11 15:54:39 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return "{error: $exception, value: $value}";
|
|
|
|
}
|
|
|
|
}
|