Skip to content

Refactor: simplified PurchasesOrchestrator.syncPurchases#2731

Merged
NachoSoto merged 2 commits into
mainfrom
purchases-orchestrator-magic-sring
Jun 29, 2023
Merged

Refactor: simplified PurchasesOrchestrator.syncPurchases#2731
NachoSoto merged 2 commits into
mainfrom
purchases-orchestrator-magic-sring

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

I found this while looking into SDK-3097.

I found this while looking into SDK-3097.
@NachoSoto NachoSoto requested a review from a team June 28, 2023 17:31
@codecov

codecov Bot commented Jun 28, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2731 (376d3b7) into main (1cbc974) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2731   +/-   ##
=======================================
  Coverage   86.48%   86.48%           
=======================================
  Files         212      212           
  Lines       15048    15045    -3     
=======================================
- Hits        13014    13012    -2     
+ Misses       2034     2033    -1     
Impacted Files Coverage Δ
...s/Purchasing/Purchases/PurchasesOrchestrator.swift 86.24% <100.00%> (-0.05%) ⬇️

... and 1 file with indirect coverage changes

@NachoSoto NachoSoto changed the title Refactor: replaced magic string in PurchasesOrchestrator Refactor: simplified PurchasesOrchestrator.syncPurchases Jun 28, 2023
Comment on lines +1001 to +1004
if !hasTransactions, let customerInfo = cachedCustomerInfo, customerInfo.originalPurchaseDate != nil {
if let completion = completion {
self.operationDispatcher.dispatchOnMainThread {
completion(
Result(cachedCustomerInfo,
ErrorUtils.customerInfoError(withMessage: "No cached customer info"))
)
completion(.success(customerInfo))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aboedo this new implementation is 100% equivalent. You can see that it wasn't even possible to send an error in this particular case.

@NachoSoto NachoSoto requested review from a team and aboedo and removed request for a team June 28, 2023 19:05
@NachoSoto NachoSoto merged commit 68892f3 into main Jun 29, 2023
@NachoSoto NachoSoto deleted the purchases-orchestrator-magic-sring branch June 29, 2023 13:56
NachoSoto added a commit that referenced this pull request Jun 30, 2023
**This is an automatic release.**

### New Features
* New `TestStoreProduct` for creating mock `StoreProduct`s and
`Offering`s (#2711) via NachoSoto (@NachoSoto)

✨ With this new API you can now create fake products for unit tests and
SwiftUI previews! 🎉
#### Example:
```swift
let product = TestStoreProduct(
    localizedTitle: "PRO monthly",
    price: 3.99,
    localizedPriceString: "$3.99",
    productIdentifier: "com.revenuecat.product",
    productType: .autoRenewableSubscription,
    localizedDescription: "Description",
    subscriptionGroupIdentifier: "group",
    subscriptionPeriod: .init(value: 1, unit: .month)
)
let offering = Offering(
    identifier: "offering",
    serverDescription: "Main offering",
    metadata: [:],
    availablePackages: [
        .init(
            identifier: "monthly",
            packageType: .monthly,
            storeProduct: product.toStoreProduct(),
            offeringIdentifier: offering
        )
    ]
)
```

### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `13773d2` to `b2108fb`
(#2706) via dependabot[bot] (@dependabot[bot])
### Other Changes
* `VerificationResult: CustomDebugStringConvertible` (#2739) via
NachoSoto (@NachoSoto)
* Refactor: simplified `PurchasesOrchestrator.syncPurchases` (#2731) via
NachoSoto (@NachoSoto)
* `Trusted Entitlements`: add integration tests to verify `CustomerInfo`
cache invalidation (#2730) via NachoSoto (@NachoSoto)
* `SystemInfo.identifierForVendor`: add tests (#2732) via NachoSoto
(@NachoSoto)
* `Tests`: disabled `iOS 11.x` tests to fix `Xcode 15` tests (#2720) via
NachoSoto (@NachoSoto)
* `DebugViewSwiftUITests`: create separate snapshots for each OS version
(#2721) via NachoSoto (@NachoSoto)
* `Integration Tests`: fix clearing `UserDefaults` before each test
(#2719) via NachoSoto (@NachoSoto)
* Remove unused `Signing.loadPublicKey(with:)` (#2714) via NachoSoto
(@NachoSoto)
* Add `UInt32(littleEndian32Bits:)` and `UInt32.littleEndianData`
(#2713) via NachoSoto (@NachoSoto)
* `TimingUtil`: added synchronous API (#2716) via NachoSoto (@NachoSoto)
* `XCFramework`: sign archive for `Xcode 15` (#2709) via NachoSoto
(@NachoSoto)
* `CI`: removed `carthage_archive` from `release` lane (#2710) via
NachoSoto (@NachoSoto)
* `PriceFormatterProvider.priceFormatterForSK2`: enable on all versions
(#2712) via NachoSoto (@NachoSoto)
* `xrOS`: add support for `debugRevenueCatOverlay` (#2702) via NachoSoto
(@NachoSoto)
* Refactor method to get product ID including plan ID in android
purchases (#2708) via Toni Rico (@tonidero)
* `Purchases.restoreLogHandler` (#2699) via NachoSoto (@NachoSoto)
* Remove alpha from purchase tester icon to upload to testflight (#2705)
via Toni Rico (@tonidero)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants