// // WeatherData.swift // Reflect // // Codable weather model stored as JSON string in MoodEntryModel. // import Foundation struct WeatherData: Codable { let conditionSymbol: String // SF Symbol from WeatherKit (e.g. "cloud.sun.fill") let condition: String // "Partly Cloudy" let temperature: Double // Current/average in Celsius let highTemperature: Double // Day high in Celsius let lowTemperature: Double // Day low in Celsius let humidity: Double // 0.0–1.0 let latitude: Double let longitude: Double let fetchedAt: Date // MARK: - JSON Helpers func encode() -> String? { guard let data = try? JSONEncoder().encode(self) else { return nil } return String(data: data, encoding: .utf8) } static func decode(from json: String) -> WeatherData? { guard let data = json.data(using: .utf8) else { return nil } return try? JSONDecoder().decode(WeatherData.self, from: data) } }