// // Candidate.swift // iris // // Created by Codex. // import Foundation import WeatherKit struct Candidate: Codable, Equatable { let id: String let type: WinnerType let title: String let subtitle: String let confidence: Double let createdAt: Int let ttlSec: Int let condition: WeatherKit.WeatherCondition? let metadata: [String: String]? enum CodingKeys: String, CodingKey { case id case type case title case subtitle case confidence case createdAt case ttlSec case condition case metadata } init(id: String, type: WinnerType, title: String, subtitle: String, confidence: Double, createdAt: Int, ttlSec: Int, condition: WeatherKit.WeatherCondition? = nil, metadata: [String: String]? = nil) { self.id = id self.type = type self.title = title self.subtitle = subtitle self.confidence = confidence self.createdAt = createdAt self.ttlSec = ttlSec self.condition = condition self.metadata = metadata } func isExpired(at now: Int) -> Bool { if ttlSec > 0 { createdAt + ttlSec <= now } else { true } } }