NamiPaywallEvent.fromMap constructor

NamiPaywallEvent.fromMap(
  1. Map map
)

Implementation

factory NamiPaywallEvent.fromMap(Map<dynamic, dynamic> map) {
  List<dynamic> dynamicPurchases = map['purchases'];
  List<NamiPurchase> namiPurchases = List.empty(growable: true);
  dynamicPurchases.forEach((element) {
    namiPurchases.add(NamiPurchase.fromMap(element));
  });

  List<NamiSKU> namiSkus = List.empty(growable: true);
  if (map['skus'] != null) {
    List<dynamic> dynamicSkus = map['skus'];
    dynamicSkus.forEach((element) {
      namiSkus.add(NamiSKU.fromMap(element));
    });
  }

  return NamiPaywallEvent(
      (map['action'] as String)._toNamiPaywallAction(),
      map['campaignId'],
      map['campaignName'],
      (map['campaignType'] as String?).toNamiCampaignRuleType(),
      map['campaignUrl'],
      map['campaignLabel'],
      map['paywallId'],
      map['paywallName'],
      map['componentChange'] != null
          ? NamiPaywallEventComponentChange.fromMap(map['componentChange'])
          : null,
      map['segmentId'],
      map['externalSegmentId'],
      map['deepLinkUrl'],
      map['sku'] != null ? NamiSKU.fromMap(map['sku']) : null,
      map['purchaseError'],
      namiPurchases,
      namiSkus,
      map['videoMetadata'] != null
          ? NamiPaywallEventVideoMetadata.fromMap(map['videoMetadata'])
          : null,
      map['timeSpentOnPaywall']);
}