Skip to content

Commit

Permalink
Rename products
Browse files Browse the repository at this point in the history
- .full -> .iOS_macOS
- .fullTV -> .allFeatures
  • Loading branch information
keeshux committed Dec 18, 2024
1 parent f102a08 commit aee5b98
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions Library/Sources/CommonIAP/Domain/AppProduct+Features.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions Library/Sources/UILibrary/Views/Paywall/PaywallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions Library/Tests/CommonLibraryTests/Business/IAPManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 []
}
Expand All @@ -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 []
}
Expand All @@ -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()
Expand All @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -271,7 +271,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.dns]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -280,7 +280,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -289,7 +289,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -303,7 +303,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -312,7 +312,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.appleTV, .providers]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -321,7 +321,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.dns]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -330,7 +330,7 @@ extension IAPManagerTests {
XCTAssertEqual(sut.suggestedProducts(for: [.appleTV]), [
.Full.Recurring.yearly,
.Full.Recurring.monthly,
.Full.OneTime.fullTV
.Full.OneTime.allFeatures
])
}

Expand All @@ -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
])
Expand All @@ -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
])
}

Expand All @@ -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]))
}
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aee5b98

Please sign in to comment.