Skip to content

Commit

Permalink
Minimal changes to upgrade to Alamofire 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Edubits committed Oct 19, 2015
1 parent 09f6099 commit 720ccb0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,26 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
request.authenticate(usingCredential: credential)
}

request.responseJSON(options: .AllowFragments) { (req, res, result) in
request.responseJSON(options: .AllowFragments) { response in
managerStore.removeValueForKey(managerId)
if result.isFailure {
completion(response: nil, erorr: result.error)
if response.result.isFailure {
completion(response: nil, erorr: response.result.error)
return
}

if () is T {
let response = Response(response: res!, body: () as! T)
completion(response: response, erorr: nil)
completion(response: Response(response: response.response!, body: () as! T), erorr: nil)
return
}
if let json: AnyObject = result.value {
if let json: AnyObject = response.result.value {
let body = Decoders.decode(clazz: T.self, source: json)
let response = Response(response: res!, body: body)
completion(response: response, erorr: nil)
completion(response: Response(response: response.response!, body: body), erorr: nil)
return
} else if "" is T {
// swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release
// https://github.com/swagger-api/swagger-parser/pull/34
let response = Response(response: res!, body: "" as! T)
completion(response: response, erorr: nil)
completion(response: Response(response: response.response!, body: "" as! T), erorr: nil)
return
}
Expand All @@ -113,4 +110,3 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
return httpHeaders
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Alamofire/Alamofire" >= 2.0.0{{#usePromiseKit}}
github "Alamofire/Alamofire" >= 3.0.0{{#usePromiseKit}}
github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Pod::Spec.new do |s|
s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}}
s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}}
s.dependency 'PromiseKit', '~> 2.1'{{/usePromiseKit}}
s.dependency 'Alamofire', '~> 2.0.0'
s.dependency 'Alamofire', '~> 3.0.0'
end

0 comments on commit 720ccb0

Please sign in to comment.