Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import io.getstream.chat.android.client.api2.UrlQueryPayload
import io.getstream.chat.android.client.api2.model.requests.PinnedMessagesRequest
import io.getstream.chat.android.client.api2.model.response.ChannelResponse
import io.getstream.chat.android.client.api2.model.response.EventResponse
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
import io.getstream.chat.android.client.api2.model.response.QueryChannelsResponse
import io.getstream.chat.android.client.api2.model.response.QueryGroupedChannelsResponse
import io.getstream.chat.android.client.call.RetrofitCall
import io.getstream.chat.android.network.models.ChannelGetOrCreateRequest
import io.getstream.chat.android.network.models.GetPinnedMessagesResponse
import io.getstream.chat.android.network.models.GroupedQueryChannelsRequest
import io.getstream.chat.android.network.models.HideChannelRequest
import io.getstream.chat.android.network.models.MarkDeliveredRequest
Expand Down Expand Up @@ -179,7 +179,7 @@ internal interface ChannelApi {
@Path("type") channelType: String,
@Path("id") channelId: String,
@UrlQueryPayload @Query("payload") payload: PinnedMessagesRequest,
): RetrofitCall<MessagesResponse>
): RetrofitCall<GetPinnedMessagesResponse>

@POST("/channels/delivered")
fun markDelivered(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ package io.getstream.chat.android.client.api2.endpoint

import io.getstream.chat.android.client.api.AuthenticatedApi
import io.getstream.chat.android.client.api2.model.response.MessageResponse
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
import io.getstream.chat.android.client.api2.model.response.ReactionResponse
import io.getstream.chat.android.client.call.RetrofitCall
import io.getstream.chat.android.network.models.CreateDraftResponse
import io.getstream.chat.android.network.models.GetReactionsResponse
import io.getstream.chat.android.network.models.GetRepliesResponse
import io.getstream.chat.android.network.models.MessageActionRequest
import io.getstream.chat.android.network.models.QueryDraftsRequest
import io.getstream.chat.android.network.models.QueryDraftsResponse
Expand All @@ -31,6 +30,7 @@ import io.getstream.chat.android.network.models.QueryReactionsResponse
import io.getstream.chat.android.network.models.Response
import io.getstream.chat.android.network.models.SendMessageRequest
import io.getstream.chat.android.network.models.SendReactionRequest
import io.getstream.chat.android.network.models.SendReactionResponse
import io.getstream.chat.android.network.models.TranslateMessageRequest
import io.getstream.chat.android.network.models.UpdateMessagePartialRequest
import io.getstream.chat.android.network.models.UpdateMessageRequest
Expand Down Expand Up @@ -114,7 +114,7 @@ internal interface MessageApi {
fun sendReaction(
@Path("id") messageId: String,
@Body request: SendReactionRequest,
): RetrofitCall<ReactionResponse>
): RetrofitCall<SendReactionResponse>

@DELETE("/messages/{id}/reaction/{type}")
fun deleteReaction(
Expand Down Expand Up @@ -145,26 +145,26 @@ internal interface MessageApi {
fun getReplies(
@Path("parent_id") messageId: String,
@Query("limit") limit: Int,
): RetrofitCall<MessagesResponse>
): RetrofitCall<GetRepliesResponse>

@GET("/messages/{parent_id}/replies?sort=[{\"field\":\"created_at\",\"direction\":1}]")
fun getNewerReplies(
@Path("parent_id") parentId: String,
@Query("limit") limit: Int,
@Query("id_gt") lastId: String?,
): RetrofitCall<MessagesResponse>
): RetrofitCall<GetRepliesResponse>

@GET("/messages/{parent_id}/replies")
fun getRepliesMore(
@Path("parent_id") messageId: String,
@Query("limit") limit: Int,
@Query("id_lt") firstId: String,
): RetrofitCall<MessagesResponse>
): RetrofitCall<GetRepliesResponse>

