Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
connorpower committed Jan 19, 2018
2 parents dfb338e + a0b89e2 commit bdc2849
Show file tree
Hide file tree
Showing 22 changed files with 865 additions and 851 deletions.
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "Alamofire/Alamofire" ~> 4.5
github "Alamofire/Alamofire" ~> 4.5.0
github "ReactiveX/RxSwift" ~> 4.0
3 changes: 2 additions & 1 deletion IPFSWebService.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'IPFSWebService'
s.version = '1.1.0'
s.version = '2.0.0'
s.summary = 'Defines and versions the HTTP based IPFS interface.'
s.description = <<-DESC
The API for communication with an IPFS server is defined and versioned by
Expand All @@ -19,4 +19,5 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.13'

s.dependency 'Alamofire', '~> 4.5'
s.dependency 'RxSwift', '~> 4.0'
end
24 changes: 7 additions & 17 deletions SwaggerClient/Classes/Swaggers/APIHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,17 @@ class APIHelper {
return destination
}


static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
let returnValues = values
.filter { $0.1 != nil }
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
if let value = item._value as? Array<String> {
return value.map { (v) -> URLQueryItem in
URLQueryItem(
name: item._key,
value: v
)
}
} else {
return [URLQueryItem(
name: item._key,
value: "\(item._value!)"
)]
}
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
URLQueryItem(name: item._key, value:"\(item._value!)")
}
.flatMap { $0 }

if returnValues.isEmpty { return nil }
if returnValues.count == 0 {
return nil
}
return returnValues
}

}
36 changes: 10 additions & 26 deletions SwaggerClient/Classes/Swaggers/APIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,18 @@ open class SwaggerClientAPI {
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
}

open class APIBase {
func toParameters(_ encodable: JSONEncodable?) -> [String: Any]? {
let encoded: Any? = encodable?.encodeToJSON()

if encoded! is [Any] {
var dictionary = [String:Any]()
for (index, item) in (encoded as! [Any]).enumerated() {
dictionary["\(index)"] = item
}
return dictionary
} else {
return encoded as? [String:Any]
}
}
}

open class RequestBuilder<T> {
var credential: URLCredential?
var headers: [String:String]
public let parameters: Any?
public let isBody: Bool
public let method: String
public let URLString: String
let parameters: [String:Any]?
let isBody: Bool
let method: String
let URLString: String

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

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

open func addHeaders(_ aHeaders:[String:String]) {
for (header, value) in aHeaders {
addHeader(name: header, value: value)
headers[header] = value
}
}

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

@discardableResult public func addHeader(name: String, value: String) -> Self {
public func addHeader(name: String, value: String) -> Self {
if !value.isEmpty {
headers[name] = value
}
Expand All @@ -72,6 +56,6 @@ open class RequestBuilder<T> {
}

public protocol RequestBuilderFactory {
func getBuilder<T>() -> RequestBuilder<T>.Type
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
}

Loading

0 comments on commit bdc2849

Please sign in to comment.