Initial commit
This commit is contained in:
29
SatsPrice/Network/SpotPriceFetcherDelegator.swift
Normal file
29
SatsPrice/Network/SpotPriceFetcherDelegator.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// SpotPriceFetcherDelegator.swift
|
||||
// SatsPrice
|
||||
//
|
||||
// Created by Terry Yiu on 2/20/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BigDecimal
|
||||
|
||||
class SpotPriceFetcherDelegator: SpotPriceFetcher {
|
||||
private let coinbaseSpotPriceFetcher = CoinbaseSpotPriceFetcher()
|
||||
private let coinGeckoSpotPriceFetcher = CoinGeckoSpotPriceFetcher()
|
||||
|
||||
var spotPriceSource: SpotPriceSource = .coinbase
|
||||
|
||||
private var delegate: SpotPriceFetcher {
|
||||
switch spotPriceSource {
|
||||
case .coinbase:
|
||||
coinbaseSpotPriceFetcher
|
||||
case .coingecko:
|
||||
coinGeckoSpotPriceFetcher
|
||||
}
|
||||
}
|
||||
|
||||
func btcToUsd() async throws -> BigDecimal? {
|
||||
return try await delegate.btcToUsd()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user