OfferOfferData.fromMap constructor
OfferOfferData.fromMap(
- Map<String, dynamic> map
)
Implementation
factory OfferOfferData.fromMap(Map<String, dynamic> map) {
final rawPerProduct = map['perProductPrompts'];
Map<String, OfferPerProductOffer>? perProduct;
if (rawPerProduct is Map) {
perProduct = rawPerProduct.map(
(key, value) => MapEntry(
key as String,
OfferPerProductOffer.fromMap(
Map<String, dynamic>.from(value as Map),
),
),
);
}
return OfferOfferData(
flowType: OfferFlowType.fromRawValue(map['flowType'] as String),
productId: map['productId'] as String,
eligibleProductIds: (map['eligibleProductIds'] as List?)
?.map((e) => e as String)
.toList() ??
<String>[],
savingsPercent: map['savingsPercent'] as int? ?? 0,
display: OfferDisplay.fromMap(
Map<String, dynamic>.from(map['display'] as Map),
),
freeTrialDays: map['freeTrialDays'] as int? ?? 0,
minSubscriptionDays: map['minSubscriptionDays'] as int? ?? 0,
maxSubscriptionDays: map['maxSubscriptionDays'] as int?,
rolloutPercent: map['rolloutPercent'] as int?,
upgradeType: map['upgradeType'] != null
? OfferUpgradeType.fromRawValue(map['upgradeType'] as String)
: null,
fromProductId: map['fromProductId'] as String?,
toProductId: map['toProductId'] as String?,
variantId: map['variantId'] as int?,
perProductPrompts: perProduct,
checkoutPresentation: map['checkoutPresentation'] != null
? OfferCheckoutPresentation.fromRawValue(
map['checkoutPresentation'] as String,
)
: null,
);
}