fix(chat-room): 채팅방
- 쿼터 상태 조회, 쿼터 구매 API URL 변경
This commit is contained in:
@@ -75,15 +75,17 @@ interface TalkApi {
|
|||||||
): Single<ApiResponse<ServerChatMessage>>
|
): Single<ApiResponse<ServerChatMessage>>
|
||||||
|
|
||||||
// 채팅 쿼터 상태 조회
|
// 채팅 쿼터 상태 조회
|
||||||
@GET("/api/chat/quota/me")
|
@GET("/api/chat/rooms/{roomId}/quota/me")
|
||||||
fun getChatQuotaStatus(
|
fun getChatQuotaStatus(
|
||||||
|
@Path("roomId") roomId: Long,
|
||||||
@Header("Authorization") authHeader: String
|
@Header("Authorization") authHeader: String
|
||||||
): Single<ApiResponse<ChatQuotaStatusResponse>>
|
): Single<ApiResponse<ChatQuotaStatusResponse>>
|
||||||
|
|
||||||
// 채팅 쿼터 구매
|
// 채팅 쿼터 구매
|
||||||
@POST("/api/chat/quota/purchase")
|
@POST("/api/chat/rooms/{roomId}/quota/purchase")
|
||||||
fun purchaseChatQuota(
|
fun purchaseChatQuota(
|
||||||
@Header("Authorization") authHeader: String,
|
@Path("roomId") roomId: Long,
|
||||||
@Body request: ChatQuotaPurchaseRequest
|
@Body request: ChatQuotaPurchaseRequest,
|
||||||
|
@Header("Authorization") authHeader: String
|
||||||
): Single<ApiResponse<ChatQuotaStatusResponse>>
|
): Single<ApiResponse<ChatQuotaStatusResponse>>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,15 +63,22 @@ class ChatRepository(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 쿼터 상태 조회 */
|
/** 쿼터 상태 조회 */
|
||||||
fun getChatQuotaStatus(token: String): Single<ChatQuotaStatusResponse> {
|
fun getChatQuotaStatus(roomId: Long, token: String): Single<ChatQuotaStatusResponse> {
|
||||||
return talkApi.getChatQuotaStatus(authHeader = token)
|
return talkApi.getChatQuotaStatus(
|
||||||
|
roomId = roomId,
|
||||||
|
authHeader = token
|
||||||
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.map { ensureSuccess(it) }
|
.map { ensureSuccess(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 쿼터 구매 */
|
/** 쿼터 구매 */
|
||||||
fun purchaseChatQuota(token: String): Single<ChatQuotaStatusResponse> {
|
fun purchaseChatQuota(roomId: Long, token: String): Single<ChatQuotaStatusResponse> {
|
||||||
return talkApi.purchaseChatQuota(authHeader = token, request = ChatQuotaPurchaseRequest())
|
return talkApi.purchaseChatQuota(
|
||||||
|
roomId = roomId,
|
||||||
|
request = ChatQuotaPurchaseRequest(),
|
||||||
|
authHeader = token
|
||||||
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.map { ensureSuccess(it) }
|
.map { ensureSuccess(it) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ class ChatRoomActivity : BaseActivity<ActivityChatRoomBinding>(
|
|||||||
private fun onPurchaseQuotaClicked() {
|
private fun onPurchaseQuotaClicked() {
|
||||||
val token = "Bearer ${SharedPreferenceManager.token}"
|
val token = "Bearer ${SharedPreferenceManager.token}"
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
chatRepository.purchaseChatQuota(token)
|
chatRepository.purchaseChatQuota(roomId, token)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ resp ->
|
.subscribe({ resp ->
|
||||||
// 쿼터 UI 갱신
|
// 쿼터 UI 갱신
|
||||||
@@ -548,7 +548,7 @@ class ChatRoomActivity : BaseActivity<ActivityChatRoomBinding>(
|
|||||||
private fun checkQuotaStatus() {
|
private fun checkQuotaStatus() {
|
||||||
val token = "Bearer ${SharedPreferenceManager.token}"
|
val token = "Bearer ${SharedPreferenceManager.token}"
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
chatRepository.getChatQuotaStatus(token)
|
chatRepository.getChatQuotaStatus(roomId, token)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ resp ->
|
.subscribe({ resp ->
|
||||||
updateQuotaUi(resp.totalRemaining, resp.nextRechargeAtEpoch)
|
updateQuotaUi(resp.totalRemaining, resp.nextRechargeAtEpoch)
|
||||||
|
|||||||
Reference in New Issue
Block a user