fromJson static method

DVPurchaseResult fromJson(
  1. Map<String, Object?> json
)

Implementation

static DVPurchaseResult fromJson(Map<String, Object?> json) {
  Set<String> ids(Object? value) =>
      <String>{if (value is List) for (final Object? id in value) '$id'};
  return DVPurchaseResult(
    handled: json['handled'] == true,
    replayed: json['replayed'] == true,
    stale: json['stale'] == true,
    undeclared: json['undeclared'] == true,
    unattributed: json['unattributed'] == true,
    refused: json['refused'] == true,
    ignored: json['ignored'] == true,
    reason: json['reason'] as String?,
    code: json['code'] as String?,
    granted: <Entitlement>{
      for (final String id in ids(json['granted'])) Entitlement(id)
    },
    revoked: <Entitlement>{
      for (final String id in ids(json['revoked'])) Entitlement(id)
    },
    consumed: ids(json['consumed']),
    refunded: ids(json['refunded']),
  );
}