login

The login endpoint should be the first endpoints that’s called on the SDK as it provides all the credentials needed internally to the SDK to allow for other protected endpoints to be called (other authentication methods will be added in the future). The token management system within the SDK will provide the authorisation token on each request once logged in.

login(userLogin: UserLogin) : Call<UserInfo>

Parameters

user’s email and password
userLogin: UserLogin

Returns

callback with user’s object
Call UserInfo

Errors

Examples

Android

val userService = KarhooApi.userService
val userLogin = UserLogin(email = "[email protected]", password = "password")

userService.loginUser().execute { result ->
    when (result) {
        is Resource.Success -> print(result.data) // Handle data
        is Resource.Failure -> print(result.error.internalMessage) //Handle errors
    }
}

iOS

let userService = Karhoo.getUserService()
let userLogin = UserLogin(username: "[email protected]", password: "password")

userService.login(userLogin: userLogin).execute { result in
     switch result {
        case .success(let user):
            print("User: \(user)")
        case .failure(let error):
            print("error: \(error.code) \(error.message)")
    }
}