-
Notifications
You must be signed in to change notification settings - Fork 30
/
XcodeServer+Device.swift
41 lines (33 loc) · 1.29 KB
/
XcodeServer+Device.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
39
40
41
//
// XcodeServer+Device.swift
// XcodeServerSDK
//
// Created by Mateusz Zając on 01/07/15.
// Copyright © 2015 Honza Dvorsky. All rights reserved.
//
import Foundation
import BuildaUtils
// MARK: - XcodeSever API Routes for Devices management
extension XcodeServer {
/**
XCS API call for retrieving all registered devices on OS X Server.
- parameter devices: Optional array of available devices.
- parameter error: Optional error indicating that something went wrong.
*/
public final func getDevices(completion: (devices: [Device]?, error: NSError?) -> ()) {
self.sendRequestWithMethod(.GET, endpoint: .Devices, params: nil, query: nil, body: nil) { (response, body, error) -> () in
if error != nil {
completion(devices: nil, error: error)
return
}
if let array = (body as? NSDictionary)?["results"] as? NSArray {
let (result, error): ([Device]?, NSError?) = unthrow {
return try XcodeServerArray(array)
}
completion(devices: result, error: error)
} else {
completion(devices: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
}