From 4b36e625bb493208c007faa1b9ea97c5f66099a7 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 29 Oct 2024 17:27:32 -0500 Subject: [PATCH] Add support for ios products on server --- subs-mock/src/util.ts | 63 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/subs-mock/src/util.ts b/subs-mock/src/util.ts index c8a18b99a6..a9bd0f568f 100644 --- a/subs-mock/src/util.ts +++ b/subs-mock/src/util.ts @@ -226,7 +226,7 @@ export function normalizeSubscriptions( interval, state, store: { - type: 'play_store', + type: platform === 'android' ? 'play_store' : 'app_store', productId: product.store_identifier, productLookupKey: getProductLookupKey(product.store_identifier), }, @@ -267,6 +267,7 @@ export function getSubscriptionState( } export function getSubscriptionPlatform(id: string): 'web' | 'android' | 'ios' { + console.log(id) switch (id) { case 'prod_R2eNjNa6mB1Jlu': case 'prod_R37Zg28EeQ9XAz': @@ -284,9 +285,17 @@ export function getSubscriptionPlatform(id: string): 'web' | 'android' | 'ios' { case 'bsky_tier_2:annual-auto': { return 'android' } - default: { + case 'bsky_tier_0_monthly': + case 'bsky_tier_0_annual': + case 'bsky_tier_1_monthly': + case 'bsky_tier_1_annual': + case 'bsky_tier_2_monthly': + case 'bsky_tier_2_annual': { return 'ios' } + default: { + throw new Error(`Unknown product ID: ${id}`) + } } } @@ -302,7 +311,7 @@ export function getProductLookupKey(id: string): string { case 'bsky_tier_2:annual-auto': return 'bsky_tier_2' default: - throw new Error(`Unknown product ID: ${id}`) + return id } } @@ -310,42 +319,30 @@ export function normalizeSubscriptionId( id: string, ): SubscriptionId | undefined { switch (id) { - case 'bsky_tier_0:monthly-auto': { + case 'bsky_tier_0_monthly': + case 'bsky_tier_0:monthly-auto': + case 'prod_R2eNjNa6mB1Jlu': return SubscriptionId.Main0MonthlyAuto - } - case 'bsky_tier_0:annual-auto': { + case 'bsky_tier_0_annual': + case 'bsky_tier_0:annual-auto': + case 'prod_R37Zg28EeQ9XAz': return SubscriptionId.Main0AnnualAuto - } - case 'bsky_tier_1:monthly-auto': { + case 'bsky_tier_1_monthly': + case 'bsky_tier_1:monthly-auto': + case 'prod_R67eiEMuIf59w7': return SubscriptionId.Main1MonthlyAuto - } - case 'bsky_tier_1:annual-auto': { + case 'bsky_tier_1_annual': + case 'bsky_tier_1:annual-auto': + case 'prod_R67fjfexQ7THQ0': return SubscriptionId.Main1AnnualAuto - } - case 'bsky_tier_2:monthly-auto': { + case 'bsky_tier_2_monthly': + case 'bsky_tier_2:monthly-auto': + case 'prod_R67ftsSVu2U1D6': return SubscriptionId.Main2MonthlyAuto - } - case 'bsky_tier_2:annual-auto': { + case 'bsky_tier_2_annual': + case 'bsky_tier_2:annual-auto': + case 'prod_R67gClEZy1cry2': return SubscriptionId.Main2AnnualAuto - } - case 'prod_R2eNjNa6mB1Jlu': { - return SubscriptionId.Main0MonthlyAuto - } - case 'prod_R37Zg28EeQ9XAz': { - return SubscriptionId.Main0AnnualAuto - } - case 'prod_R67eiEMuIf59w7': { - return SubscriptionId.Main1MonthlyAuto - } - case 'prod_R67fjfexQ7THQ0': { - return SubscriptionId.Main1AnnualAuto - } - case 'prod_R67ftsSVu2U1D6': { - return SubscriptionId.Main2MonthlyAuto - } - case 'prod_R67gClEZy1cry2': { - return SubscriptionId.Main2AnnualAuto - } default: { return undefined }