From f8b4165fc4f4e4e7f9f7a9ef983c061c2088084f Mon Sep 17 00:00:00 2001 From: y9Kap Date: Wed, 28 Feb 2024 11:50:46 +0300 Subject: [PATCH] feat(#177-search-without-location): added support search without location. --- .../meetacy/sdk/engine/ktor/requests/search/SearchEngine.kt | 4 ++-- .../commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt | 2 +- api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt | 2 +- .../kotlin/app/meetacy/sdk/engine/requests/SearchRequest.kt | 2 +- 4 files changed, 5 insertions(+), 5 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 f80611a0..c4bea30e 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,8 +20,8 @@ internal class SearchEngine( val response = httpClient.get(baseUrl.string) { apiVersion(request.apiVersion) token(request.token) - parameter("latitude", request.location.latitude) - parameter("longitude", request.location.longitude) + 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 bc738e46..292649d3 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/AuthorizedMeetacyApi.kt @@ -41,7 +41,7 @@ public class AuthorizedMeetacyApi @UnsafeConstructor constructor( data = base.getMe(token), api = this ) - public suspend fun search(location: Location, prompt: String): List = + public suspend fun search(location: Location?, prompt: String): List = base.search(token, location, prompt).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 2fe76e01..d34e2c0e 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt @@ -35,7 +35,7 @@ public class MeetacyApi( public suspend fun search( token: Token, - location: Location, + location: Location?, prompt: String ): List { return engine.execute( 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 a5833fc5..998e6273 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 @@ -6,7 +6,7 @@ import app.meetacy.sdk.types.search.SearchItem public data class SearchRequest( val token: Token, - val location: Location, + val location: Location?, val prompt: String ) : MeetacyRequest { public data class Response(val items: List)