89 lines
2.3 KiB
Kotlin
89 lines
2.3 KiB
Kotlin
package chats.data.remote.api
|
|
|
|
import chats.data.remote.dto.ChatDto
|
|
import chats.data.remote.dto.MessageDto
|
|
import retrofit2.http.*
|
|
|
|
data class SendMessageRequest(
|
|
val content: String?,
|
|
val type: String = "text",
|
|
val attachments: List<AttachmentRequest>? = null,
|
|
val replyToId: String? = null,
|
|
val quote: String? = null
|
|
)
|
|
|
|
data class AttachmentRequest(
|
|
val type: String,
|
|
val url: String,
|
|
val fileName: String,
|
|
val fileSize: Long
|
|
)
|
|
|
|
interface ChatApi {
|
|
@GET("chats")
|
|
suspend fun getChats(): List<ChatDto>
|
|
|
|
@GET("messages/chat/{chatId}")
|
|
suspend fun getMessages(
|
|
@Path("chatId") chatId: String,
|
|
@Query("cursor") cursor: String? = null,
|
|
@Query("limit") limit: Int? = 50
|
|
): List<MessageDto>
|
|
|
|
@POST("messages/chat/{chatId}")
|
|
suspend fun sendMessage(@Path("chatId") chatId: String, @Body request: SendMessageRequest): MessageDto
|
|
|
|
@Multipart
|
|
@POST("messages/upload")
|
|
suspend fun uploadFile(@Part file: okhttp3.MultipartBody.Part): FileUploadResponse
|
|
|
|
// Klipy GIF API
|
|
@GET("klipy/trending")
|
|
suspend fun getTrendingGifs(@Query("page") page: Int): List<KlipyGifDto>
|
|
|
|
@GET("klipy/search")
|
|
suspend fun searchGifs(@Query("q") query: String, @Query("page") page: Int): List<KlipyGifDto>
|
|
|
|
@GET("klipy/categories")
|
|
suspend fun getGifCategories(): List<GifCategoryDto>
|
|
|
|
@POST("klipy/shared/{id}")
|
|
suspend fun markGifShared(@Path("id") id: String, @Body query: String)
|
|
|
|
@POST("messages/{messageId}/reactions")
|
|
suspend fun addReaction(@Path("messageId") messageId: String, @Body emoji: String)
|
|
|
|
@POST("chats/{chatId}/typing")
|
|
suspend fun sendTypingStatus(@Path("chatId") chatId: String)
|
|
|
|
@POST("chats/{chatId}/read")
|
|
suspend fun markMessagesAsRead(@Path("chatId") chatId: String, @Body lastMessageId: String)
|
|
}
|
|
|
|
data class KlipyGifDto(
|
|
val id: String,
|
|
val images: GifImagesDto?,
|
|
val title: String?
|
|
)
|
|
|
|
data class GifImagesDto(
|
|
val fixed_height: GifImageSourceDto?,
|
|
val original: GifImageSourceDto?
|
|
)
|
|
|
|
data class GifImageSourceDto(
|
|
val url: String
|
|
)
|
|
|
|
data class GifCategoryDto(
|
|
val category: String,
|
|
val preview_url: String,
|
|
val query: String
|
|
)
|
|
|
|
data class FileUploadResponse(
|
|
val url: String,
|
|
val filename: String,
|
|
val size: Long
|
|
)
|