-
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.
[feat/#15] Repository 인터페이스의 구현체를 구현합니다.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/sopt/korailtalk/data/repositoryimpl/PaymentRepositoryImpl.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,27 @@ | ||
package com.sopt.korailtalk.data.repositoryimpl | ||
|
||
import com.sopt.korailtalk.data.mapper.todata.toData | ||
import com.sopt.korailtalk.data.mapper.todomain.toDomain | ||
import com.sopt.korailtalk.data.remote.datasource.PaymentRemoteDataSource | ||
import com.sopt.korailtalk.data.remote.util.handleApiResponse | ||
import com.sopt.korailtalk.domain.model.LPoint | ||
import com.sopt.korailtalk.domain.model.TicketBuying | ||
import com.sopt.korailtalk.domain.repository.PaymentRepository | ||
import javax.inject.Inject | ||
|
||
class PaymentRepositoryImpl @Inject constructor( | ||
private val paymentRemoteDataSource: PaymentRemoteDataSource | ||
) : PaymentRepository { | ||
override suspend fun getLpoint(userId: Long, pointPassword: Int): Result<LPoint> { | ||
return runCatching { | ||
paymentRemoteDataSource.getLpoint(userId = userId, pointPassword = pointPassword) | ||
.handleApiResponse().getOrThrow().toDomain() | ||
} | ||
} | ||
|
||
override suspend fun buyTicket(ticketBuying: TicketBuying): Result<Unit> { | ||
return runCatching { | ||
paymentRemoteDataSource.buyTicket(ticketBuyingRequestDto = ticketBuying.toData()) | ||
} | ||
} | ||
} |