Files
purchases-ios/Sources/Purchasing/TransactionsFactory.swift
T
NachoSoto 01c46c41bb Replaced CustomerInfo.nonSubscriptionsTransactions with a new non-StoreTransaction type (#1733)
Fixes [CF-781]

Making `CustomerInfo.nonSubscriptionTransactions` return type a `StoreTransaction` was my mistake from an earlier refactor. I saw the two types were similar, so I made them conform to the same interface.
However, they represent different concepts.

### Changes:

- Added new `NonSubscriptionTransaction` type
- Deprecated `CustomerInfo.nonSubscriptionTransactions` with a `renamed` for a new `nonSubscriptions`
- Made the old `BackendParsedTransaction` initialization depend on the new type to avoid duplicating code
- Add new test to cover the new method, and left the existing one
- Added more checks in `CustomerInfoTest` for missing properties
- Updated all APITesters

[CF-781]: https://revenuecats.atlassian.net/browse/CF-781?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-06-30 08:59:16 -07:00

32 lines
903 B
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// TransactionsFactory.swift
//
// Created by RevenueCat.
//
import Foundation
enum TransactionsFactory {
static func nonSubscriptionTransactions(
withSubscriptionsData subscriptionsData: [String: [CustomerInfoResponse.Transaction]]
) -> [NonSubscriptionTransaction] {
subscriptionsData
.flatMap { (productID, transactions) -> [NonSubscriptionTransaction] in
transactions
.lazy
.compactMap { NonSubscriptionTransaction(with: $0, productID: productID) }
}
.sorted { $0.purchaseDate < $1.purchaseDate }
}
}