Files
rider-pro-android-app/app/src/main/java/com/aiosman/riderpro/data/UserService.kt

34 lines
957 B
Kotlin
Raw Normal View History

2024-07-29 00:01:09 +08:00
package com.aiosman.riderpro.data
2024-08-11 17:15:17 +08:00
import com.aiosman.riderpro.data.api.ApiClient
2024-07-29 00:01:09 +08:00
import com.aiosman.riderpro.test.TestDatabase
2024-07-30 16:57:25 +08:00
data class UserAuth(
val id: Int,
val token: String? = null
)
2024-07-29 00:01:09 +08:00
interface UserService {
2024-08-11 17:15:17 +08:00
suspend fun getUserProfile(id: String): AccountProfileEntity
suspend fun followUser(id: String)
suspend fun unFollowUser(id: String)
2024-07-31 14:50:55 +08:00
2024-07-29 00:01:09 +08:00
}
class TestUserServiceImpl : UserService {
2024-08-11 17:15:17 +08:00
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
2024-07-29 00:01:09 +08:00
}
}