From 228b628cc21925fdfade31a273c8fc7462d77558 Mon Sep 17 00:00:00 2001 From: Michael Herring Date: Sun, 11 Feb 2018 22:51:35 +0900 Subject: [PATCH 1/2] Add a closure to pass the user/team IDs when handling auth test success --- Sources/WebAPI.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/WebAPI.swift b/Sources/WebAPI.swift index 695fa29..fc2180e 100644 --- a/Sources/WebAPI.swift +++ b/Sources/WebAPI.swift @@ -35,6 +35,7 @@ public final class WebAPI { public typealias HistoryClosure = (_ history: History) -> Void public typealias FileClosure = (_ file: File) -> Void public typealias ItemsClosure = (_ items: [Item]?) -> Void + public typealias AuthTestClosure = (_ user: String, _ team: String) -> Void public enum InfoType: String { case purpose, topic @@ -115,9 +116,9 @@ extension WebAPI { // MARK: - Auth extension WebAPI { - public func authenticationTest(success: SuccessClosure?, failure: FailureClosure?) { - networkInterface.request(.authTest, parameters: ["token": token], successClosure: { _ in - success?(true) + public func authenticationTest(success: AuthTestClosure?, failure: FailureClosure?) { + networkInterface.request(.authTest, parameters: ["token": token], successClosure: { (response) in + success?(response["user_id"] as! String, response["team_id"] as! String) }) {(error) in failure?(error) } From 76a2bd12d7c91a2e59a2517f79b5c140bcaf57f6 Mon Sep 17 00:00:00 2001 From: Michael Herring Date: Mon, 19 Feb 2018 13:37:47 +0900 Subject: [PATCH 2/2] change AuthTestClosure args to be string optionals instead --- Sources/WebAPI.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/WebAPI.swift b/Sources/WebAPI.swift index fc2180e..98716b7 100644 --- a/Sources/WebAPI.swift +++ b/Sources/WebAPI.swift @@ -35,7 +35,7 @@ public final class WebAPI { public typealias HistoryClosure = (_ history: History) -> Void public typealias FileClosure = (_ file: File) -> Void public typealias ItemsClosure = (_ items: [Item]?) -> Void - public typealias AuthTestClosure = (_ user: String, _ team: String) -> Void + public typealias AuthTestClosure = (_ user: String?, _ team: String?) -> Void public enum InfoType: String { case purpose, topic @@ -118,7 +118,7 @@ extension WebAPI { extension WebAPI { public func authenticationTest(success: AuthTestClosure?, failure: FailureClosure?) { networkInterface.request(.authTest, parameters: ["token": token], successClosure: { (response) in - success?(response["user_id"] as! String, response["team_id"] as! String) + success?(response["user_id"] as? String, response["team_id"] as? String) }) {(error) in failure?(error) }