public func getAccountBalances(completion: @escaping (ResponseType) -> Void) {
let apiType = Kraken.API.getAccountBalance
if apiType.checkInterval(response: store.balanceResponse) {
completion(.cached)
} else {
krakenDataTaskFor(api: apiType) { (response) in
guard let json = response.json as? Dictionary<String, Any> else {
print("Error: Cast Failed in \(#function)")
return
}
let arrayOfCryptoBalances = json["result"] as! Dictionary<String,String>
var balances: [Balance] = []
for cryptoBalance in arrayOfCryptoBalances {
let newBalance = ["type": cryptoBalance.key,
"amount": cryptoBalance.value,
"available": cryptoBalance.value]
balances.append(Balance(json: newBalance, currencyStore: self))
}
self.store.balances = balances
self.store.balanceResponse = response.httpResponse
completion(.fetched)
}.resume()
}
}
Do you want me to create a pull request with my solution or are you taking care of it yourself? Maybe Kraken has updated the API since you wrote it. Also I found it annoying by Kraken that they decided to call most of the crypto currencies with own symbols. e.g. XBT instead of BTC for Bitcoin... is this what your overwrite function is for?