Skip to content

Commit

Permalink
[REFACTOR] default User 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eshc123 committed Sep 28, 2022
1 parent f084ddc commit 68bb945
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.eshc.data.model.toUser
import com.eshc.data.source.UserDataSource
import com.eshc.data.source.remote.api.GithubService
import com.eshc.domain.model.User
import com.eshc.domain.model.defaultUser
import io.reactivex.rxjava3.core.Single
import javax.inject.Inject

Expand All @@ -14,7 +13,7 @@ class UserDataSourceImpl @Inject constructor(
override fun getUser(): Single<Result<User>> {
return githubService.getUserData()
.map {
Result.success(it.body()?.toUser() ?: defaultUser())
Result.success(it.body()?.toUser() ?: User())
}
.onErrorReturn {
Result.failure(it.cause ?: Throwable("User Error"))
Expand Down
37 changes: 11 additions & 26 deletions domain/src/main/java/com/eshc/domain/model/User.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package com.eshc.domain.model

data class User(
val id : Long,
val login : String,
val avatarUrl : String,
val name : String,
val blog : String,
val location : String,
val email : String,
val bio : String,
val publicRepos : Int,
val followers : Int,
val following : Int
val id : Long = -1,
val login : String = "",
val avatarUrl : String = "",
val name : String = "",
val blog : String = "",
val location : String = "",
val email : String = "",
val bio : String = "",
val publicRepos : Int = 0,
val followers : Int = 0,
val following : Int = 0
)

fun defaultUser() : User {
return User(
id = -1,
login = "",
avatarUrl = "",
name = "",
blog = "",
location = "",
email = "",
bio = "",
publicRepos = 0,
followers = 0,
following = 0
)
}

0 comments on commit 68bb945

Please sign in to comment.