Skip to content

Instantly share code, notes, and snippets.

@charlesmuchene
Created February 12, 2020 19:16
Show Gist options
  • Save charlesmuchene/0687156ed005bfa558323153a49e87fb to your computer and use it in GitHub Desktop.
Save charlesmuchene/0687156ed005bfa558323153a49e87fb to your computer and use it in GitHub Desktop.
//
// 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