-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Henrik Panhans <[email protected]>
- Loading branch information
1 parent
1661f96
commit 3f5460b
Showing
8 changed files
with
129 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,50 @@ | ||
import Foundation | ||
|
||
extension Weather { | ||
|
||
/// The language that should be used in API responses for example for weather condition descriptions. | ||
public enum Language: String, Codable { | ||
case afrikaans = "af" | ||
case arabic = "ar" | ||
case azerbaijani = "az" | ||
case bulgarian = "bg" | ||
case catalan = "ca" | ||
case czech = "cz" | ||
case danish = "da" | ||
case german = "de" | ||
case greek = "el" | ||
case english = "en" | ||
case basque = "eu" | ||
case persian = "fa" | ||
case finnish = "fi" | ||
case french = "fr" | ||
case galician = "gl" | ||
case hebrew = "he" | ||
case hindi = "hi" | ||
case croatian = "hr" | ||
case hungarian = "hu" | ||
case indonesian = "id" | ||
case italian = "it" | ||
case japanese = "ja" | ||
case korean = "kr" | ||
case latvian = "la" | ||
case lithuanian = "lt" | ||
case macedonian = "mk" | ||
case norwegian = "no" | ||
case dutch = "nl" | ||
case polish = "pl" | ||
case portuguese = "pt" | ||
case portugueseBrasil = "pt_br" | ||
case romanian = "ro" | ||
case russian = "ru" | ||
case swedish = "sv" | ||
case slovak = "sk" | ||
case slovenian = "sl" | ||
case spanish = "es" | ||
case serbian = "sr" | ||
case thai = "th" | ||
case turkish = "tr" | ||
case ukrainian = "ua" | ||
case vietnamese = "vi" | ||
case chineseSimplified = "zh_cn" | ||
case chineseTraditional = "zh_tw" | ||
case zulu = "zu" | ||
} | ||
|
||
/// The language that should be used in API responses for example for weather condition descriptions. | ||
public enum WeatherLanguage: String, Codable { | ||
case afrikaans = "af" | ||
case arabic = "ar" | ||
case azerbaijani = "az" | ||
case bulgarian = "bg" | ||
case catalan = "ca" | ||
case czech = "cz" | ||
case danish = "da" | ||
case german = "de" | ||
case greek = "el" | ||
case english = "en" | ||
case basque = "eu" | ||
case persian = "fa" | ||
case finnish = "fi" | ||
case french = "fr" | ||
case galician = "gl" | ||
case hebrew = "he" | ||
case hindi = "hi" | ||
case croatian = "hr" | ||
case hungarian = "hu" | ||
case indonesian = "id" | ||
case italian = "it" | ||
case japanese = "ja" | ||
case korean = "kr" | ||
case latvian = "la" | ||
case lithuanian = "lt" | ||
case macedonian = "mk" | ||
case norwegian = "no" | ||
case dutch = "nl" | ||
case polish = "pl" | ||
case portuguese = "pt" | ||
case portugueseBrasil = "pt_br" | ||
case romanian = "ro" | ||
case russian = "ru" | ||
case swedish = "sv" | ||
case slovak = "sk" | ||
case slovenian = "sl" | ||
case spanish = "es" | ||
case serbian = "sr" | ||
case thai = "th" | ||
case turkish = "tr" | ||
case ukrainian = "ua" | ||
case vietnamese = "vi" | ||
case chineseSimplified = "zh_cn" | ||
case chineseTraditional = "zh_tw" | ||
case zulu = "zu" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
import Foundation | ||
|
||
extension Weather { | ||
/// The units that should the data in the API responses should be formatted in. | ||
public enum WeatherUnits: String, Codable { | ||
|
||
/// The units that should the data in the API responses should be formatted in. | ||
public enum Units: String, Codable { | ||
/// Temperature in Kelvin and wind speed in meter/sec. | ||
case standard | ||
/// Temperature in Celsius and wind speed in meter/sec. | ||
case metric | ||
/// Temperature in Fahrenheit and wind speed in miles/hour. | ||
case imperial | ||
|
||
/// Temperature in Kelvin and wind speed in meter/sec. | ||
case standard | ||
/// Temperature in Celsius and wind speed in meter/sec. | ||
case metric | ||
/// Temperature in Fahrenheit and wind speed in miles/hour. | ||
case imperial | ||
|
||
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) | ||
var temperatureUnit: UnitTemperature { | ||
switch self { | ||
case .standard: | ||
return .kelvin | ||
case .metric: | ||
return .celsius | ||
case .imperial: | ||
return .fahrenheit | ||
} | ||
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) | ||
var temperatureUnit: UnitTemperature { | ||
switch self { | ||
case .standard: | ||
return .kelvin | ||
case .metric: | ||
return .celsius | ||
case .imperial: | ||
return .fahrenheit | ||
} | ||
} | ||
|
||
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) | ||
var windSpeedUnit: UnitSpeed { | ||
switch self { | ||
case .standard: | ||
return .metersPerSecond | ||
case .metric: | ||
return .metersPerSecond | ||
case .imperial: | ||
return .milesPerHour | ||
} | ||
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) | ||
var windSpeedUnit: UnitSpeed { | ||
switch self { | ||
case .standard: | ||
return .metersPerSecond | ||
case .metric: | ||
return .metersPerSecond | ||
case .imperial: | ||
return .milesPerHour | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
import Foundation | ||
|
||
public enum OpenWeatherError: Error, Equatable { | ||
public enum OpenWeatherError: LocalizedError, Equatable { | ||
|
||
case invalidRequestTimestamp | ||
case invalidAPIKey | ||
case noCurrentConditionReturned | ||
case invalidTimeZoneIdentifier(_ identifier: String) | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case .invalidRequestTimestamp: | ||
return "The request timestamp is invalid" | ||
case .invalidAPIKey: | ||
return "The API key is missing or empty" | ||
case .noCurrentConditionReturned: | ||
return "No current condition was returned" | ||
case .invalidTimeZoneIdentifier(let identifier): | ||
return "The timezone identifier '\(identifier)' is invalid" | ||
} | ||
} | ||
|
||
} |