Last active
May 15, 2018 13:04
-
-
Save poksi592/dcd5cf880e99f8700f4ccdf6d7eb0eae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nonCompliantModule = NonConformingModule() | |
nonCompliantModule.login(username: "myUsername", | |
password: "myPassword", | |
completion: { (bearerToken, error) in | |
print(String(describing: bearerToken)) | |
}) | |
class NonConformingModule { | |
func login(username: String, | |
password: String, | |
completion: ((String?, Error?) -> Void)?) { | |
let service = NetworkService() | |
service.post(scheme: "tandem", | |
host: "login", | |
path: "/login", | |
parameters: ["username": "myUsername", | |
"password": "myPassword"]) { (response, urlResponse, error) in | |
// We are not going to check errors and URL response status codes, just a shortest path. | |
var networkError: ResponseError? = nil | |
if let error = error { | |
networkError = ResponseError(error: error, response: urlResponse) | |
} | |
let token = response?["bearerToken"] as? String | |
completion?(token, networkError) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment