Гиф
This commit is contained in:
@@ -39,13 +39,13 @@ interface ChatApi {
|
||||
|
||||
// Klipy GIF API
|
||||
@GET("klipy/trending")
|
||||
suspend fun getTrendingGifs(@Query("page") page: Int): List<KlipyGifDto>
|
||||
suspend fun getTrendingGifs(@Query("page") page: Int): KlipyResponse
|
||||
|
||||
@GET("klipy/search")
|
||||
suspend fun searchGifs(@Query("q") query: String, @Query("page") page: Int): List<KlipyGifDto>
|
||||
suspend fun searchGifs(@Query("q") query: String, @Query("page") page: Int): KlipyResponse
|
||||
|
||||
@GET("klipy/categories")
|
||||
suspend fun getGifCategories(): List<GifCategoryDto>
|
||||
suspend fun getGifCategories(): GifCategoriesResponse
|
||||
|
||||
@POST("klipy/shared/{id}")
|
||||
suspend fun markGifShared(@Path("id") id: String, @Body query: String)
|
||||
@@ -60,15 +60,27 @@ interface ChatApi {
|
||||
suspend fun markMessagesAsRead(@Path("chatId") chatId: String, @Body lastMessageId: String)
|
||||
}
|
||||
|
||||
data class KlipyResponse(
|
||||
val data: KlipyDataWrapper
|
||||
)
|
||||
|
||||
data class KlipyDataWrapper(
|
||||
val data: List<KlipyGifDto>
|
||||
)
|
||||
|
||||
data class KlipyGifDto(
|
||||
val id: String,
|
||||
val images: GifImagesDto?,
|
||||
val title: String?
|
||||
val images: GifImagesDto? = null,
|
||||
val files: Map<String, Map<String, GifImageSourceDto>>? = null,
|
||||
val file: Map<String, Map<String, GifImageSourceDto>>? = null,
|
||||
val media_formats: Map<String, GifImageSourceDto>? = null,
|
||||
val title: String? = null
|
||||
)
|
||||
|
||||
data class GifImagesDto(
|
||||
val fixed_height: GifImageSourceDto?,
|
||||
val original: GifImageSourceDto?
|
||||
val fixed_height: GifImageSourceDto? = null,
|
||||
val original: GifImageSourceDto? = null,
|
||||
val fixed_height_small: GifImageSourceDto? = null
|
||||
)
|
||||
|
||||
data class GifImageSourceDto(
|
||||
@@ -86,3 +98,11 @@ data class FileUploadResponse(
|
||||
val filename: String,
|
||||
val size: Long
|
||||
)
|
||||
|
||||
data class GifCategoriesResponse(
|
||||
val data: GifCategoriesData
|
||||
)
|
||||
|
||||
data class GifCategoriesData(
|
||||
val categories: List<GifCategoryDto>
|
||||
)
|
||||
|
||||
@@ -55,6 +55,18 @@ class ChatRepositoryImpl @Inject constructor(
|
||||
val body = MultipartBody.Part.createFormData("file", file.name, requestFile)
|
||||
return api.uploadFile(body).url
|
||||
}
|
||||
|
||||
override suspend fun getTrendingGifs(page: Int): List<chats.data.remote.api.KlipyGifDto> {
|
||||
return api.getTrendingGifs(page).data.data
|
||||
}
|
||||
|
||||
override suspend fun searchGifs(query: String, page: Int): List<chats.data.remote.api.KlipyGifDto> {
|
||||
return api.searchGifs(query, page).data.data
|
||||
}
|
||||
|
||||
override suspend fun getGifCategories(): List<chats.data.remote.api.GifCategoryDto> {
|
||||
return api.getGifCategories().data.categories
|
||||
}
|
||||
}
|
||||
|
||||
// Mappers
|
||||
|
||||
Reference in New Issue
Block a user