File tree Expand file tree Collapse file tree 3 files changed +6
-8
lines changed
SkyWizardAPI/Sources/SkyWizardService/Weather Expand file tree Collapse file tree 3 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ import SkyWizardEnum
1111import SkyWizardModel
1212
1313public protocol WeatherService {
14- typealias TaskType = Task < WeatherData , Error >
15- func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> TaskType
14+ func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> WeatherData
1615 func getWeatherType( for current: WeatherData . CurrentWeatherData ) -> CurrentWeatherType
1716 func getWeather( for daily: WeatherData . DailyWeatherData ) throws -> [ DailyWeatherData ]
1817 func getWeather( for hourly: WeatherData . HourlyWeatherData ) throws -> [ HourlyWeatherData ]
Original file line number Diff line number Diff line change @@ -12,10 +12,8 @@ import SkyWizardModel
1212
1313#if DEBUG
1414public class WeatherServiceMock : WeatherService {
15- public func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> TaskType {
16- return Task {
17- . sample
18- }
15+ public func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> WeatherData {
16+ . sample
1917 }
2018
2119 public func getWeatherType( for current: WeatherData . CurrentWeatherData ) -> CurrentWeatherType {
Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ public final class WeatherServiceRemote: WeatherService {
1818 self . dataTransferService = dataTransferService
1919 }
2020
21- public func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> TaskType {
22- await dataTransferService. request ( with: WeatherEndpoints . getWeather ( latitude: location. latitude, longitude: location. longitude) )
21+ public func fetchWeather( for location: CLLocationCoordinate2D ) async throws -> WeatherData {
22+ let task = await dataTransferService. request ( with: WeatherEndpoints . getWeather ( latitude: location. latitude, longitude: location. longitude) )
23+ return try await task. value
2324 }
2425
2526 public func getWeatherType( for current: WeatherData . CurrentWeatherData ) -> CurrentWeatherType {
You can’t perform that action at this time.
0 commit comments