mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-10 22:45:55 +05:45
Alpha of the Customer Center. In this branch, it's been disabled behind a compilation flag. --------- Co-authored-by: Will Taylor <wtaylor151@gmail.com> Co-authored-by: James Borthwick <109382862+jamesrb1@users.noreply.github.com> Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com> Co-authored-by: JayShortway <29483617+JayShortway@users.noreply.github.com> Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com> Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com> Co-authored-by: Cody Kerns <44073103+codykerns@users.noreply.github.com> Co-authored-by: Andy Boedo <andresboedo@gmail.com>
51 lines
1.8 KiB
Swift
51 lines
1.8 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
|
|
//
|
|
// CustomerCenterConfigAPI.swift
|
|
//
|
|
// Created by Cesar de la Vega on 31/5/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class CustomerCenterConfigAPI {
|
|
|
|
typealias CustomerCenterConfigResponseHandler = Backend.ResponseHandler<CustomerCenterConfigResponse>
|
|
|
|
private let customerCenterConfigResponseCallbacksCache: CallbackCache<CustomerCenterConfigCallback>
|
|
private let backendConfig: BackendConfiguration
|
|
|
|
init(backendConfig: BackendConfiguration) {
|
|
self.backendConfig = backendConfig
|
|
self.customerCenterConfigResponseCallbacksCache = .init()
|
|
}
|
|
|
|
func getCustomerCenterConfig(appUserID: String,
|
|
isAppBackgrounded: Bool,
|
|
completion: @escaping CustomerCenterConfigResponseHandler) {
|
|
let config = NetworkOperation.UserSpecificConfiguration(httpClient: self.backendConfig.httpClient,
|
|
appUserID: appUserID)
|
|
|
|
let factory = GetCustomerCenterConfigOperation.createFactory(
|
|
configuration: config,
|
|
callbackCache: self.customerCenterConfigResponseCallbacksCache
|
|
)
|
|
|
|
let callback = CustomerCenterConfigCallback(cacheKey: factory.cacheKey, completion: completion)
|
|
let cacheStatus = self.customerCenterConfigResponseCallbacksCache.add(callback)
|
|
|
|
self.backendConfig.addCacheableOperation(
|
|
with: factory,
|
|
delay: .default(forBackgroundedApp: isAppBackgrounded),
|
|
cacheStatus: cacheStatus
|
|
)
|
|
}
|
|
|
|
}
|