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
// | |
// AuthenticationDataHandler.swift | |
// Bonfire | |
// | |
// Created by Charles Muchene on 2/10/20. | |
// Copyright © 2020 SenseiDevs. All rights reserved. | |
// | |
import Alamofire | |
import Foundation | |
class AuthenticationDataHandler { | |
/// Login user with given `Login` instance | |
/// - Parameters: | |
/// - login: `Login` instance | |
/// - completionHandler: Handler to receive result | |
func login(with login: Login, completionHandler: @escaping (Result<Token, APIError>) -> Void) { | |
Network.shared.session | |
.request(UserRouter.login(login)) | |
.validate(statusCode: .ok .+ .invalidCredentials) | |
.responseDecodable(of: Token.self, errorCode: .invalidCredentials, completionHandler: completionHandler) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment