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 WebPurchaseRedemptionResult.success(
customerInfo: CustomerInfo.fromJson(Map<String, dynamic>.from(json['customerInfo'] as Map)),
);
case 'ERROR':
return WebPurchaseRedemptionResult.error(
error: PurchasesError.fromJson(Map<String, dynamic>.from(json['error'] as Map)),
);
case 'PURCHASE_BELONGS_TO_OTHER_USER':
return const WebPurchaseRedemptionResult.purchaseBelongsToOtherUser();
case 'INVALID_TOKEN':
return const WebPurchaseRedemptionResult.invalidToken();
case 'EXPIRED':
return WebPurchaseRedemptionResult.expired(
obfuscatedEmail: json['obfuscatedEmail'] as String,
);
default:
throw ArgumentError.value(resultType, 'result', 'Invalid value');
}
}