-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0d6fa9
commit a7db0b1
Showing
12 changed files
with
353 additions
and
188 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
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,55 @@ | ||
// | ||
// Alerts.swift | ||
// TeslaKit | ||
// | ||
// Copyright © 2022 David Lüthi. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ObjectMapper | ||
import MapKit | ||
|
||
public struct Alerts { | ||
public var recent_alerts: [Recent_Alert] = [] | ||
public init() {} | ||
public init(recent_alerts: [Recent_Alert]) { | ||
self.recent_alerts = recent_alerts | ||
} | ||
} | ||
|
||
extension Alerts: Mappable { | ||
public mutating func mapping(map: Map) { | ||
recent_alerts <- map["recent_alerts"] | ||
} | ||
} | ||
|
||
public struct Recent_Alert { | ||
public var allValues: Map | ||
public var name: String = "" | ||
public var time: String = "" | ||
public var audience: [String] = [] | ||
public var user_text: String = "" | ||
public init() { | ||
allValues = Map(mappingType: .fromJSON, JSON: ["":""]) | ||
} | ||
} | ||
|
||
extension Recent_Alert: DataResponse { | ||
public mutating func mapping(map: Map) { | ||
allValues = map | ||
name <- map["name"] | ||
time <- map["time"] | ||
audience <- map["audience"] | ||
user_text <- map["user_text"] | ||
} | ||
} | ||
|
||
extension Recent_Alert: Hashable { | ||
public static func == (lhs: Self, rhs: Self) -> Bool { | ||
return lhs.name == rhs.name | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(name) | ||
} | ||
} |
Oops, something went wrong.