Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexbaramilis/5063e74263373c80d65b47c06d1682f3 to your computer and use it in GitHub Desktop.
Save alexbaramilis/5063e74263373c80d65b47c06d1682f3 to your computer and use it in GitHub Desktop.
Air by Propeller's API forecast response with Decodable and CodingKeys
struct PropellerForecastResponse: Decodable {
let properties: PropellerForecastProperties
}
struct PropellerForecastProperties: Decodable {
let risk: String // risk of adverse respiratory conditions: "high", "medium" or "low"
let probability: Double // probability of adverse respiratory conditions: ex. 0.4938...
}
// MARK: - CodingKeys
extension PropellerForecastProperties {
enum CodingKeys: String, CodingKey {
case risk = "code"
case probability = "value"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment