Last active
December 17, 2017 17:34
-
-
Save romansl/b3dd199532cfa4481b60953440912e92 to your computer and use it in GitHub Desktop.
Coroutine version.
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
class Rest { | |
suspend fun sendInstalledApps() {} | |
suspend fun updateCustomer() {} | |
suspend fun checkClientVersion() {} | |
suspend fun createOrUpdateDevice() {} | |
suspend fun refreshCustomerToken() {} | |
suspend fun getProfile() {} | |
} | |
suspend fun register(): Profile { | |
rest.checkClientVersion() | |
rest.sendInstalledApps(App.installedPackages) | |
val device = rest.createOrUpdateDevice() | |
val tokenData = if (device.data?.device?.isCustomer == true) { | |
rest.updateCustomer(prefStorage.googleAuth) | |
rest.refreshCustomerToken() | |
} else { | |
val td = rest.refreshCustomerToken() | |
rest.updateCustomer() | |
td | |
} | |
tokenData.data?.let { | |
prefStorage.accessToken.set(it.accessToken) | |
} | |
val profileData = rest.getProfile() | |
return profileData.data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment