From d38fbb645112edb3b3319248a1ad41f6d13737ff Mon Sep 17 00:00:00 2001 From: roman_tcaregorodtcev Date: Fri, 5 Oct 2018 14:53:51 +0300 Subject: [PATCH] Request user profile by id added --- .../chat/rocket/core/internal/rest/User.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt b/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt index 0a88bf42..964f30c1 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt @@ -71,6 +71,22 @@ suspend fun RocketChatClient.updateProfile( return handleRestCall>(request, type).result() } +/** + * Get user profile by id. + * + * @param userId The ID of the user. + * @return An [User] profile. + */ +suspend fun RocketChatClient.getProfile(userId: String): User { + val urlBuilder = requestUrl(restUrl, "users.info") + .addQueryParameter("userId", userId) + + val request = requestBuilderForAuthenticatedMethods(urlBuilder.build()).get().build() + + val type = Types.newParameterizedType(RestResult::class.java, User::class.java) + return handleRestCall>(request, type).result() +} + /** * Updates own basic information for the user. *