-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from Nexters/feature/254
Feature/254 선물하기 flow
- Loading branch information
Showing
40 changed files
with
1,862 additions
and
132 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/nexters/boolti/data/datasource/GiftDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.nexters.boolti.data.datasource | ||
|
||
import com.nexters.boolti.data.network.api.GiftService | ||
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.GiftApproveRequest | ||
import javax.inject.Inject | ||
|
||
internal class GiftDataSource @Inject constructor( | ||
private val service: GiftService | ||
) { | ||
suspend fun receiveGift(request: GiftReceiveRequest): Boolean = service.receiveGift(request) | ||
|
||
suspend fun approveGiftPayment(request: GiftApproveRequest): ApproveGiftPaymentResponse = | ||
service.approveGiftPayment(request) | ||
|
||
suspend fun getGift(giftId: String): GiftResponse = service.getGift(giftId) | ||
|
||
suspend fun getGiftImages(): List<ImageResponse> = service.getGiftImages() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
data/src/main/java/com/nexters/boolti/data/network/api/GiftService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.nexters.boolti.data.network.api | ||
|
||
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.GiftApproveRequest | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
internal interface GiftService { | ||
@POST("/app/api/v1/order/receive-gift") | ||
suspend fun receiveGift(@Body request: GiftReceiveRequest): Boolean | ||
|
||
@POST("/app/api/v1/order/gift-approve-payment") | ||
suspend fun approveGiftPayment(@Body request: GiftApproveRequest): ApproveGiftPaymentResponse | ||
|
||
@GET("/app/api/v1/gift/{giftId}") | ||
suspend fun getGift(@Path("giftId") giftId: String): GiftResponse | ||
|
||
@GET("/app/api/v1/gift/img-list") | ||
suspend fun getGiftImages(): List<ImageResponse> | ||
} |
5 changes: 5 additions & 0 deletions
5
data/src/main/java/com/nexters/boolti/data/network/request/GiftReceiveRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.nexters.boolti.data.network.request | ||
|
||
data class GiftReceiveRequest( | ||
val giftId: String, | ||
) |
19 changes: 19 additions & 0 deletions
19
data/src/main/java/com/nexters/boolti/data/network/response/ApproveGiftPaymentResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.nexters.boolti.data.network.response | ||
|
||
import com.nexters.boolti.domain.model.ApproveGiftPayment | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ApproveGiftPaymentResponse( | ||
val orderId: String, | ||
val reservationId: String, | ||
val giftId: String, | ||
) { | ||
fun toDomain(): ApproveGiftPayment { | ||
return ApproveGiftPayment( | ||
orderId = orderId, | ||
reservationId = reservationId, | ||
giftId = giftId | ||
) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
data/src/main/java/com/nexters/boolti/data/network/response/GiftResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.nexters.boolti.data.network.response | ||
|
||
import com.nexters.boolti.domain.model.Gift | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class GiftResponse( | ||
val id: String, | ||
val orderId: String, | ||
val reservationId: String, | ||
val giftImgId: String, | ||
val message: String, | ||
val senderName: String, | ||
val senderPhoneNumber: String, | ||
val recipientName: String, | ||
val recipientPhoneNumber: String, | ||
val isDone: Boolean, | ||
) { | ||
fun toDomain(): Gift { | ||
return Gift( | ||
id = id, | ||
orderId = orderId, | ||
reservationId = reservationId, | ||
giftImgId = giftImgId, | ||
message = message, | ||
senderName = senderName, | ||
senderPhoneNumber = senderPhoneNumber, | ||
recipientName = recipientName, | ||
recipientPhoneNumber = recipientPhoneNumber, | ||
isDone = isDone, | ||
) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
data/src/main/java/com/nexters/boolti/data/repository/GiftRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.nexters.boolti.data.repository | ||
|
||
import com.nexters.boolti.data.datasource.GiftDataSource | ||
import com.nexters.boolti.data.network.request.GiftReceiveRequest | ||
import com.nexters.boolti.data.network.response.toDomains | ||
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.GiftApproveRequest | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
internal class GiftRepositoryImpl @Inject constructor( | ||
private val dataSource: GiftDataSource | ||
) : GiftRepository { | ||
override fun receiveGift(giftId: String): Flow<Boolean> = flow { | ||
emit(dataSource.receiveGift(GiftReceiveRequest(giftId))) | ||
} | ||
|
||
override fun approveGiftPayment(request: GiftApproveRequest): Flow<ApproveGiftPayment> = flow { | ||
emit(dataSource.approveGiftPayment(request).toDomain()) | ||
} | ||
|
||
override fun getGift(giftId: String): Flow<Gift> = flow { | ||
emit(dataSource.getGift(giftId).toDomain()) | ||
} | ||
|
||
override fun getGiftImages(): Flow<List<ImagePair>> = flow { | ||
emit(dataSource.getGiftImages().toDomains()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/nexters/boolti/domain/model/ApproveGiftPayment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.nexters.boolti.domain.model | ||
|
||
data class ApproveGiftPayment( | ||
val orderId: String, | ||
val reservationId: String, | ||
val giftId: String, | ||
) |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/nexters/boolti/domain/model/Gift.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.nexters.boolti.domain.model | ||
|
||
data class Gift( | ||
val id: String, | ||
val orderId: String, | ||
val reservationId: String, | ||
val giftImgId: String, | ||
val message: String, | ||
val senderName: String, | ||
val senderPhoneNumber: String, | ||
val recipientName: String, | ||
val recipientPhoneNumber: String, | ||
val isDone: Boolean, | ||
) |
17 changes: 17 additions & 0 deletions
17
domain/src/main/java/com/nexters/boolti/domain/repository/GiftRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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.GiftApproveRequest | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface GiftRepository { | ||
fun receiveGift(giftId: String): Flow<Boolean> | ||
|
||
fun approveGiftPayment(request: GiftApproveRequest): Flow<ApproveGiftPayment> | ||
|
||
fun getGift(giftId: String): Flow<Gift> | ||
|
||
fun getGiftImages(): Flow<List<ImagePair>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
domain/src/main/java/com/nexters/boolti/domain/request/GiftApproveRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.nexters.boolti.domain.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class GiftApproveRequest( | ||
val orderId: String, | ||
val amount: Int, | ||
val paymentKey: String, | ||
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.