mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
* Add validation logic for Test Store API keys under the TEST_STORE compiler flag * add unit test for test store api key validation * Move API key validation to `configure` and store validation result in `SystemInfo` * start new flow for purchase of `TestStoreProduct`s * WIP: implement alert for purchase of a Test Store product * Add file to Xcode workspace * WIP: implement fake purchase alert in all platforms and OSs * Enforce only one test purchases at once. Use constants for test purchase alert strings * Place new test store purchase APIs under the TEST_STORE compiler flag * fix lint * fix unit tests after change of internal APIs * PR comments * temporarily return hardcoded `CustomerInfo` on confirmed test purchase * tests: adapt unit tests to new `TestStorePurchaseHandler` dependency of `PurchasesOrchestrator` * fix lint * Fix backend integration tests compilation * Remove deprecation warning * remove unnecessary OSs checks Since the minimum supported versions of the SDK are iOS 13 and tvOS 13 * add `GetWebProductsOperation` * avoid duplicating decoding objects from WebOfferingProductsResponse and WebProductsResponse * add missing tests snapshots * Add `WebProductsResponse.ProductType` enum * Fix tests * add web products decoding tests * Rename WebProducts to WebBillingProducts * (more) rename WebProducts to WebBillingProducts * (even more) rename WebProducts to WebBillingProducts * Move `getWebBillingProducts` outside of `OfferingsAPI` into a new `WebBillingAPI` object * improve test * remove unnecessary `sorted()` of `Set` * fix lint * fix tests Since the GetWebBilling request path contains an unordered set of productIds, which the tests do not support, we're only doing snapshot tests with 1 product ID * fix more tests
54 lines
1.9 KiB
Swift
54 lines
1.9 KiB
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
|
|
//
|
|
// WebBillingAPI.swift
|
|
//
|
|
// Created by Antonio Pallares on 7/29/25.
|
|
|
|
import Foundation
|
|
|
|
class WebBillingAPI {
|
|
|
|
typealias WebBillingProductsResponseHandler = Backend.ResponseHandler<WebBillingProductsResponse>
|
|
|
|
private let webBillingProductsCallbackCache: CallbackCache<WebBillingProductsCallback>
|
|
private let backendConfig: BackendConfiguration
|
|
|
|
init(backendConfig: BackendConfiguration) {
|
|
self.backendConfig = backendConfig
|
|
self.webBillingProductsCallbackCache = .init()
|
|
}
|
|
|
|
func getWebBillingProducts(
|
|
appUserID: String, productIds: Set<String>, completion: @escaping WebBillingProductsResponseHandler
|
|
) {
|
|
let config = NetworkOperation.UserSpecificConfiguration(httpClient: self.backendConfig.httpClient,
|
|
appUserID: appUserID)
|
|
let factory = GetWebBillingProductsOperation.createFactory(
|
|
configuration: config,
|
|
webBillingProductsCallbackCache: self.webBillingProductsCallbackCache,
|
|
productIds: productIds
|
|
)
|
|
|
|
let webProductsCallback = WebBillingProductsCallback(cacheKey: factory.cacheKey, completion: completion)
|
|
let cacheStatus = self.webBillingProductsCallbackCache.add(webProductsCallback)
|
|
|
|
self.backendConfig.addCacheableOperation(
|
|
with: factory,
|
|
delay: .none,
|
|
cacheStatus: cacheStatus
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
// @unchecked because:
|
|
// - Class is not `final` (it's mocked). This implicitly makes subclasses `Sendable` even if they're not thread-safe.
|
|
extension WebBillingAPI: @unchecked Sendable {}
|