@GET("/messages/{parent_id}/replies")
fun getRepliesAround(
@Path("parent_id") parentId: String,
@Query("limit") limit: Int,
@Query("id_around") aroundId: String,
): RetrofitCall<MessagesResponse>
): RetrofitCall<GetRepliesResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@
* limitations under the License.
*/

package io.getstream.chat.android.client.api2.model.response
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json

import com.squareup.moshi.JsonClass
import io.getstream.chat.android.network.models.MessageResponse
/**
*
*/
@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class GetPinnedMessagesResponse(
@Json(name = "duration")
internal val duration: String,

@JsonClass(generateAdapter = true)
internal data class MessagesResponse(
val messages: List<MessageResponse>,
@Json(name = "messages")
internal val messages: List<io.getstream.chat.android.network.models.MessageResponse> = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,25 @@
* limitations under the License.
*/

package io.getstream.chat.android.client.api2.model.response
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.JsonClass
import com.squareup.moshi.Json

/**
* Basic response information
*/
@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class GetRepliesResponse(
@Json(name = "duration")
internal val duration: String,

@JsonClass(generateAdapter = true)
internal data class ReactionResponse(
val reaction: io.getstream.chat.android.network.models.ReactionResponse,
@Json(name = "messages")
internal val messages: List<io.getstream.chat.android.network.models.MessageResponse> = emptyList(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)

package io.getstream.chat.android.network.models

import com.squareup.moshi.Json

/**
* Basic response information
*/
@com.squareup.moshi.JsonClass(generateAdapter = true)
internal data class SendReactionResponse(
@Json(name = "duration")
internal val duration: String,

@Json(name = "message")
internal val message: io.getstream.chat.android.network.models.MessageResponse,

@Json(name = "reaction")
internal val reaction: io.getstream.chat.android.network.models.ReactionResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ import io.getstream.chat.android.client.api2.model.response.ChannelResponse
import io.getstream.chat.android.client.api2.model.response.EventResponse
import io.getstream.chat.android.client.api2.model.response.FlagResponse
import io.getstream.chat.android.client.api2.model.response.MessageResponse
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
import io.getstream.chat.android.client.api2.model.response.MuteUserResponse
import io.getstream.chat.android.client.api2.model.response.QueryChannelsResponse
import io.getstream.chat.android.client.api2.model.response.QueryGroupedChannelsGroup
import io.getstream.chat.android.client.api2.model.response.QueryGroupedChannelsResponse
import io.getstream.chat.android.client.api2.model.response.ReactionResponse
import io.getstream.chat.android.client.api2.model.response.SyncHistoryResponse
import io.getstream.chat.android.client.call.RetrofitCall
import io.getstream.chat.android.client.parser.toMap
Expand Down Expand Up @@ -121,7 +119,9 @@ import io.getstream.chat.android.network.models.EventRequest
import io.getstream.chat.android.network.models.GetApplicationResponse
import io.getstream.chat.android.network.models.GetBlockedUsersResponse
import io.getstream.chat.android.network.models.GetOGResponse
import io.getstream.chat.android.network.models.GetPinnedMessagesResponse
import io.getstream.chat.android.network.models.GetReactionsResponse
import io.getstream.chat.android.network.models.GetRepliesResponse
import io.getstream.chat.android.network.models.GetThreadResponse
import io.getstream.chat.android.network.models.GetUserGroupResponse
import io.getstream.chat.android.network.models.GroupedChannelsGroupRequest
Expand Down Expand Up @@ -168,6 +168,7 @@ import io.getstream.chat.android.network.models.SearchResponse
import io.getstream.chat.android.network.models.SearchRolesResponse
import io.getstream.chat.android.network.models.SearchUserGroupsResponse
import io.getstream.chat.android.network.models.SendEventRequest
import io.getstream.chat.android.network.models.SendReactionResponse
import io.getstream.chat.android.network.models.SharedLocationResponse
import io.getstream.chat.android.network.models.SharedLocationResponseData
import io.getstream.chat.android.network.models.SortParamRequest
Expand Down Expand Up @@ -491,7 +492,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#sendReactionInput")
fun testSendReaction(call: RetrofitCall<ReactionResponse>, expected: KClass<*>) = runTest {
fun testSendReaction(call: RetrofitCall<SendReactionResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<MessageApi>()
whenever(api.sendReaction(any(), any())).doReturn(call)
Expand Down Expand Up @@ -1302,7 +1303,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#getPinnedMessagesInput")
fun testGetPinnedMessages(call: RetrofitCall<MessagesResponse>, expected: KClass<*>) = runTest {
fun testGetPinnedMessages(call: RetrofitCall<GetPinnedMessagesResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<ChannelApi>()
whenever(api.getPinnedMessages(any(), any(), any())).doReturn(call)
Expand Down Expand Up @@ -1734,7 +1735,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#getNewerRepliesInput")
fun testGetNewerReplies(call: RetrofitCall<MessagesResponse>, expected: KClass<*>) = runTest {
fun testGetNewerReplies(call: RetrofitCall<GetRepliesResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<MessageApi>()
whenever(api.getNewerReplies(any(), any(), any())).doReturn(call)
Expand All @@ -1753,7 +1754,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#getRepliesInput")
fun testGetReplies(call: RetrofitCall<MessagesResponse>, expected: KClass<*>) = runTest {
fun testGetReplies(call: RetrofitCall<GetRepliesResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<MessageApi>()
whenever(api.getReplies(any(), any())).doReturn(call)
Expand All @@ -1771,7 +1772,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#getRepliesMoreInput")
fun testGetRepliesMore(call: RetrofitCall<MessagesResponse>, expected: KClass<*>) = runTest {
fun testGetRepliesMore(call: RetrofitCall<GetRepliesResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<MessageApi>()
whenever(api.getRepliesMore(any(), any(), any())).doReturn(call)
Expand All @@ -1790,7 +1791,7 @@ internal class MoshiChatApiTest {

@ParameterizedTest
@MethodSource("io.getstream.chat.android.client.api2.MoshiChatApiTestArguments#getRepliesAroundInput")
fun testGetRepliesAround(call: RetrofitCall<MessagesResponse>, expected: KClass<*>) = runTest {
fun testGetRepliesAround(call: RetrofitCall<GetRepliesResponse>, expected: KClass<*>) = runTest {
// given
val api = mock<MessageApi>()
whenever(api.getRepliesAround(any(), any(), any())).doReturn(call)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ import io.getstream.chat.android.client.api2.model.response.ChannelResponse
import io.getstream.chat.android.client.api2.model.response.EventResponse
import io.getstream.chat.android.client.api2.model.response.FlagResponse
import io.getstream.chat.android.client.api2.model.response.MessageResponse
import io.getstream.chat.android.client.api2.model.response.MessagesResponse
import io.getstream.chat.android.client.api2.model.response.MuteUserResponse
import io.getstream.chat.android.client.api2.model.response.QueryChannelsResponse
import io.getstream.chat.android.client.api2.model.response.QueryGroupedChannelsGroup
import io.getstream.chat.android.client.api2.model.response.QueryGroupedChannelsResponse
import io.getstream.chat.android.client.api2.model.response.ReactionResponse
import io.getstream.chat.android.client.api2.model.response.SyncHistoryResponse
import io.getstream.chat.android.client.utils.RetroError
import io.getstream.chat.android.client.utils.RetroSuccess
Expand All @@ -56,7 +54,9 @@ import io.getstream.chat.android.network.models.CreateUserGroupResponse
import io.getstream.chat.android.network.models.GetApplicationResponse
import io.getstream.chat.android.network.models.GetBlockedUsersResponse
import io.getstream.chat.android.network.models.GetOGResponse
import io.getstream.chat.android.network.models.GetPinnedMessagesResponse
import io.getstream.chat.android.network.models.GetReactionsResponse
import io.getstream.chat.android.network.models.GetRepliesResponse
import io.getstream.chat.android.network.models.GetThreadResponse
import io.getstream.chat.android.network.models.GetUserGroupResponse
import io.getstream.chat.android.network.models.ListDevicesResponse
Expand All @@ -79,6 +79,7 @@ import io.getstream.chat.android.network.models.SearchResponse
import io.getstream.chat.android.network.models.SearchResult
import io.getstream.chat.android.network.models.SearchRolesResponse
import io.getstream.chat.android.network.models.SearchUserGroupsResponse
import io.getstream.chat.android.network.models.SendReactionResponse
import io.getstream.chat.android.network.models.SharedLocationResponse
import io.getstream.chat.android.network.models.SortParamRequest
import io.getstream.chat.android.network.models.UnblockUsersResponse
Expand Down Expand Up @@ -225,10 +226,16 @@ internal object MoshiChatApiTestArguments {
@JvmStatic
fun sendReactionInput() = listOf(
Arguments.of(
RetroSuccess(ReactionResponse(Mother.randomReactionResponse())).toRetrofitCall(),
RetroSuccess(
SendReactionResponse(
duration = "1ms",
message = Mother.randomMessageResponse(),
reaction = Mother.randomReactionResponse(),
),
).toRetrofitCall(),
Result.Success::class,
),
Arguments.of(RetroError<ReactionResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
Arguments.of(RetroError<SendReactionResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
)

@JvmStatic
Expand Down Expand Up @@ -333,7 +340,7 @@ internal object MoshiChatApiTestArguments {
fun stopWatchingInput() = completableResponseArguments()

@JvmStatic
fun getPinnedMessagesInput() = messagesResponseArguments()
fun getPinnedMessagesInput() = pinnedMessagesResponseArguments()

@JvmStatic
fun updateChannelInput() = channelResponseArguments()
Expand Down Expand Up @@ -411,16 +418,16 @@ internal object MoshiChatApiTestArguments {
)

@JvmStatic
fun getNewerRepliesInput() = messagesResponseArguments()
fun getNewerRepliesInput() = repliesResponseArguments()

@JvmStatic
fun getRepliesInput() = messagesResponseArguments()
fun getRepliesInput() = repliesResponseArguments()

@JvmStatic
fun getRepliesMoreInput() = messagesResponseArguments()
fun getRepliesMoreInput() = repliesResponseArguments()

@JvmStatic
fun getRepliesAroundInput() = messagesResponseArguments()
fun getRepliesAroundInput() = repliesResponseArguments()

@JvmStatic
fun sendActionInput() = messageResponseArguments()
Expand Down Expand Up @@ -931,12 +938,23 @@ internal object MoshiChatApiTestArguments {
Arguments.of(RetroError<MessageResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
)

private fun messagesResponseArguments() = listOf(
private fun repliesResponseArguments() = listOf(
Arguments.of(
RetroSuccess(GetRepliesResponse(duration = "1ms", messages = listOf(Mother.randomMessageResponse())))
.toRetrofitCall(),
Result.Success::class,
),
Arguments.of(RetroError<GetRepliesResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
)

private fun pinnedMessagesResponseArguments() = listOf(
Arguments.of(
RetroSuccess(MessagesResponse(listOf(Mother.randomMessageResponse()))).toRetrofitCall(),
RetroSuccess(
GetPinnedMessagesResponse(duration = "1ms", messages = listOf(Mother.randomMessageResponse())),
).toRetrofitCall(),
Result.Success::class,
),
Arguments.of(RetroError<MessagesResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
Arguments.of(RetroError<GetPinnedMessagesResponse>(statusCode = 500).toRetrofitCall(), Result.Failure::class),
)

private fun updateUsersResponseArguments(): List<Arguments> {
Expand Down
Loading
Loading