更新
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.aiosman.riderpro.data
|
||||
|
||||
import com.aiosman.riderpro.data.api.ApiClient
|
||||
import com.aiosman.riderpro.test.TestDatabase
|
||||
|
||||
data class UserAuth(
|
||||
@@ -8,17 +9,26 @@ data class UserAuth(
|
||||
)
|
||||
|
||||
interface UserService {
|
||||
suspend fun getUserProfile(id: String): AccountProfile
|
||||
suspend fun getUserProfile(id: String): AccountProfileEntity
|
||||
suspend fun followUser(id: String)
|
||||
suspend fun unFollowUser(id: String)
|
||||
|
||||
}
|
||||
|
||||
class TestUserServiceImpl : UserService {
|
||||
override suspend fun getUserProfile(id: String): AccountProfile {
|
||||
TestDatabase.accountData.forEach {
|
||||
if (it.id == id.toInt()) {
|
||||
return it
|
||||
}
|
||||
}
|
||||
return AccountProfile(0, 0, 0, "", "", "", "")
|
||||
override suspend fun getUserProfile(id: String): AccountProfileEntity {
|
||||
val resp = ApiClient.api.getAccountProfileById(id.toInt())
|
||||
val body = resp.body() ?: throw ServiceException("Failed to get account")
|
||||
return body.data.toAccountProfileEntity()
|
||||
}
|
||||
|
||||
override suspend fun followUser(id: String) {
|
||||
val resp = ApiClient.api.followUser(id.toInt())
|
||||
return
|
||||
}
|
||||
|
||||
override suspend fun unFollowUser(id: String) {
|
||||
val resp = ApiClient.api.unfollowUser(id.toInt())
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user