新增聊天消息提醒
This commit is contained in:
42
app/src/main/java/com/aiosman/riderpro/data/ChatService.kt
Normal file
42
app/src/main/java/com/aiosman/riderpro/data/ChatService.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.aiosman.riderpro.data
|
||||
|
||||
import com.aiosman.riderpro.data.api.ApiClient
|
||||
import com.aiosman.riderpro.data.api.UpdateChatNotificationRequestBody
|
||||
import com.aiosman.riderpro.entity.ChatNotification
|
||||
|
||||
interface ChatService {
|
||||
suspend fun getChatNotifications(
|
||||
targetTrtcId: String
|
||||
): ChatNotification?
|
||||
|
||||
suspend fun updateChatNotification(
|
||||
targetUserId: Int,
|
||||
strategy: String
|
||||
): ChatNotification
|
||||
}
|
||||
|
||||
class ChatServiceImpl : ChatService {
|
||||
override suspend fun getChatNotifications(
|
||||
targetTrtcId: String
|
||||
): ChatNotification? {
|
||||
val resp = ApiClient.api.getChatNotification(targetTrtcId)
|
||||
if (resp.isSuccessful) {
|
||||
return resp.body()?.data
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override suspend fun updateChatNotification(
|
||||
targetUserId: Int,
|
||||
strategy: String
|
||||
): ChatNotification {
|
||||
val resp = ApiClient.api.updateChatNotification(UpdateChatNotificationRequestBody(
|
||||
targetUserId = targetUserId,
|
||||
strategy = strategy
|
||||
))
|
||||
if (resp.isSuccessful) {
|
||||
return resp.body()?.data!!
|
||||
}
|
||||
throw Exception("update chat notification failed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user