Files
GitHawk/Classes/Settings/GithubClient+APIStatus.swift
Hesham Salman f213bac924 Thin SwiftLint ruleset (#704)
* Thin SwiftLint ruleset

* Disabled trailing_whitespace rule
2017-10-23 16:58:09 -04:00

33 lines
855 B
Swift

//
// GithubClient+APIStatus.swift
// Freetime
//
// Created by Ryan Nystrom on 8/27/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
extension GithubClient {
enum APIStatus: String {
case good, minor, major
}
func fetchAPIStatus(completion: @escaping (Result<APIStatus>) -> Void) {
request(Request(
url: "https://status.github.com/api/status.json",
method: .get,
completion: { (response, _) in
if let json = response.value as? [String: Any],
let statusString = json["status"] as? String,
let status = APIStatus(rawValue: statusString) {
completion(.success(status))
} else {
completion(.error(nil))
}
}))
}
}