/
XcodeServer+Toolchain.swift
38 lines (33 loc) · 1.23 KB
/
XcodeServer+Toolchain.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// XcodeServer+Toolchain.swift
// XcodeServerSDK
//
// Created by Laurent Gaches on 21/04/16.
// Copyright © 2016 Laurent Gaches. All rights reserved.
//
import Foundation
import BuildaUtils
// MARK: - Toolchain XcodeSever API Routes
extension XcodeServer {
/**
XCS API call for getting all available toolchains.
- parameter toolchains: Optional array of available toolchains.
- parameter error: Optional error.
*/
public final func getToolchains(completion: (toolchains: [Toolchain]?,error: NSError?) -> ()) {
self.sendRequestWithMethod(.GET, endpoint: .Toolchains, params: nil, query: nil, body: nil) { (response, body, error) in
if error != nil {
completion(toolchains: nil, error: error)
return
}
if let body = (body as? NSDictionary)?["results"] as? NSArray {
let (result, error): ([Toolchain]?, NSError?) = unthrow { _ in
return try XcodeServerArray(body)
}
completion(toolchains: result, error: error)
} else {
completion(toolchains: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
}