Skip to content

Commit

Permalink
REF: Make offset temperature optional in Bed and Tool object
Browse files Browse the repository at this point in the history
  • Loading branch information
josefdolezal committed May 13, 2017
1 parent 4c02c97 commit b43caf6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion OctoPhone/Networking/Model Mapping/Bed+JSONAble.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ extension Bed: JSONAble {
static func fromJSON(json: [String : Any]) throws -> Bed {
guard
let actual = json["actual"] as? Double,
let offset = json["offset"] as? Double,
let target = json["target"] as? Double
else {
throw JSONAbleError.errorMappingJSONToObject(json: json)
}

let offset = json["offset"] as? Double ?? 0.0

return Bed(actualTemperature: actual, targetTemperature: target, offsetTemperature: offset)
}
}
3 changes: 2 additions & 1 deletion OctoPhone/Networking/Model Mapping/Tool+JSONAble.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ extension Tool: JSONAble {
static func fromJSON(json: [String : Any]) throws -> Tool {
guard
let actual = json["actual"] as? Double,
let offset = json["offset"] as? Double,
let target = json["target"] as? Double
else {
throw JSONAbleError.errorMappingJSONToObject(json: json)
}

let offset = json["offset"] as? Double ?? 0.0

return Tool(actual: actual, offset: offset, target: target)
}
}

0 comments on commit b43caf6

Please sign in to comment.