Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
os:
- linux
- osx
language: generic
sudo: required
dist: trusty
osx_image: xcode8
script:
- eval "$(curl -sL https://swift.vapor.sh/ci)"
- eval "$(curl -sL https://swift.vapor.sh/codecov)"
16 changes: 8 additions & 8 deletions Sources/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal final class APIClient: NSObject {
self.baseURL = url
}

func get(path: URL, rawResponse: Bool = false, headers: [String : String] = [:], params: [String : AnyObject] = [:], _ handler: @escaping (AnyObject?, Error?) -> Void) {
func get(path: URL, rawResponse: Bool = false, headers: [String : String] = [:], params: [String : String] = [:], _ handler: @escaping (AnyObject?, Error?) -> Void) {
let request: URLRequest = requestFor(path, method: .GET, headers: headers, params: params, body: nil)
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: nil)
let task = session.dataTask(with: request) { data, response, error in
Expand All @@ -76,7 +76,7 @@ internal final class APIClient: NSObject {
task.resume()
}

func post(path: URL, rawResponse: Bool = false, headers: [String : String] = [:], params: [String : AnyObject] = [:], body: String? = nil, _ handler: @escaping (AnyObject?, Error?) -> Void) {
func post(path: URL, rawResponse: Bool = false, headers: [String : String] = [:], params: [String : String] = [:], body: String? = nil, _ handler: @escaping (AnyObject?, Error?) -> Void) {
let bodyData: Data? = body?.data(using: String.Encoding.utf8)
let request: URLRequest = requestFor(path, method: .POST, headers: headers, params: params, body: bodyData)
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: nil)
Expand All @@ -90,7 +90,7 @@ internal final class APIClient: NSObject {

// MARK: Private Helpers

private func requestFor(_ url: URL, method: APIMethod, headers: [String : String] = [:], params: [String : AnyObject] = [:], body: Data?) -> URLRequest {
private func requestFor(_ url: URL, method: APIMethod, headers: [String : String] = [:], params: [String : String] = [:], body: Data?) -> URLRequest {
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: ApiClientTimeout)
request.httpMethod = method.description
request.addValue(encodedAuthorizationHeader, forHTTPHeaderField: "Authorization")
Expand All @@ -106,11 +106,11 @@ internal final class APIClient: NSObject {
} else {
var components = URLComponents(url: url, resolvingAgainstBaseURL: false)
let queryItems: [URLQueryItem] = params.map {
if let val = $0.value as? String {
return URLQueryItem(name: $0.key, value: val)
} else {
return URLQueryItem(name: $0.key, value: String(describing: $0.value))
}
// if let val = $0.value as? String {
return URLQueryItem(name: $0.key, value: $0.value)
// } else {
// return URLQueryItem(name: $0.key, value: String(describing: $0.value))
// }
}

components?.queryItems = queryItems
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoberturaCoverage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension Jenkins {
return handler(nil)
}

let parameters: [String : AnyObject] = ["depth" : depth as AnyObject]
let parameters: [String : String] = ["depth" : String(depth)]
client?.get(path: url, params: parameters) { response, error in
guard let json = response as? JSON,
let results = json["results"] as? JSON else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Job.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public extension Jenkins {
return
}

client?.post(path: url, params: parameters as [String : AnyObject]) { response, error in
client?.post(path: url, params: parameters) { response, error in
handler(error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/JobConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public extension Jenkins {
return
}

client?.post(path: url, params: ["description" : description as AnyObject]) { response, error in
client?.post(path: url, params: ["description" : description]) { response, error in
handler(error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/JobParameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct JobParameter {
}

if let defaultValueBlock = json["defaultParameterValue"] as? JSON,
let defaultValue = defaultValueBlock["value"] as AnyObject! {
let defaultValue = defaultValueBlock["value"] {
self.parameter = defaultValue
}
}
Expand Down