Skip to content

Commit bdc2849

Browse files
committed
Merge branch 'release/2.0.0'
2 parents dfb338e + a0b89e2 commit bdc2849

22 files changed

Lines changed: 865 additions & 851 deletions

Cartfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
github "Alamofire/Alamofire" ~> 4.5
1+
github "Alamofire/Alamofire" ~> 4.5.0
2+
github "ReactiveX/RxSwift" ~> 4.0

IPFSWebService.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'IPFSWebService'
3-
s.version = '1.1.0'
3+
s.version = '2.0.0'
44
s.summary = 'Defines and versions the HTTP based IPFS interface.'
55
s.description = <<-DESC
66
The API for communication with an IPFS server is defined and versioned by
@@ -19,4 +19,5 @@ Pod::Spec.new do |s|
1919
s.osx.deployment_target = '10.13'
2020

2121
s.dependency 'Alamofire', '~> 4.5'
22+
s.dependency 'RxSwift', '~> 4.0'
2223
end

SwaggerClient/Classes/Swaggers/APIHelper.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,17 @@ class APIHelper {
4949
return destination
5050
}
5151

52+
5253
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
5354
let returnValues = values
5455
.filter { $0.1 != nil }
55-
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
56-
if let value = item._value as? Array<String> {
57-
return value.map { (v) -> URLQueryItem in
58-
URLQueryItem(
59-
name: item._key,
60-
value: v
61-
)
62-
}
63-
} else {
64-
return [URLQueryItem(
65-
name: item._key,
66-
value: "\(item._value!)"
67-
)]
68-
}
56+
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
57+
URLQueryItem(name: item._key, value:"\(item._value!)")
6958
}
70-
.flatMap { $0 }
71-
72-
if returnValues.isEmpty { return nil }
59+
if returnValues.count == 0 {
60+
return nil
61+
}
7362
return returnValues
7463
}
64+
7565
}

SwaggerClient/Classes/Swaggers/APIs.swift

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,18 @@ open class SwaggerClientAPI {
1313
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
1414
}
1515

16-
open class APIBase {
17-
func toParameters(_ encodable: JSONEncodable?) -> [String: Any]? {
18-
let encoded: Any? = encodable?.encodeToJSON()
19-
20-
if encoded! is [Any] {
21-
var dictionary = [String:Any]()
22-
for (index, item) in (encoded as! [Any]).enumerated() {
23-
dictionary["\(index)"] = item
24-
}
25-
return dictionary
26-
} else {
27-
return encoded as? [String:Any]
28-
}
29-
}
30-
}
31-
3216
open class RequestBuilder<T> {
3317
var credential: URLCredential?
3418
var headers: [String:String]
35-
public let parameters: Any?
36-
public let isBody: Bool
37-
public let method: String
38-
public let URLString: String
19+
let parameters: [String:Any]?
20+
let isBody: Bool
21+
let method: String
22+
let URLString: String
3923

4024
/// Optional block to obtain a reference to the request's progress instance when available.
4125
public var onProgressReady: ((Progress) -> ())?
4226

43-
required public init(method: String, URLString: String, parameters: Any?, isBody: Bool, headers: [String:String] = [:]) {
27+
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
4428
self.method = method
4529
self.URLString = URLString
4630
self.parameters = parameters
@@ -52,13 +36,13 @@ open class RequestBuilder<T> {
5236

5337
open func addHeaders(_ aHeaders:[String:String]) {
5438
for (header, value) in aHeaders {
55-
addHeader(name: header, value: value)
39+
headers[header] = value
5640
}
5741
}
5842

59-
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: ErrorResponse?) -> Void) { }
43+
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) { }
6044

61-
@discardableResult public func addHeader(name: String, value: String) -> Self {
45+
public func addHeader(name: String, value: String) -> Self {
6246
if !value.isEmpty {
6347
headers[name] = value
6448
}
@@ -72,6 +56,6 @@ open class RequestBuilder<T> {
7256
}
7357

7458
public protocol RequestBuilderFactory {
75-
func getBuilder<T>() -> RequestBuilder<T>.Type
59+
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
60+
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
7661
}
77-

0 commit comments

Comments
 (0)