HPOpenWeather Documentation Beta

Class Open​Weather

public final class OpenWeather 

Nested Types

OpenWeather.Settings

Type that can be used to configure all settings at once

Initializers

init(api​Key:​)

public init(apiKey: String? = nil) 

init(settings:​)

public init(settings: Settings) 

Properties

shared

public static let shared 

A shared instance of the weather client

api​Key

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

request​Weather(coordinate:​excluded​Fields:​date:​url​Session:​finishing​Queue:​progress​Handler:​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(_:​progress​Handler:​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

request Weather​Request

The request object that holds information about request location, date, etc.

completion @escaping (Result<Weather​Request.​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

settings Settings

The weather client settings, including an API key, language and units