2022-07-28 17:03:16 +00:00
|
|
|
import 'package:cake_wallet/ionia/ionia_gift_card_instruction.dart';
|
2022-07-28 18:03:53 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2022-07-28 17:03:16 +00:00
|
|
|
|
|
|
|
class IoniaMerchant {
|
|
|
|
IoniaMerchant({
|
2022-10-12 17:09:57 +00:00
|
|
|
required this.id,
|
|
|
|
required this.legalName,
|
|
|
|
required this.systemName,
|
|
|
|
required this.description,
|
|
|
|
required this.website,
|
|
|
|
required this.termsAndConditions,
|
|
|
|
required this.logoUrl,
|
|
|
|
required this.cardImageUrl,
|
|
|
|
required this.cardholderAgreement,
|
|
|
|
required this.isActive,
|
|
|
|
required this.isOnline,
|
|
|
|
required this.isPhysical,
|
|
|
|
required this.isVariablePurchase,
|
|
|
|
required this.minimumCardPurchase,
|
|
|
|
required this.maximumCardPurchase,
|
|
|
|
required this.acceptsTips,
|
|
|
|
required this.createdDateFormatted,
|
|
|
|
required this.modifiedDateFormatted,
|
|
|
|
required this.usageInstructions,
|
|
|
|
required this.usageInstructionsBak,
|
|
|
|
required this.hasBarcode,
|
|
|
|
required this.instructions,
|
|
|
|
required this.savingsPercentage});
|
2022-07-28 17:03:16 +00:00
|
|
|
|
|
|
|
factory IoniaMerchant.fromJsonMap(Map<String, dynamic> element) {
|
|
|
|
return IoniaMerchant(
|
|
|
|
id: element["Id"] as int,
|
|
|
|
legalName: element["LegalName"] as String,
|
|
|
|
systemName: element["SystemName"] as String,
|
|
|
|
description: element["Description"] as String,
|
|
|
|
website: element["Website"] as String,
|
|
|
|
termsAndConditions: element["TermsAndConditions"] as String,
|
|
|
|
logoUrl: element["LogoUrl"] as String,
|
|
|
|
cardImageUrl: element["CardImageUrl"] as String,
|
|
|
|
cardholderAgreement: element["CardholderAgreement"] as String,
|
2022-10-12 17:09:57 +00:00
|
|
|
isActive: element["IsActive"] as bool?,
|
2022-07-28 17:03:16 +00:00
|
|
|
isOnline: element["IsOnline"] as bool,
|
|
|
|
isPhysical: element["IsPhysical"] as bool,
|
|
|
|
isVariablePurchase: element["IsVariablePurchase"] as bool,
|
|
|
|
minimumCardPurchase: element["MinimumCardPurchase"] as double,
|
|
|
|
maximumCardPurchase: element["MaximumCardPurchase"] as double,
|
|
|
|
acceptsTips: element["AcceptsTips"] as bool,
|
2022-10-12 17:09:57 +00:00
|
|
|
createdDateFormatted: element["CreatedDate"] as String?,
|
|
|
|
modifiedDateFormatted: element["ModifiedDate"] as String?,
|
|
|
|
usageInstructions: element["UsageInstructions"] as String?,
|
|
|
|
usageInstructionsBak: element["UsageInstructionsBak"] as String?,
|
2022-07-28 17:03:16 +00:00
|
|
|
hasBarcode: element["HasBarcode"] as bool,
|
|
|
|
instructions: IoniaGiftCardInstruction.parseListOfInstructions(element['PaymentInstructions'] as String),
|
|
|
|
savingsPercentage: element["SavingsPercentage"] as double);
|
|
|
|
}
|
|
|
|
|
|
|
|
final int id;
|
|
|
|
final String legalName;
|
|
|
|
final String systemName;
|
|
|
|
final String description;
|
|
|
|
final String website;
|
|
|
|
final String termsAndConditions;
|
|
|
|
final String logoUrl;
|
|
|
|
final String cardImageUrl;
|
|
|
|
final String cardholderAgreement;
|
2022-10-12 17:09:57 +00:00
|
|
|
final bool? isActive;
|
2022-07-28 17:03:16 +00:00
|
|
|
final bool isOnline;
|
2022-10-12 17:09:57 +00:00
|
|
|
final bool? isPhysical;
|
2022-07-28 17:03:16 +00:00
|
|
|
final bool isVariablePurchase;
|
|
|
|
final double minimumCardPurchase;
|
|
|
|
final double maximumCardPurchase;
|
|
|
|
final bool acceptsTips;
|
2022-10-12 17:09:57 +00:00
|
|
|
final String? createdDateFormatted;
|
|
|
|
final String? modifiedDateFormatted;
|
|
|
|
final String? usageInstructions;
|
|
|
|
final String? usageInstructionsBak;
|
2022-07-28 17:03:16 +00:00
|
|
|
final bool hasBarcode;
|
|
|
|
final List<IoniaGiftCardInstruction> instructions;
|
|
|
|
final double savingsPercentage;
|
|
|
|
|
|
|
|
double get discount => savingsPercentage;
|
2022-07-28 18:03:53 +00:00
|
|
|
|
|
|
|
String get avaibilityStatus {
|
|
|
|
var status = '';
|
|
|
|
|
|
|
|
if (isOnline) {
|
|
|
|
status += S.current.online;
|
|
|
|
}
|
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
if (isPhysical ?? false) {
|
2022-07-28 18:03:53 +00:00
|
|
|
if (status.isNotEmpty) {
|
|
|
|
status = '$status & ';
|
|
|
|
}
|
|
|
|
|
|
|
|
status = '${status}${S.current.in_store}';
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
2022-07-28 17:03:16 +00:00
|
|
|
|
|
|
|
}
|