PurchaserInfo.fromJson constructor

PurchaserInfo.fromJson(
  1. Map value
)

Implementation

factory PurchaserInfo.fromJson(Map<dynamic, dynamic> value) {
  Map<dynamic, dynamic> map = value;
  value['entitlements'] = {
    'all': value['entitlements'],
    'active': {
      for (final item
          in Map.from(value['entitlements']).entries.where((item) {
        return DateTime.parse(value['expires_date']).isAfter(DateTime.now());
      }))
        item.key: item.value
    }
  };
  value['allExpirationDates'] = {};
  value['allPurchasedProductIdentifiers'] = [];
  value['allPurchaseDates'] = {};
  value['activeSubscriptions'] = value['subscriptions'].values.toList();
  value['nonSubscriptionTransactions'] =
      value['non_subscriptions'].values.toList();
  return PurchaserInfo._(map);
}