feat(chat-quota): 쿼터 구매 계약과 광고 ad unit 구성을 추가한다
This commit is contained in:
@@ -13,6 +13,8 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.chat.talk.TalkApi
|
||||
import kr.co.vividnext.sodalive.chat.talk.room.db.ChatMessageDao
|
||||
import kr.co.vividnext.sodalive.chat.talk.room.quota.ChatQuotaPurchaseRequest
|
||||
import kr.co.vividnext.sodalive.chat.talk.room.quota.ChatRoomQuotaCanOption
|
||||
import kr.co.vividnext.sodalive.chat.talk.room.quota.ChatRoomQuotaChargeType
|
||||
import kr.co.vividnext.sodalive.chat.talk.room.quota.ChatQuotaStatusResponse
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import java.util.concurrent.Callable
|
||||
@@ -73,10 +75,18 @@ class ChatRepository(
|
||||
}
|
||||
|
||||
/** 쿼터 구매 */
|
||||
fun purchaseChatQuota(roomId: Long, token: String): Single<ChatQuotaStatusResponse> {
|
||||
fun purchaseChatQuota(
|
||||
roomId: Long,
|
||||
token: String,
|
||||
chargeType: ChatRoomQuotaChargeType,
|
||||
canOption: ChatRoomQuotaCanOption? = null
|
||||
): Single<ChatQuotaStatusResponse> {
|
||||
return talkApi.purchaseChatQuota(
|
||||
roomId = roomId,
|
||||
request = ChatQuotaPurchaseRequest(),
|
||||
request = ChatQuotaPurchaseRequest(
|
||||
chargeType = chargeType,
|
||||
canOption = canOption
|
||||
),
|
||||
authHeader = token
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -87,12 +97,14 @@ class ChatRepository(
|
||||
* 로컬에서 최근 20개 메시지 조회
|
||||
*/
|
||||
fun getRecentMessagesFromLocal(roomId: Long): Single<List<ChatMessage>> {
|
||||
return Single.fromCallable(Callable {
|
||||
runCatching {
|
||||
val entities = kotlinx.coroutines.runBlocking { chatDao.getRecentMessages(roomId) }
|
||||
entities.map { it.toDomain() }
|
||||
}.getOrDefault(emptyList())
|
||||
}).subscribeOn(Schedulers.io())
|
||||
return Single.fromCallable(
|
||||
Callable {
|
||||
runCatching {
|
||||
val entities = kotlinx.coroutines.runBlocking { chatDao.getRecentMessages(roomId) }
|
||||
entities.map { it.toDomain() }
|
||||
}.getOrDefault(emptyList())
|
||||
}
|
||||
).subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,5 +5,22 @@ import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class ChatQuotaPurchaseRequest(
|
||||
@SerializedName("container") val container: String = "aos"
|
||||
@SerializedName("container") val container: String = "aos",
|
||||
@SerializedName("chargeType") val chargeType: ChatRoomQuotaChargeType,
|
||||
@SerializedName("canOption") val canOption: ChatRoomQuotaCanOption? = null
|
||||
)
|
||||
|
||||
@Keep
|
||||
enum class ChatRoomQuotaChargeType {
|
||||
CAN,
|
||||
AD
|
||||
}
|
||||
|
||||
@Keep
|
||||
enum class ChatRoomQuotaCanOption(
|
||||
val needCan: Int,
|
||||
val quota: Int
|
||||
) {
|
||||
CAN_10(10, 15),
|
||||
CAN_20(20, 40)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user