Last active
November 12, 2018 06:22
-
-
Save Kilo-Loco/7687e77fbe2b91a59c23c1a741d62ff4 to your computer and use it in GitHub Desktop.
Currency Result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CurrencyResult: Codable { | |
let success: Bool | |
let name: String | |
let date: String | |
let rawCurrencies: [String: Float] | |
var currencies: [Currency] { | |
var currencies = [Currency]() | |
for (uid, rate) in rawCurrencies { | |
let currency = Currency(uid: uid, rate: rate) | |
currencies.append(currency) | |
} | |
return currencies | |
} | |
private enum CodingKeys: String, CodingKey { | |
case success | |
case date | |
case rawCurrencies = "rates" | |
case name = "base" | |
} | |
} | |
struct Currency: Codable { | |
let uid: String | |
let rate: Float | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment