From 542958dcb3f7230b5035f0efa31480cc3c516476 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 4 Nov 2024 09:40:07 -0500 Subject: [PATCH] cast subscription duration as enum value --- lib/pangea/repo/subscription_repo.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/pangea/repo/subscription_repo.dart b/lib/pangea/repo/subscription_repo.dart index 4b0174cf33..d50cd1c6f5 100644 --- a/lib/pangea/repo/subscription_repo.dart +++ b/lib/pangea/repo/subscription_repo.dart @@ -49,11 +49,8 @@ class SubscriptionRepo { final RCProductsResponseModel resp = RCProductsResponseModel.fromJson(json); return resp.allProducts; - } catch (err) { - ErrorHandler.logError( - m: "Failed to fetch entitlement information for revenuecat API", - s: StackTrace.current, - ); + } catch (err, s) { + ErrorHandler.logError(e: err, s: s); return null; } } @@ -97,7 +94,9 @@ class RCProductsResponseModel { .map( (offering) => SubscriptionDetails( price: offering['price'], - duration: offering['duration'], + duration: SubscriptionDuration.values.firstWhereOrNull( + (duration) => duration.value == offering['duration'], + ), id: offering['id'], appId: offering['appId'], ),