Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.