Class
OpenWeather
public final class OpenWeather
Relationships
Nested Types
OpenWeather.Settings
Type that can be used to configure all settings at once
Initializers
init(apiKey:)
public init(apiKey: String? = nil)
init(settings:)
public init(settings: Settings)
Properties
apiKey
public var apiKey : String?
The OpenWeatherMap API key to authorize requests
language
public var language: RequestLanguage = .english
The language that should be used in API responses
units
public var units: RequestUnits = .metric
The units that should be used to format the API responses
Methods
requestWeather(coordinate:excludedFields:date:urlSession:finishingQueue:progressHandler:completion:)
public func requestWeather(
coordinate: CLLocationCoordinate2D,
excludedFields: [ExcludableField]? = nil,
date: Date? = nil,
urlSession: URLSession = .shared,
finishingQueue: DispatchQueue = .main,
progressHandler: ProgressHandler? = nil,
completion: @escaping (Result<WeatherResponse, Error>) -> Void)
schedule(_:progressHandler:completion:)
public func schedule(
_ request: WeatherRequest,
progressHandler: ProgressHandler? = nil,
completion: @escaping (Result<WeatherRequest.Output, Error>) -> Void)
Sends the specified request to the OpenWeather API
Parameters
Name | Type | Description |
---|---|---|
request | WeatherRequest |
The request object that holds information about request location, date, etc. |
completion | @escaping (Result<WeatherRequest.Output, Error>) -> Void |
The completion block that will be called once the networking finishes |
Returns
A network task that can be used to cancel the request
apply(_:)
public func apply(_ settings: Settings)
Applies new settings to the weather client
Parameters
Name | Type | Description |
---|---|---|
settings | Settings |
The weather client settings, including an API key, language and units |