104 lines
3.4 KiB
Dart
104 lines
3.4 KiB
Dart
class ShareCardConfig {
|
|
const ShareCardConfig({
|
|
required this.enabled,
|
|
required this.allowMainWallet,
|
|
required this.allowBonusWallet,
|
|
required this.allowTestWallet,
|
|
required this.allowWon,
|
|
required this.allowLost,
|
|
required this.allowRefunded,
|
|
});
|
|
|
|
final bool enabled;
|
|
final bool allowMainWallet;
|
|
final bool allowBonusWallet;
|
|
final bool allowTestWallet;
|
|
final bool allowWon;
|
|
final bool allowLost;
|
|
final bool allowRefunded;
|
|
|
|
factory ShareCardConfig.fromJson(Map<String, dynamic> json) {
|
|
return ShareCardConfig(
|
|
enabled: json['enabled'] == true,
|
|
allowMainWallet: json['allowMainWallet'] != false,
|
|
allowBonusWallet: json['allowBonusWallet'] != false,
|
|
allowTestWallet: json['allowTestWallet'] == true,
|
|
allowWon: json['allowWon'] != false,
|
|
allowLost: json['allowLost'] != false,
|
|
allowRefunded: json['allowRefunded'] != false,
|
|
);
|
|
}
|
|
|
|
bool isEligible({
|
|
required String? status,
|
|
required String? stakeAccountKind,
|
|
bool requireStatus = true,
|
|
}) {
|
|
if (!enabled) return false;
|
|
final kind = stakeAccountKind ?? 'main';
|
|
if (kind == 'main' && !allowMainWallet) return false;
|
|
if (kind == 'bonus' && !allowBonusWallet) return false;
|
|
if (kind == 'test' && !allowTestWallet) return false;
|
|
if (status == null || status.isEmpty) return !requireStatus;
|
|
if (status != 'won' && status != 'lost' && status != 'refunded') return false;
|
|
if (status == 'won' && !allowWon) return false;
|
|
if (status == 'lost' && !allowLost) return false;
|
|
if (status == 'refunded' && !allowRefunded) return false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class ShareCardPayload {
|
|
const ShareCardPayload({
|
|
required this.betId,
|
|
required this.gameName,
|
|
required this.direction,
|
|
required this.status,
|
|
required this.resultSignedDisplay,
|
|
required this.stakeDisplay,
|
|
required this.intervalMinutes,
|
|
required this.settledAt,
|
|
required this.verifyUrl,
|
|
required this.predictionMode,
|
|
required this.isAuto,
|
|
this.sequence = const [],
|
|
});
|
|
|
|
final String betId;
|
|
final String gameName;
|
|
final String direction;
|
|
final String status;
|
|
final String resultSignedDisplay;
|
|
final num stakeDisplay;
|
|
final int intervalMinutes;
|
|
final String settledAt;
|
|
final String verifyUrl;
|
|
final String predictionMode;
|
|
final bool isAuto;
|
|
final List<String> sequence;
|
|
|
|
factory ShareCardPayload.fromJson(Map<String, dynamic> json) {
|
|
final seq = json['sequence'];
|
|
return ShareCardPayload(
|
|
betId: (json['betId'] ?? '').toString(),
|
|
gameName: (json['gameName'] ?? 'Candle Predict').toString(),
|
|
direction: (json['direction'] ?? 'long').toString(),
|
|
status: (json['status'] ?? '').toString(),
|
|
resultSignedDisplay: (json['resultSignedDisplay'] ?? '0').toString(),
|
|
stakeDisplay: json['stakeDisplay'] is num
|
|
? json['stakeDisplay'] as num
|
|
: num.tryParse('${json['stakeDisplay']}') ?? 0,
|
|
intervalMinutes: json['intervalMinutes'] is int
|
|
? json['intervalMinutes'] as int
|
|
: int.tryParse('${json['intervalMinutes']}') ?? 1,
|
|
settledAt: (json['settledAt'] ?? '').toString(),
|
|
verifyUrl: (json['verifyUrl'] ?? '').toString(),
|
|
predictionMode: (json['predictionMode'] ?? 'single').toString(),
|
|
isAuto: json['isAuto'] == true,
|
|
sequence: seq is List
|
|
? seq.map((e) => e.toString()).toList()
|
|
: const <String>[],
|
|
);
|
|
}
|
|
}
|