fix(chat-room): 채팅방

- 쿼터 상태 조회, 쿼터 구매 API URL 변경
This commit is contained in:
2025-09-10 12:03:49 +09:00
parent 65791c55ca
commit 9ed3c046b3
3 changed files with 19 additions and 10 deletions

View File

@@ -75,15 +75,17 @@ interface TalkApi {
): Single<ApiResponse<ServerChatMessage>>
// 채팅 쿼터 상태 조회
@GET("/api/chat/quota/me")
@GET("/api/chat/rooms/{roomId}/quota/me")
fun getChatQuotaStatus(
@Path("roomId") roomId: Long,
@Header("Authorization") authHeader: String
): Single<ApiResponse<ChatQuotaStatusResponse>>
// 채팅 쿼터 구매
@POST("/api/chat/quota/purchase")
@POST("/api/chat/rooms/{roomId}/quota/purchase")
fun purchaseChatQuota(
@Header("Authorization") authHeader: String,
@Body request: ChatQuotaPurchaseRequest
@Path("roomId") roomId: Long,
@Body request: ChatQuotaPurchaseRequest,
@Header("Authorization") authHeader: String
): Single<ApiResponse<ChatQuotaStatusResponse>>
}

View File

@@ -63,15 +63,22 @@ class ChatRepository(
}
/** 쿼터 상태 조회 */
fun getChatQuotaStatus(token: String): Single<ChatQuotaStatusResponse> {
return talkApi.getChatQuotaStatus(authHeader = token)
fun getChatQuotaStatus(roomId: Long, token: String): Single<ChatQuotaStatusResponse> {
return talkApi.getChatQuotaStatus(
roomId = roomId,
authHeader = token
)
.subscribeOn(Schedulers.io())
.map { ensureSuccess(it) }
}
/** 쿼터 구매 */
fun purchaseChatQuota(token: String): Single<ChatQuotaStatusResponse> {
return talkApi.purchaseChatQuota(authHeader = token, request = ChatQuotaPurchaseRequest())
fun purchaseChatQuota(roomId: Long, token: String): Single<ChatQuotaStatusResponse> {
return talkApi.purchaseChatQuota(
roomId = roomId,
request = ChatQuotaPurchaseRequest(),
authHeader = token
)
.subscribeOn(Schedulers.io())
.map { ensureSuccess(it) }
}

View File

@@ -462,7 +462,7 @@ class ChatRoomActivity : BaseActivity<ActivityChatRoomBinding>(
private fun onPurchaseQuotaClicked() {
val token = "Bearer ${SharedPreferenceManager.token}"
compositeDisposable.add(
chatRepository.purchaseChatQuota(token)
chatRepository.purchaseChatQuota(roomId, token)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
// 쿼터 UI 갱신
@@ -548,7 +548,7 @@ class ChatRoomActivity : BaseActivity<ActivityChatRoomBinding>(
private fun checkQuotaStatus() {
val token = "Bearer ${SharedPreferenceManager.token}"
compositeDisposable.add(
chatRepository.getChatQuotaStatus(token)
chatRepository.getChatQuotaStatus(roomId, token)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
updateQuotaUi(resp.totalRemaining, resp.nextRechargeAtEpoch)