add poi type to feed item shape
This commit is contained in:
@@ -36,6 +36,7 @@ struct FeedItem: Codable, Equatable {
|
||||
let ttlSec: Int
|
||||
let condition: WeatherKit.WeatherCondition?
|
||||
let startsAt: Int?
|
||||
let poiType: POIDataSource.POIType?
|
||||
let bucket: Bucket
|
||||
let actions: [String]
|
||||
|
||||
@@ -48,6 +49,7 @@ struct FeedItem: Codable, Equatable {
|
||||
case ttlSec = "ttl_sec"
|
||||
case condition
|
||||
case startsAt = "starts_at"
|
||||
case poiType = "poi_type"
|
||||
case bucket
|
||||
case actions
|
||||
}
|
||||
@@ -60,6 +62,7 @@ struct FeedItem: Codable, Equatable {
|
||||
ttlSec: Int,
|
||||
condition: WeatherKit.WeatherCondition? = nil,
|
||||
startsAt: Int? = nil,
|
||||
poiType: POIDataSource.POIType? = nil,
|
||||
bucket: Bucket,
|
||||
actions: [String]) {
|
||||
self.id = id
|
||||
@@ -70,6 +73,7 @@ struct FeedItem: Codable, Equatable {
|
||||
self.ttlSec = ttlSec
|
||||
self.condition = condition
|
||||
self.startsAt = startsAt
|
||||
self.poiType = poiType
|
||||
self.bucket = bucket
|
||||
self.actions = actions
|
||||
}
|
||||
@@ -85,6 +89,11 @@ struct FeedItem: Codable, Equatable {
|
||||
bucket = try container.decode(Bucket.self, forKey: .bucket)
|
||||
actions = try container.decode([String].self, forKey: .actions)
|
||||
startsAt = try container.decodeIfPresent(Int.self, forKey: .startsAt)
|
||||
if let raw = try container.decodeIfPresent(String.self, forKey: .poiType) {
|
||||
poiType = POIDataSource.POIType(rawValue: raw) ?? .other
|
||||
} else {
|
||||
poiType = nil
|
||||
}
|
||||
|
||||
if let encoded = try container.decodeIfPresent(String.self, forKey: .condition) {
|
||||
condition = WeatherKit.WeatherCondition.irisDecode(encoded)
|
||||
@@ -104,6 +113,9 @@ struct FeedItem: Codable, Equatable {
|
||||
try container.encode(bucket, forKey: .bucket)
|
||||
try container.encode(actions, forKey: .actions)
|
||||
try container.encodeIfPresent(startsAt, forKey: .startsAt)
|
||||
if let poiType {
|
||||
try container.encode(poiType.rawValue, forKey: .poiType)
|
||||
}
|
||||
if let condition {
|
||||
try container.encode(condition.irisScreamingCase(), forKey: .condition)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user