From aee5b98298a09a1ba8cdbfa05a8efbc8a4a50d37 Mon Sep 17 00:00:00 2001 From: Davide Date: Wed, 18 Dec 2024 09:49:43 +0100 Subject: [PATCH] Rename products - .full -> .iOS_macOS - .fullTV -> .allFeatures --- .../Domain/AppProduct+Features.swift | 12 ++--- .../IAP/AppFeatureProviding+Products.swift | 4 +- .../IAP/IAPManager+Suggestions.swift | 6 +-- .../UILibrary/Views/Paywall/PaywallView.swift | 4 +- .../Business/IAPManagerTests.swift | 48 +++++++++---------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Library/Sources/CommonIAP/Domain/AppProduct+Features.swift b/Library/Sources/CommonIAP/Domain/AppProduct+Features.swift index d8284fa88..19a4b7b4e 100644 --- a/Library/Sources/CommonIAP/Domain/AppProduct+Features.swift +++ b/Library/Sources/CommonIAP/Domain/AppProduct+Features.swift @@ -37,11 +37,11 @@ extension AppProduct { public enum Full { static let all: [AppProduct] = [ - .Full.OneTime.fullTV, + .Full.OneTime.allFeatures, .Full.Recurring.monthly, .Full.Recurring.yearly, // - .Full.OneTime.full, + .Full.OneTime.iOS_macOS, .Full.OneTime.iOS, .Full.OneTime.macOS ] @@ -68,7 +68,7 @@ extension AppProduct.Full { public enum OneTime { // iOS/macOS + tvOS - public static let fullTV = AppProduct(featureId: "full.lifetime") + public static let allFeatures = AppProduct(featureId: "full.lifetime") } public enum Recurring { @@ -83,8 +83,8 @@ extension AppProduct { switch self { case .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV, - .Full.OneTime.full: + .Full.OneTime.allFeatures, + .Full.OneTime.iOS_macOS: return true default: return false @@ -114,7 +114,7 @@ extension AppProduct.Features { extension AppProduct.Full.OneTime { @available(*, deprecated) - public static let full = AppProduct(featureId: "full_multi_version") + public static let iOS_macOS = AppProduct(featureId: "full_multi_version") @available(*, deprecated) public static let iOS = AppProduct(featureId: "full_version") diff --git a/Library/Sources/CommonLibrary/IAP/AppFeatureProviding+Products.swift b/Library/Sources/CommonLibrary/IAP/AppFeatureProviding+Products.swift index a943b0746..08193e669 100644 --- a/Library/Sources/CommonLibrary/IAP/AppFeatureProviding+Products.swift +++ b/Library/Sources/CommonLibrary/IAP/AppFeatureProviding+Products.swift @@ -31,10 +31,10 @@ extension AppProduct: AppFeatureProviding { // MARK: Current - case .Full.OneTime.full: + case .Full.OneTime.iOS_macOS: return AppFeature.fullFeatures - case .Full.OneTime.fullTV, .Full.Recurring.monthly, .Full.Recurring.yearly: + case .Full.OneTime.allFeatures, .Full.Recurring.monthly, .Full.Recurring.yearly: return AppFeature.fullTVFeatures case .Features.appleTV: diff --git a/Library/Sources/CommonLibrary/IAP/IAPManager+Suggestions.swift b/Library/Sources/CommonLibrary/IAP/IAPManager+Suggestions.swift index d46781761..c4b8c3c5c 100644 --- a/Library/Sources/CommonLibrary/IAP/IAPManager+Suggestions.swift +++ b/Library/Sources/CommonLibrary/IAP/IAPManager+Suggestions.swift @@ -52,13 +52,13 @@ extension IAPManager { } } else { // !isFullVersionPurchaser if eligibleFeatures.contains(.appleTV) { - products.insert(.Full.OneTime.full) + products.insert(.Full.OneTime.iOS_macOS) } else { - products.insert(.Full.OneTime.fullTV) + products.insert(.Full.OneTime.allFeatures) } } - if withRecurring && products.contains(.Full.OneTime.fullTV) { + if withRecurring && products.contains(.Full.OneTime.allFeatures) { products.insert(.Full.Recurring.monthly) products.insert(.Full.Recurring.yearly) } diff --git a/Library/Sources/UILibrary/Views/Paywall/PaywallView.swift b/Library/Sources/UILibrary/Views/Paywall/PaywallView.swift index 8b91c61b5..1177cf720 100644 --- a/Library/Sources/UILibrary/Views/Paywall/PaywallView.swift +++ b/Library/Sources/UILibrary/Views/Paywall/PaywallView.swift @@ -285,9 +285,9 @@ private extension AppProduct { return .min case .Full.Recurring.monthly: return 1 - case .Full.OneTime.fullTV: + case .Full.OneTime.allFeatures: return 2 - case .Full.OneTime.full: + case .Full.OneTime.iOS_macOS: return 3 default: return .max diff --git a/Library/Tests/CommonLibraryTests/Business/IAPManagerTests.swift b/Library/Tests/CommonLibraryTests/Business/IAPManagerTests.swift index 6b53e9321..3c9bfbc3c 100644 --- a/Library/Tests/CommonLibraryTests/Business/IAPManagerTests.swift +++ b/Library/Tests/CommonLibraryTests/Business/IAPManagerTests.swift @@ -49,7 +49,7 @@ extension IAPManagerTests { let sut = IAPManager(receiptReader: reader) let appProducts: [AppProduct] = [ - .Full.OneTime.full, + .Full.OneTime.iOS_macOS, .Donations.huge ] let inAppProducts = try await sut.purchasableProducts(for: appProducts) @@ -88,7 +88,7 @@ extension IAPManagerTests { await reader.setReceipt(withBuild: olderBuildNumber, identifiers: []) let sut = IAPManager(receiptReader: reader) { build in if build <= self.defaultBuildNumber { - return [.Full.OneTime.full] + return [.Full.OneTime.iOS_macOS] } return [] } @@ -101,7 +101,7 @@ extension IAPManagerTests { await reader.setReceipt(withBuild: newerBuildNumber, products: []) let sut = IAPManager(receiptReader: reader) { build in if build <= self.defaultBuildNumber { - return [.Full.OneTime.full] + return [.Full.OneTime.iOS_macOS] } return [] } @@ -119,7 +119,7 @@ extension IAPManagerTests { XCTAssertFalse(sut.isEligible(for: AppFeature.fullFeatures)) - await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.OneTime.full]) + await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.OneTime.iOS_macOS]) XCTAssertFalse(sut.isEligible(for: AppFeature.fullFeatures)) await sut.reloadReceipt() @@ -146,8 +146,8 @@ extension IAPManagerTests { let reader = FakeAppReceiptReader() await reader.setReceipt( withBuild: defaultBuildNumber, - products: [.Full.OneTime.full], - cancelledProducts: [.Full.OneTime.full] + products: [.Full.OneTime.iOS_macOS], + cancelledProducts: [.Full.OneTime.iOS_macOS] ) let sut = IAPManager(receiptReader: reader) @@ -177,7 +177,7 @@ extension IAPManagerTests { func test_givenFullV2Version_thenIsEligibleForAnyFeatureExceptExcluded() async { let reader = FakeAppReceiptReader() - await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.OneTime.full]) + await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.OneTime.iOS_macOS]) let sut = IAPManager(receiptReader: reader) await sut.reloadReceipt() @@ -271,7 +271,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.dns]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -280,7 +280,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -289,7 +289,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -303,7 +303,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -312,7 +312,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -321,7 +321,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.dns]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -330,7 +330,7 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } @@ -339,24 +339,24 @@ extension IAPManagerTests { XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [ .Full.Recurring.yearly, .Full.Recurring.monthly, - .Full.OneTime.fullTV + .Full.OneTime.allFeatures ]) } func test_givenFull_whenRequireFeature_thenSuggestsNothing() async { - let sut = await IAPManager(products: [.Full.OneTime.full]) + let sut = await IAPManager(products: [.Full.OneTime.iOS_macOS]) XCTAssertNil(sut.suggestedProducts(for: [.dns])) } func test_givenFull_whenRequireAppleTV_thenSuggestsAppleTV() async { - let sut = await IAPManager(products: [.Full.OneTime.full]) + let sut = await IAPManager(products: [.Full.OneTime.iOS_macOS]) XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [ .Features.appleTV ]) } func test_givenFull_whenRequireFeatureAndAppleTV_thenSuggestsAppleTV() async { - let sut = await IAPManager(products: [.Full.OneTime.full]) + let sut = await IAPManager(products: [.Full.OneTime.iOS_macOS]) XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [ .Features.appleTV ]) @@ -365,7 +365,7 @@ extension IAPManagerTests { func test_givenAppleTV_whenRequireFeature_thenSuggestsFull() async { let sut = await IAPManager(products: [.Features.appleTV]) XCTAssertEqual(sut.suggestedProducts(for: [.dns]), [ - .Full.OneTime.full + .Full.OneTime.iOS_macOS ]) } @@ -377,22 +377,22 @@ extension IAPManagerTests { func test_givenAppleTV_whenRequireFeatureAndAppleTV_thenSuggestsFull() async { let sut = await IAPManager(products: [.Features.appleTV]) XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [ - .Full.OneTime.full + .Full.OneTime.iOS_macOS ]) } func test_givenFullTV_whenRequireFeature_thenSuggestsNothing() async { - let sut = await IAPManager(products: [.Full.OneTime.fullTV]) + let sut = await IAPManager(products: [.Full.OneTime.allFeatures]) XCTAssertNil(sut.suggestedProducts(for: [.dns])) } func test_givenFullTV_whenRequireAppleTV_thenSuggestsNothing() async { - let sut = await IAPManager(products: [.Full.OneTime.fullTV]) + let sut = await IAPManager(products: [.Full.OneTime.allFeatures]) XCTAssertNil(sut.suggestedProducts(for: [.appleTV])) } func test_givenFullTV_whenRequireFeatureAndAppleTV_thenSuggestsNothing() async { - let sut = await IAPManager(products: [.Full.OneTime.fullTV]) + let sut = await IAPManager(products: [.Full.OneTime.allFeatures]) XCTAssertNil(sut.suggestedProducts(for: [.appleTV, .providers])) } } @@ -539,7 +539,7 @@ extension IAPManagerTests { extension IAPManagerTests { func test_givenManager_whenObserveObjects_thenReloadsReceipt() async { let reader = FakeAppReceiptReader() - await reader.setReceipt(withBuild: .max, products: [.Full.OneTime.full]) + await reader.setReceipt(withBuild: .max, products: [.Full.OneTime.iOS_macOS]) let sut = IAPManager(receiptReader: reader) XCTAssertEqual(sut.userLevel, .undefined)