From 4d6e190ed888b6488b90d6a4221818fc48a6ef5d Mon Sep 17 00:00:00 2001 From: algosketch Date: Wed, 24 Jul 2024 22:33:57 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EB=AC=B4=EB=A3=8C=20=EC=84=A0?= =?UTF-8?q?=EB=AC=BC=EC=9D=84=20=EC=9C=84=ED=95=9C=20api=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boolti/data/datasource/GiftDataSource.kt | 4 ++++ .../boolti/data/network/api/GiftService.kt | 4 ++++ .../data/repository/GiftRepositoryImpl.kt | 5 +++++ .../boolti/domain/repository/GiftRepository.kt | 4 ++++ .../boolti/domain/request/FreeGiftRequest.kt | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 domain/src/main/java/com/nexters/boolti/domain/request/FreeGiftRequest.kt diff --git a/data/src/main/java/com/nexters/boolti/data/datasource/GiftDataSource.kt b/data/src/main/java/com/nexters/boolti/data/datasource/GiftDataSource.kt index bd08713b..0f1977cf 100644 --- a/data/src/main/java/com/nexters/boolti/data/datasource/GiftDataSource.kt +++ b/data/src/main/java/com/nexters/boolti/data/datasource/GiftDataSource.kt @@ -5,6 +5,7 @@ import com.nexters.boolti.data.network.request.GiftReceiveRequest import com.nexters.boolti.data.network.response.ApproveGiftPaymentResponse import com.nexters.boolti.data.network.response.GiftResponse import com.nexters.boolti.data.network.response.ImageResponse +import com.nexters.boolti.domain.request.FreeGiftRequest import com.nexters.boolti.domain.request.GiftApproveRequest import javax.inject.Inject @@ -16,6 +17,9 @@ internal class GiftDataSource @Inject constructor( suspend fun approveGiftPayment(request: GiftApproveRequest): ApproveGiftPaymentResponse = service.approveGiftPayment(request) + suspend fun createFreeGift(request: FreeGiftRequest): ApproveGiftPaymentResponse = + service.createFreeGift(request) + suspend fun getGift(giftUuid: String): GiftResponse = service.getGift(giftUuid) suspend fun getGiftImages(): List = service.getGiftImages() diff --git a/data/src/main/java/com/nexters/boolti/data/network/api/GiftService.kt b/data/src/main/java/com/nexters/boolti/data/network/api/GiftService.kt index 8eaa5a0f..243306ce 100644 --- a/data/src/main/java/com/nexters/boolti/data/network/api/GiftService.kt +++ b/data/src/main/java/com/nexters/boolti/data/network/api/GiftService.kt @@ -4,6 +4,7 @@ import com.nexters.boolti.data.network.request.GiftReceiveRequest import com.nexters.boolti.data.network.response.ApproveGiftPaymentResponse import com.nexters.boolti.data.network.response.GiftResponse import com.nexters.boolti.data.network.response.ImageResponse +import com.nexters.boolti.domain.request.FreeGiftRequest import com.nexters.boolti.domain.request.GiftApproveRequest import retrofit2.http.Body import retrofit2.http.GET @@ -17,6 +18,9 @@ internal interface GiftService { @POST("/app/api/v1/order/gift-approve-payment") suspend fun approveGiftPayment(@Body request: GiftApproveRequest): ApproveGiftPaymentResponse + @POST + suspend fun createFreeGift(@Body request: FreeGiftRequest): ApproveGiftPaymentResponse + @GET("/app/api/v1/gift/{giftUuid}") suspend fun getGift(@Path("giftUuid") giftUuid: String): GiftResponse diff --git a/data/src/main/java/com/nexters/boolti/data/repository/GiftRepositoryImpl.kt b/data/src/main/java/com/nexters/boolti/data/repository/GiftRepositoryImpl.kt index 4faa3ca5..561eec20 100644 --- a/data/src/main/java/com/nexters/boolti/data/repository/GiftRepositoryImpl.kt +++ b/data/src/main/java/com/nexters/boolti/data/repository/GiftRepositoryImpl.kt @@ -7,6 +7,7 @@ import com.nexters.boolti.domain.model.ApproveGiftPayment import com.nexters.boolti.domain.model.Gift import com.nexters.boolti.domain.model.ImagePair import com.nexters.boolti.domain.repository.GiftRepository +import com.nexters.boolti.domain.request.FreeGiftRequest import com.nexters.boolti.domain.request.GiftApproveRequest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -23,6 +24,10 @@ internal class GiftRepositoryImpl @Inject constructor( emit(dataSource.approveGiftPayment(request).toDomain()) } + override fun sendFreeGift(request: FreeGiftRequest): Flow = flow { + emit(dataSource.createFreeGift(request).toDomain()) + } + override fun getGift(giftUuid: String): Flow = flow { emit(dataSource.getGift(giftUuid).toDomain()) } diff --git a/domain/src/main/java/com/nexters/boolti/domain/repository/GiftRepository.kt b/domain/src/main/java/com/nexters/boolti/domain/repository/GiftRepository.kt index e860bcfd..28187e26 100644 --- a/domain/src/main/java/com/nexters/boolti/domain/repository/GiftRepository.kt +++ b/domain/src/main/java/com/nexters/boolti/domain/repository/GiftRepository.kt @@ -3,14 +3,18 @@ package com.nexters.boolti.domain.repository import com.nexters.boolti.domain.model.ApproveGiftPayment import com.nexters.boolti.domain.model.Gift import com.nexters.boolti.domain.model.ImagePair +import com.nexters.boolti.domain.request.FreeGiftRequest import com.nexters.boolti.domain.request.GiftApproveRequest import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow interface GiftRepository { fun receiveGift(giftUuid: String): Flow fun approveGiftPayment(request: GiftApproveRequest): Flow + fun sendFreeGift(request: FreeGiftRequest): Flow + fun getGift(giftUuid: String): Flow fun getGiftImages(): Flow> diff --git a/domain/src/main/java/com/nexters/boolti/domain/request/FreeGiftRequest.kt b/domain/src/main/java/com/nexters/boolti/domain/request/FreeGiftRequest.kt new file mode 100644 index 00000000..f110b245 --- /dev/null +++ b/domain/src/main/java/com/nexters/boolti/domain/request/FreeGiftRequest.kt @@ -0,0 +1,18 @@ +package com.nexters.boolti.domain.request + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class FreeGiftRequest( + val amount: Int, + val showId: String, + val salesTicketTypeId: String, + val ticketCount: Int, + @SerialName("giftImgId") val giftImageId: String, + val message: String, + val senderName: String, + val senderPhoneNumber: String, + val recipientName: String, + val recipientPhoneNumber: String, +) \ No newline at end of file