Skip to content

Instantly share code, notes, and snippets.

@Kilo-Loco
Last active November 12, 2018 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kilo-Loco/7687e77fbe2b91a59c23c1a741d62ff4 to your computer and use it in GitHub Desktop.
Save Kilo-Loco/7687e77fbe2b91a59c23c1a741d62ff4 to your computer and use it in GitHub Desktop.
Currency Result
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