feat(content): 랭킹 API 계약을 추가한다
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.main.content.data
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Single
|
||||||
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.Header
|
||||||
|
import retrofit2.http.Query
|
||||||
|
|
||||||
|
interface AudioRankingsApi {
|
||||||
|
@GET("/api/v2/audio/rankings")
|
||||||
|
fun getRankings(
|
||||||
|
@Header("Authorization") authHeader: String,
|
||||||
|
@Query("type") type: AudioRankingType
|
||||||
|
): Single<ApiResponse<AudioRankingResponse>>
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.main.content.data
|
||||||
|
|
||||||
|
import androidx.annotation.Keep
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
data class AudioRankingResponse(
|
||||||
|
@SerializedName("showRankChange") val showRankChange: Boolean,
|
||||||
|
@SerializedName("type") val type: AudioRankingType,
|
||||||
|
@SerializedName("items") val items: List<AudioRankingItemResponse>
|
||||||
|
)
|
||||||
|
|
||||||
|
enum class AudioRankingType(
|
||||||
|
val queryValue: String,
|
||||||
|
val label: String
|
||||||
|
) {
|
||||||
|
WEEKLY_POPULAR("WEEKLY_POPULAR", "주간 인기"),
|
||||||
|
RISING("RISING", "지금 뜨는 중"),
|
||||||
|
REVENUE("REVENUE", "매출"),
|
||||||
|
SALES_COUNT("SALES_COUNT", "판매량"),
|
||||||
|
COMMENT_COUNT("COMMENT_COUNT", "댓글수"),
|
||||||
|
LIKE_COUNT("LIKE_COUNT", "좋아요")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
data class AudioRankingItemResponse(
|
||||||
|
@SerializedName("contentId") val contentId: Long,
|
||||||
|
@SerializedName("title") val title: String,
|
||||||
|
@SerializedName("creatorNickname") val creatorNickname: String,
|
||||||
|
@SerializedName("rank") val rank: Int,
|
||||||
|
@SerializedName("rankChange") val rankChange: Int?,
|
||||||
|
@SerializedName("isNew") val isNew: Boolean,
|
||||||
|
@SerializedName("coverImageUrl") val coverImageUrl: String?
|
||||||
|
)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.main.content.data
|
||||||
|
|
||||||
|
class AudioRankingsRepository(private val api: AudioRankingsApi) {
|
||||||
|
fun getRankings(token: String, type: AudioRankingType) = api.getRankings(
|
||||||
|
authHeader = token,
|
||||||
|
type = type
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.main.content
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.content.data.AudioRankingType
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class AudioRankingTypeTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `랭킹 타입은 PRD 순서를 유지한다`() {
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
AudioRankingType.WEEKLY_POPULAR,
|
||||||
|
AudioRankingType.RISING,
|
||||||
|
AudioRankingType.REVENUE,
|
||||||
|
AudioRankingType.SALES_COUNT,
|
||||||
|
AudioRankingType.COMMENT_COUNT,
|
||||||
|
AudioRankingType.LIKE_COUNT
|
||||||
|
),
|
||||||
|
AudioRankingType.entries
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `랭킹 타입 query value는 enum name을 사용한다`() {
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
"WEEKLY_POPULAR",
|
||||||
|
"RISING",
|
||||||
|
"REVENUE",
|
||||||
|
"SALES_COUNT",
|
||||||
|
"COMMENT_COUNT",
|
||||||
|
"LIKE_COUNT"
|
||||||
|
),
|
||||||
|
AudioRankingType.entries.map { it.queryValue }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `랭킹 타입 label은 PRD 순서를 유지한다`() {
|
||||||
|
assertEquals(
|
||||||
|
listOf("주간 인기", "지금 뜨는 중", "매출", "판매량", "댓글수", "좋아요"),
|
||||||
|
AudioRankingType.entries.map { it.label }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user