-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LIFX/feature/add-capabilities
Feature/add capabilities
- Loading branch information
Showing
7 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// ProductInformation.swift | ||
// LIFXHTTPKit | ||
// | ||
// Created by LIFX Laptop on 5/4/17. | ||
|
||
import Foundation | ||
|
||
public struct ProductInformation { | ||
public let productName: String | ||
public let manufacturer: String | ||
public let capabilities: Capabilities? | ||
|
||
public init?(data: NSDictionary) { | ||
guard let name = data["name"] as? String, let company = data["company"] as? String, let productCapabilities = data["capabilities"] as? NSDictionary else { | ||
return nil | ||
} | ||
productName = name | ||
manufacturer = company | ||
capabilities = Capabilities(data: productCapabilities) | ||
} | ||
|
||
var description: String { | ||
return "Name: \(productName) - manufactured by \(manufacturer) Capabilities supported - \(String(describing: capabilities?.description))" | ||
} | ||
} | ||
|
||
public struct Capabilities { | ||
public let hasColor: Bool | ||
public let hasIR: Bool | ||
public let hasMulitiZone: Bool | ||
|
||
public init?(data: NSDictionary) { | ||
guard let hasColor = data["has_color"] as? Bool, | ||
let hasIR = data["has_ir"] as? Bool, let multiZone = data["has_multizone"] as? Bool else { | ||
return nil | ||
} | ||
|
||
self.hasColor = hasColor | ||
self.hasIR = hasIR | ||
self.hasMulitiZone = multiZone | ||
} | ||
|
||
var description: String { | ||
return "Color - \(hasColor), Infra-red \(hasIR), Multiple zones - \(hasMulitiZone)" | ||
} | ||
|
||
} |
This file contains 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
This file contains 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