NamiEntitlement.fromMap constructor

NamiEntitlement.fromMap(
  1. Map map
)

Implementation

factory NamiEntitlement.fromMap(Map<dynamic, dynamic> map) {
  List<dynamic> dynamicRelatedSkus = map['relatedSKUs'];
  List<NamiSKU> relatedSkus = List.empty(growable: true);
  dynamicRelatedSkus.forEach((element) {
    NamiSKU namiSKU = NamiSKU.fromMap(element);
    relatedSkus.add(namiSKU);
  });
  List<dynamic> dynamicPurchasedSkus = map['purchasedSKUs'];
  List<NamiSKU> purchasedSkus = List.empty(growable: true);
  dynamicPurchasedSkus.forEach((element) {
    NamiSKU namiSKU = NamiSKU.fromMap(element);
    purchasedSkus.add(namiSKU);
  });
  List<dynamic> dynamicActivePurchases = map['activePurchases'];
  List<NamiPurchase> activePurchases = List.empty(growable: true);
  dynamicActivePurchases.forEach((element) {
    NamiPurchase namiPurchase = NamiPurchase.fromMap(element);
    activePurchases.add(namiPurchase);
  });
  return NamiEntitlement(map['name'], map['description'], map['referenceId'],
      relatedSkus, purchasedSkus, activePurchases);
}