WebPurchaseRedemptionResult.fromJson constructor
WebPurchaseRedemptionResult.fromJson(
- Map<String, dynamic> json
)
Implementation
factory WebPurchaseRedemptionResult.fromJson(Map<String, dynamic> json) {
final resultType = json['result'] as String;
switch (resultType) {
case 'SUCCESS':
return WebPurchaseRedemptionSuccess(
customerInfo: CustomerInfo.fromJson(
Map<String, dynamic>.from(json['customerInfo']),
),
);
case 'ERROR':
return WebPurchaseRedemptionError(
error: PurchasesError.fromJson(
Map<String, dynamic>.from(json['error']),
),
);
case 'PURCHASE_BELONGS_TO_OTHER_USER':
return const WebPurchaseRedemptionPurchaseBelongsToOtherUser();
case 'INVALID_TOKEN':
return const WebPurchaseRedemptionInvalidToken();
case 'EXPIRED':
return WebPurchaseRedemptionExpired(
obfuscatedEmail: json['obfuscatedEmail'] as String,
);
default:
throw ArgumentError.value(resultType, 'result', 'Invalid value');
}
}