Skip to content

Commit

Permalink
[feat/#15] Repository 인터페이스의 구현체를 구현합니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
SYAAINN committed Nov 28, 2024
1 parent 90965c6 commit f71d242
Showing 1 changed file with 27 additions and 0 deletions.
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())
}
}
}

0 comments on commit f71d242

Please sign in to comment.