|
|
|
|
@ -266,7 +266,26 @@ import Combine |
|
|
|
|
// return units.reduce(0) { $0 + $1.purchasedQuantity } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func paymentForNewTournament() -> TournamentPayment? { |
|
|
|
|
struct CanCreateResponse: Decodable { var canCreate: Bool } |
|
|
|
|
|
|
|
|
|
public func paymentForNewTournament() async -> TournamentPayment? { |
|
|
|
|
|
|
|
|
|
if let payment = self.localPaymentForNewTournament() { |
|
|
|
|
return payment |
|
|
|
|
} else if let services = try? StoreCenter.main.service() { |
|
|
|
|
do { |
|
|
|
|
let response: CanCreateResponse = try await services.run(path: "is_granted_unlimited_access/", method: .get, requiresToken: true) |
|
|
|
|
if response.canCreate { |
|
|
|
|
return .unlimited |
|
|
|
|
} |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func localPaymentForNewTournament() -> TournamentPayment? { |
|
|
|
|
|
|
|
|
|
switch self.currentPlan { |
|
|
|
|
case .monthlyUnlimited: |
|
|
|
|
|