From 737701409cc141357135fd259003b02ca547cf7d Mon Sep 17 00:00:00 2001 From: y9Kap Date: Wed, 27 Dec 2023 00:04:24 +0300 Subject: [PATCH 1/4] feat(#86-change-requests-type): change some requests type in endpoints --- .../sdk/engine/ktor/requests/friends/FriendsEngine.kt | 2 +- .../sdk/engine/ktor/requests/meetings/MeetingsEngine.kt | 6 ++---- .../meetacy/sdk/engine/ktor/requests/users/UsersEngine.kt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt index 1c00684..b0b566c 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt @@ -73,7 +73,7 @@ internal class FriendsEngine( suspend fun delete(request: DeleteFriendRequest) { val url = baseUrl / "delete" val body = request.toBody() - httpClient.post(url.string) { + httpClient.delete(url.string) { apiVersion(request.apiVersion) token(request.token) setBody(body) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt index c0b37e1..f674c95 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt @@ -37,9 +37,7 @@ import app.meetacy.sdk.types.serializable.user.type import app.meetacy.sdk.types.url.Url import io.ktor.client.HttpClient import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.client.request.post -import io.ktor.client.request.setBody +import io.ktor.client.request.* import kotlinx.serialization.Serializable internal class MeetingsEngine( @@ -199,7 +197,7 @@ internal class MeetingsEngine( suspend fun editMeeting(request: EditMeetingRequest): EditMeetingRequest.Response = with(request) { val url = baseUrl / "edit" val body = request.toBody() - val response = httpClient.post(url.string) { + val response = httpClient.put(url.string) { apiVersion(request.apiVersion) token(request.token) setBody(body) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/users/UsersEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/users/UsersEngine.kt index e868dae..c8e3160 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/users/UsersEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/users/UsersEngine.kt @@ -69,7 +69,7 @@ internal class UsersEngine( suspend fun editUser(request: EditUserRequest): EditUserRequest.Response { val url = baseUrl / "edit" val body = request.toBody() - val response = httpClient.post(url.string) { + val response = httpClient.put(url.string) { apiVersion(request.apiVersion) token(request.token) setBody(body) From a945b88d3daa615be3710f92872443823a6af306 Mon Sep 17 00:00:00 2001 From: y9Kap Date: Wed, 17 Jan 2024 00:27:48 +0300 Subject: [PATCH 2/4] fix(#86-change-requests-type): remove body at get requests --- .../ktor/requests/meetings/MeetingsEngine.kt | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt index f674c95..662613e 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/meetings/MeetingsEngine.kt @@ -74,21 +74,15 @@ internal class MeetingsEngine( return ListMeetingsHistoryRequest.Response(response) } - private fun ListActiveMeetingsRequest.toBody() = ListMeetingsPagingBody( - amount.serializable(), - pagingId?.serializable() - ) - suspend fun listActiveMeetings( request: ListActiveMeetingsRequest ): ListActiveMeetingsRequest.Response { val url = baseUrl / "history" / "active" - val body = request.toBody() - val response = httpClient.get(url.string) { apiVersion(request.apiVersion) token(request.token) - setBody(body) + parameter("amount", request.amount.int) + parameter("pagingId", request.pagingId?.string) }.bodyAsSuccess>() .type() .mapItems { meeting -> meeting.type() } @@ -96,21 +90,15 @@ internal class MeetingsEngine( return ListActiveMeetingsRequest.Response(response) } - private fun ListPastMeetingsRequest.toBody() = ListMeetingsPagingBody( - amount.serializable(), - pagingId?.serializable() - ) - suspend fun listPastMeetings( request: ListPastMeetingsRequest ): ListPastMeetingsRequest.Response { val url = baseUrl / "history" / "past" - val body = request.toBody() - - val response = httpClient.post(url.string) { + val response = httpClient.get(url.string) { apiVersion(request.apiVersion) token(request.token) - setBody(body) + parameter("amount", request.amount.int) + parameter("pagingId", request.pagingId?.string) }.bodyAsSuccess>() .type() .mapItems { meeting -> meeting.type() } @@ -162,7 +150,7 @@ internal class MeetingsEngine( suspend fun createMeeting( request: CreateMeetingRequest - ): CreateMeetingRequest.Response = with(request) { + ): CreateMeetingRequest.Response { val url = baseUrl / "create" val body = request.toBody() val response = httpClient.post(url.string) { From 398f1747ceedd454831511911e9784c21d824e68 Mon Sep 17 00:00:00 2001 From: Alex Sokol Date: Sat, 10 Feb 2024 17:52:01 +0300 Subject: [PATCH 3/4] Update libs.versions.toml --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 443d9af..0807afb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "1.9.0" ktor = "2.3.6" -meetacySdk = "0.0.61" +meetacySdk = "0.0.62" # kotlinx kotlinxCoroutines = "1.6.4" From f8b4165fc4f4e4e7f9f7a9ef983c061c2088084f Mon Sep 17 00:00:00 2001 From: y9Kap Date: Wed, 28 Feb 2024 11:50:46 +0300 Subject: [PATCH 4/4] 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 f80611a..c4bea30 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 bc738e4..292649d 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 2fe76e0..d34e2c0 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 a5833fc..998e627 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)