feat(gift): 선물함 API 계약을 추가한다

This commit is contained in:
2026-10-01 21:16:49 +09:00
parent 1211a1d6a1
commit 352f385dd6
4 changed files with 48 additions and 0 deletions
@@ -6,8 +6,17 @@ import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Query
interface GiftApi {
@GET("/api/v2/gifts")
fun getGiftInbox(
@Query("type") type: String,
@Query("page") page: Int,
@Query("size") size: Int,
@Header("Authorization") authHeader: String
): Single<ApiResponse<GiftInboxResponse>>
@GET("/api/v2/gifts/form-options")
fun getFormOptions(
@Header("Authorization") authHeader: String
@@ -3,6 +3,30 @@ package kr.co.vividnext.sodalive.v2.gift.data
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
@Keep
data class GiftInboxResponse(
@SerializedName("totalCount") val totalCount: Int,
@SerializedName("items") val items: List<GiftInboxItemResponse>,
@SerializedName("page") val page: Int,
@SerializedName("size") val size: Int,
@SerializedName("hasNext") val hasNext: Boolean
)
@Keep
data class GiftInboxItemResponse(
@SerializedName("applicationNo") val applicationNo: String,
@SerializedName("direction") val direction: String,
@SerializedName("status") val status: String,
@SerializedName("statusName") val statusName: String,
@SerializedName("priceCan") val priceCan: Int,
@SerializedName("categoryName") val categoryName: String,
@SerializedName("sizeName") val sizeName: String,
@SerializedName("createdAt") val createdAt: String?,
@SerializedName("counterpartMemberId") val counterpartMemberId: Long,
@SerializedName("counterpartNickname") val counterpartNickname: String,
@SerializedName("counterpartProfileImageUrl") val counterpartProfileImageUrl: String?
)
@Keep
data class GiftFormOptionsResponse(
@SerializedName("sizes") val sizes: List<GiftSizeResponse>,
@@ -1,6 +1,13 @@
package kr.co.vividnext.sodalive.v2.gift.data
class GiftRepository(private val api: GiftApi) {
fun getGiftInbox(page: Int, token: String) = api.getGiftInbox(
type = "ALL",
page = page,
size = 20,
authHeader = token
)
fun getFormOptions(token: String) = api.getFormOptions(authHeader = token)
fun createGift(request: GiftCreateRequest, token: String) = api.createGift(
@@ -163,6 +163,14 @@ class GiftSendRequestViewModelTest {
}
private class FakeGiftApi : GiftApi {
override fun getGiftInbox(
type: String,
page: Int,
size: Int,
authHeader: String
): Single<ApiResponse<kr.co.vividnext.sodalive.v2.gift.data.GiftInboxResponse>> =
Single.error(UnsupportedOperationException())
private val formOptionsResponses = ArrayDeque<Single<ApiResponse<GiftFormOptionsResponse>>>()
private val createGiftResponses = ArrayDeque<Single<ApiResponse<Any>>>()
var lastAuthHeader: String? = null