Untitled

 avatar
unknown
plain_text
12 days ago
1.0 kB
5
Indexable
class AuthenticationServiceImpl : AuthenticationService {

    override fun authenticate(authType: AuthType, credentials: Credentials, callback: (Result<String>) -> Unit) {
        when (authType) {
            AuthType.SOFTPOS -> authenticateSoftPOS(credentials, callback)
            AuthType.MPOC_SDK -> authenticateMPOCSDK(credentials, callback)
        }
    }

    private fun authenticateSoftPOS(credentials: Credentials, callback: (Result<String>) -> Unit) {
        // Ideally REST API oterwise will open webview 
        val authUrl = "wallee auth REST"
        callback(Result.success(authUrl)) // logic to process the login 
    }

    private fun authenticateMPOCSDK(credentials: Credentials, callback: (Result<String>) -> Unit) {
        // hwre we generate the token for third party autheticator
        val token = generateAuthToken(credentials)  
        callback(Result.success(token))
    }

    private fun generateAuthToken(credentials: Credentials): String {
        return "token (public API)"
    }
}
Editor is loading...
Leave a Comment