From 58487fa79d5196e10f85a731ab45e0be695159b8 Mon Sep 17 00:00:00 2001 From: y9Kap Date: Thu, 7 Mar 2024 23:59:32 +0300 Subject: [PATCH] fix(#93-add-getSubscriptions-and-getSubscribers-methods): promt in first place in search request --- .../sdk/engine/ktor/requests/search/SearchEngine.kt | 2 +- .../kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt | 3 +-- api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt | 8 +++----- .../app/meetacy/sdk/engine/requests/SearchRequest.kt | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/search/SearchEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/search/SearchEngine.kt index c4bea30..941b126 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/search/SearchEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/search/SearchEngine.kt @@ -20,9 +20,9 @@ internal class SearchEngine( val response = httpClient.get(baseUrl.string) { apiVersion(request.apiVersion) token(request.token) + parameter("prompt", request.prompt) parameter("latitude", request.location?.latitude) parameter("longitude", request.location?.longitude) - parameter("prompt", request.prompt) }.bodyAsSuccess>() return SearchRequest.Response(response.map { it.type() }) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt index b9fcad8..bb4a952 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt @@ -12,7 +12,6 @@ import app.meetacy.sdk.types.auth.Token import app.meetacy.sdk.types.location.Location import app.meetacy.sdk.updates.AuthorizedUpdatesApi import app.meetacy.sdk.users.AuthorizedSelfUserDetailsRepository -import app.meetacy.sdk.users.AuthorizedSelfUserRepository import app.meetacy.sdk.users.AuthorizedUsersApi /** @@ -44,6 +43,6 @@ public class AuthorizedMeetacyApi @UnsafeConstructor constructor( ) public suspend fun search(location: Location?, prompt: String): List = - base.search(token, location, prompt).map { AuthorizedSearchItemRepository.of(it.data, api = this) } + base.search(prompt, token, location).map { AuthorizedSearchItemRepository.of(it.data, api = this) } } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt index 5e50b4a..674ba56 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt @@ -13,8 +13,6 @@ import app.meetacy.sdk.search.SearchItemRepository import app.meetacy.sdk.types.annotation.UnsafeConstructor import app.meetacy.sdk.types.auth.Token import app.meetacy.sdk.types.location.Location -import app.meetacy.sdk.types.user.SelfUser -import app.meetacy.sdk.types.user.SelfUserDetails import app.meetacy.sdk.updates.UpdatesApi import app.meetacy.sdk.users.SelfUserDetailsRepository import app.meetacy.sdk.users.UsersApi @@ -40,13 +38,13 @@ public class MeetacyApi( } public suspend fun search( + prompt: String, token: Token, - location: Location?, - prompt: String + location: Location? ): List { return engine.execute( request = SearchRequest( - token, location, prompt + prompt, token, location ) ).items.map { searchItem -> SearchItemRepository.of(searchItem, api = this) diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/SearchRequest.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/SearchRequest.kt index 998e627..d26fcd8 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/SearchRequest.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/SearchRequest.kt @@ -5,9 +5,9 @@ import app.meetacy.sdk.types.location.Location import app.meetacy.sdk.types.search.SearchItem public data class SearchRequest( + val prompt: String, val token: Token, - val location: Location?, - val prompt: String + val location: Location? ) : MeetacyRequest { public data class Response(val items: List) }