Skip to content

Commit

Permalink
[FEATURE] #30 UserDataSource, UserRepository - GetUserStarred 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
eshc123 committed Sep 29, 2022
1 parent 1ce6db9 commit 7f13a86
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/src/main/java/com/eshc/data/model/StarredEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.eshc.data.model

data class StarredEntity(
val id : Long
)
2 changes: 2 additions & 0 deletions data/src/main/java/com/eshc/data/source/UserDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import io.reactivex.rxjava3.core.Single

interface UserDataSource {
fun getUser() : Single<Result<User>>

fun getUserStarred() : Single<Result<Int>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ class UserDataSourceImpl @Inject constructor(
Result.failure(it.cause ?: Throwable("User Error"))
}
}

override fun getUserStarred(): Single<Result<Int>> {
return githubService.getStarredRepos()
.map {
Result.success(it.body()?.size ?: 0)
}
.onErrorReturn {
Result.failure(it.cause ?: Throwable("Starred Error"))
}
}
}

0 comments on commit 7f13a86

Please sign in to comment.