2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/enumerable_item.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
class TradeState extends EnumerableItem<String> with Serializable<String> {
|
2023-10-25 20:58:25 +00:00
|
|
|
const TradeState({required String raw, required String title}) : super(raw: raw, title: title);
|
2020-01-08 12:26:34 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) => other is TradeState && other.raw == raw;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
static const pending = TradeState(raw: 'pending', title: 'Pending');
|
|
|
|
static const confirming = TradeState(raw: 'confirming', title: 'Confirming');
|
|
|
|
static const trading = TradeState(raw: 'trading', title: 'Trading');
|
|
|
|
static const traded = TradeState(raw: 'traded', title: 'Traded');
|
|
|
|
static const complete = TradeState(raw: 'complete', title: 'Complete');
|
2023-10-25 20:58:25 +00:00
|
|
|
static const toBeCreated = TradeState(raw: 'TO_BE_CREATED', title: 'To be created');
|
2020-01-04 19:31:52 +00:00
|
|
|
static const unpaid = TradeState(raw: 'UNPAID', title: 'Unpaid');
|
|
|
|
static const underpaid = TradeState(raw: 'UNDERPAID', title: 'Underpaid');
|
2023-10-25 20:58:25 +00:00
|
|
|
static const paidUnconfirmed = TradeState(raw: 'PAID_UNCONFIRMED', title: 'Paid unconfirmed');
|
2020-01-04 19:31:52 +00:00
|
|
|
static const paid = TradeState(raw: 'PAID', title: 'Paid');
|
|
|
|
static const btcSent = TradeState(raw: 'BTC_SENT', title: 'Btc sent');
|
|
|
|
static const timeout = TradeState(raw: 'TIMED_OUT', title: 'Timeout');
|
|
|
|
static const notFound = TradeState(raw: 'NOT_FOUND', title: 'Not found');
|
|
|
|
static const created = TradeState(raw: 'created', title: 'Created');
|
|
|
|
static const finished = TradeState(raw: 'finished', title: 'Finished');
|
|
|
|
static const waiting = TradeState(raw: 'waiting', title: 'Waiting');
|
2020-02-07 11:07:58 +00:00
|
|
|
static const processing = TradeState(raw: 'processing', title: 'Processing');
|
2023-10-25 20:58:25 +00:00
|
|
|
static const waitingPayment = TradeState(raw: 'waitingPayment', title: 'Waiting payment');
|
2021-04-14 18:23:10 +00:00
|
|
|
static const waitingAuthorization =
|
|
|
|
TradeState(raw: 'waitingAuthorization', title: 'Waiting authorization');
|
|
|
|
static const failed = TradeState(raw: 'failed', title: 'Failed');
|
|
|
|
static const completed = TradeState(raw: 'completed', title: 'Completed');
|
2024-05-14 02:07:16 +00:00
|
|
|
static const expired = TradeState(raw: 'expired', title: 'Expired');
|
2022-04-13 13:28:21 +00:00
|
|
|
static const settling = TradeState(raw: 'settling', title: 'Settlement in progress');
|
|
|
|
static const settled = TradeState(raw: 'settled', title: 'Settlement completed');
|
2023-10-12 00:20:19 +00:00
|
|
|
static const wait = TradeState(raw: 'wait', title: 'Waiting');
|
|
|
|
static const overdue = TradeState(raw: 'overdue', title: 'Overdue');
|
|
|
|
static const refund = TradeState(raw: 'refund', title: 'Refund');
|
|
|
|
static const refunded = TradeState(raw: 'refunded', title: 'Refunded');
|
|
|
|
static const confirmation = TradeState(raw: 'confirmation', title: 'Confirmation');
|
|
|
|
static const confirmed = TradeState(raw: 'confirmed', title: 'Confirmed');
|
|
|
|
static const exchanging = TradeState(raw: 'exchanging', title: 'Exchanging');
|
|
|
|
static const sending = TradeState(raw: 'sending', title: 'Sending');
|
|
|
|
static const success = TradeState(raw: 'success', title: 'Success');
|
2024-05-14 02:07:16 +00:00
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
static TradeState deserialize({required String raw}) {
|
2024-05-14 02:07:16 +00:00
|
|
|
|
|
|
|
switch (raw) {
|
|
|
|
case '1':
|
|
|
|
return unpaid;
|
|
|
|
case '2':
|
|
|
|
return paidUnconfirmed;
|
|
|
|
case '3':
|
|
|
|
return sending;
|
|
|
|
case '4':
|
|
|
|
return confirmed;
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
return exchanging;
|
|
|
|
case '7':
|
|
|
|
return sending;
|
|
|
|
case '8':
|
|
|
|
return complete;
|
|
|
|
case '9':
|
|
|
|
return expired;
|
|
|
|
case '10':
|
|
|
|
return underpaid;
|
|
|
|
case '11':
|
|
|
|
return failed;
|
|
|
|
}
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
switch (raw) {
|
2024-03-28 12:41:11 +00:00
|
|
|
case 'NOT_FOUND':
|
|
|
|
return notFound;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'pending':
|
|
|
|
return pending;
|
|
|
|
case 'confirming':
|
|
|
|
return confirming;
|
|
|
|
case 'trading':
|
|
|
|
return trading;
|
|
|
|
case 'traded':
|
|
|
|
return traded;
|
|
|
|
case 'complete':
|
|
|
|
return complete;
|
|
|
|
case 'TO_BE_CREATED':
|
|
|
|
return toBeCreated;
|
|
|
|
case 'UNPAID':
|
|
|
|
return unpaid;
|
|
|
|
case 'UNDERPAID':
|
|
|
|
return underpaid;
|
|
|
|
case 'PAID_UNCONFIRMED':
|
|
|
|
return paidUnconfirmed;
|
|
|
|
case 'PAID':
|
|
|
|
return paid;
|
|
|
|
case 'BTC_SENT':
|
|
|
|
return btcSent;
|
|
|
|
case 'TIMED_OUT':
|
|
|
|
return timeout;
|
|
|
|
case 'created':
|
|
|
|
return created;
|
|
|
|
case 'finished':
|
|
|
|
return finished;
|
|
|
|
case 'waiting':
|
|
|
|
return waiting;
|
2020-02-07 11:07:58 +00:00
|
|
|
case 'processing':
|
|
|
|
return processing;
|
2021-04-14 18:23:10 +00:00
|
|
|
case 'waitingPayment':
|
|
|
|
return waitingPayment;
|
|
|
|
case 'waitingAuthorization':
|
|
|
|
return waitingAuthorization;
|
|
|
|
case 'failed':
|
|
|
|
return failed;
|
|
|
|
case 'completed':
|
|
|
|
return completed;
|
2023-10-12 00:20:19 +00:00
|
|
|
case 'wait':
|
|
|
|
return wait;
|
|
|
|
case 'overdue':
|
|
|
|
return overdue;
|
|
|
|
case 'refund':
|
|
|
|
return refund;
|
|
|
|
case 'refunded':
|
|
|
|
return refunded;
|
|
|
|
case 'confirmation':
|
|
|
|
return confirmation;
|
|
|
|
case 'confirmed':
|
|
|
|
return confirmed;
|
|
|
|
case 'exchanging':
|
|
|
|
return exchanging;
|
|
|
|
case 'sending':
|
|
|
|
return sending;
|
|
|
|
case 'success':
|
2024-03-28 12:41:11 +00:00
|
|
|
case 'done':
|
2023-10-12 00:20:19 +00:00
|
|
|
return success;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
2022-10-12 17:09:57 +00:00
|
|
|
throw Exception('Unexpected token: $raw in TradeState deserialize');
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => raw.hashCode ^ title.hashCode;
|
|
|
|
}
|