Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#185] 유료결제뷰 대응 API 수정 #186

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Constants {
const val minSdk = 28
const val targetSdk = 34

const val versionCode = 20
const val versionCode = 21
const val versionName = "2.1.0"

const val jvmVersion = "17"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface CreateDataSource {

suspend fun postToVerify(request: KeyRequestDto): BaseResponse<Boolean>

suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>>
suspend fun getPromptExample(type: String): BaseResponse<List<PromptExampleDto>>

suspend fun postToValidatePurchase(request: PurchaseValidRequestDto): BaseResponse<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ constructor(
override suspend fun postToVerify(request: KeyRequestDto): BaseResponse<Boolean> =
createService.postToVerify(request)

override suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>> =
createService.getPromptExample()
override suspend fun getPromptExample(type: String): BaseResponse<List<PromptExampleDto>> =
createService.getPromptExample(type)

override suspend fun postToValidatePurchase(request: PurchaseValidRequestDto): BaseResponse<Boolean> =
createService.postToValidatePurchase(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ constructor(
createDataSource.postToVerify(request.toDto()).response
}

override suspend fun getPromptExample(): Result<List<PromptExampleModel>> =
override suspend fun getPromptExample(type: String): Result<List<PromptExampleModel>> =
runCatching {
createDataSource.getPromptExample().response.map { it.toModel() }
createDataSource.getPromptExample(type).response.map { it.toModel() }
}

override suspend fun postToValidatePurchase(request: PurchaseValidRequestModel): Result<Boolean> =
Expand Down
7 changes: 5 additions & 2 deletions data/src/main/java/kr/genti/data/service/CreateService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kr.genti.data.dto.response.S3PresignedUrlDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface CreateService {
@POST("api/v1/presigned-url")
Expand Down Expand Up @@ -43,8 +44,10 @@ interface CreateService {
@Body request: KeyRequestDto,
): BaseResponse<Boolean>

@GET("api/v1/users/examples/with-picture-square")
suspend fun getPromptExample(): BaseResponse<List<PromptExampleDto>>
@GET("api/v1/users/examples/with-picture-square/{type}")
suspend fun getPromptExample(
@Path("type") type: String
): BaseResponse<List<PromptExampleDto>>

@POST("api/v1/users/in-app-purchases/google/receipt-validation")
suspend fun postToValidatePurchase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface CreateRepository {

suspend fun postToVerify(request: KeyRequestModel): Result<Boolean>

suspend fun getPromptExample(): Result<List<PromptExampleModel>>
suspend fun getPromptExample(type: String): Result<List<PromptExampleModel>>

suspend fun postToValidatePurchase(request: PurchaseValidRequestModel): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ constructor(
private var firstImageS3KeyList = listOf<KeyRequestModel>()
private var secondImageS3KeyList = listOf<KeyRequestModel>()

init {
// getExamplePrompt()
}

fun modCurrentPercent(amount: Int) {
_currentPercent.value += amount
}
Expand Down Expand Up @@ -116,11 +112,16 @@ constructor(
_totalGeneratingState.value = UiState.Empty
}

private fun getExamplePrompt() {
fun getExamplePrompt() {
_getExampleState.value = UiState.Loading
val currentType = when {
!isCreatingParentPic -> TYPE_FREE_ONE
selectedNumber.value == PictureNumber.ONE -> TYPE_PAID_ONE
else -> TYPE_PAID_TWO
}
viewModelScope.launch {
runCatching {
createRepository.getPromptExample()
createRepository.getPromptExample(currentType)
}.onSuccess {
_getExampleState.value = UiState.Success(it.getOrThrow())
}.onFailure {
Expand Down Expand Up @@ -265,5 +266,9 @@ constructor(
companion object {
const val VALIDATION_FALSE = "VALIDATION_FALSE"
const val SERVER_ERROR = "SERVER_ERROR"

const val TYPE_FREE_ONE = "FREE_ONE"
const val TYPE_PAID_ONE = "PAID_ONE"
const val TYPE_PAID_TWO = "PAID_TWO"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DefineFragment() : BaseFragment<FragmentDefineBinding>(R.layout.fragment_d

private fun initView() {
binding.vm = viewModel
viewModel.getExamplePrompt()
}

private fun initCreateBtnListener() {
Expand Down Expand Up @@ -118,19 +119,17 @@ class DefineFragment() : BaseFragment<FragmentDefineBinding>(R.layout.fragment_d
}

private fun observeGetExampleState() {
viewModel.getExampleState
.flowWithLifecycle(lifecycle)
.onEach { state ->
when (state) {
is UiState.Success -> {
adapter.submitList(state.data)
binding.dotIndicator.setViewPager(binding.vpCreateRandom)
}

is UiState.Failure -> toast(stringOf(R.string.error_msg))
else -> return@onEach
viewModel.getExampleState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
is UiState.Success -> {
adapter.submitList(state.data)
binding.dotIndicator.setViewPager(binding.vpCreateRandom)
}
}.launchIn(lifecycleScope)

is UiState.Failure -> toast(stringOf(R.string.error_msg))
else -> return@onEach
}
}.launchIn(lifecycleScope)
}

}
2 changes: 1 addition & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
<string name="profile_tv_list_title">내가 만든 사진</string>
<string name="profile_tv_empty">아직 내가 만든 사진이 없어요.</string>
<string name="profile_tv_empty_guide">세상에 하나뿐인 나만의 사진을 만들어보세요!</string>
<string name="profile_image_download_success">사진이 저장되었어요\n친구들에게 공유해보세요!</string>
<string name="profile_image_download_success">사진이 저장되었어요</string>

<string name="setting_tv_title">설정</string>
<string name="setting_btn_terms_of_service">이용 약관</string>
Expand Down