Skip to content

Commit

Permalink
Merge tag '2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
chayelheinsen committed Feb 21, 2018
2 parents 70c0111 + b89eb49 commit e11a397
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions BuckoNetworking/Protocols/DecodableEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ public protocol DecodableEndpoint: Endpoint {

public extension DecodableEndpoint {
@discardableResult
public func request(completion: @escaping ((ResponseType?, Error?) -> Void)) -> Request {
public func request(completion: @escaping ((ResponseType?, DataResponse<Data>) -> Void)) -> Request {
let request = Bucko.shared.requestData(endpoint: self) { response in

if response.result.isSuccess {
guard let value = response.result.value else { return }

do {
let result = try JSONDecoder().decode(ResponseType.self, from: value)
completion(result, nil)
completion(result, response)
} catch {
debugPrint(error)
completion(nil, error)
completion(nil, response)
}
} else {
completion(nil, response.result.error)
completion(nil, response)
}
}

Expand Down
8 changes: 4 additions & 4 deletions BuckoNetworking/Protocols/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ public extension Endpoint {
@discardableResult
public func request<T: Decodable>(
responseType: T.Type,
completion: @escaping ((T?, Error?) -> Void)) -> Request {
completion: @escaping ((T?, DataResponse<Data>) -> Void)) -> Request {
let request = Bucko.shared.requestData(endpoint: self) { response in

if response.result.isSuccess {
guard let value = response.result.value else { return }

do {
let result = try JSONDecoder().decode(T.self, from: value)
completion(result, nil)
completion(result, response)
} catch {
debugPrint(error)
completion(nil, error)
completion(nil, response)
}
} else {
completion(nil, response.result.error)
completion(nil, response)
}
}

Expand Down

0 comments on commit e11a397

Please sign in to comment.