From b86817ffc898e273b25bae6ca760c8b108dca126 Mon Sep 17 00:00:00 2001 From: y9kap Date: Tue, 31 Oct 2023 13:28:50 +0300 Subject: [PATCH] fix(#76-support-search): fuckery optional again --- .../sdk/engine/ktor/KtorMeetacyEngine.kt | 5 ++++ .../sdk/engine/requests/EditMeetingRequest.kt | 12 ++++---- .../sdk/meetings/AuthorizedMeetingsApi.kt | 20 ++++++------- .../meetacy/sdk/meetings/MeetingRepository.kt | 30 +++++++++---------- .../app/meetacy/sdk/meetings/MeetingsApi.kt | 20 ++++++------- .../meeting/MeetingSerializable.kt | 2 +- .../app/meetacy/sdk/types/meeting/Meeting.kt | 2 +- 7 files changed, 48 insertions(+), 43 deletions(-) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt index ffa9a474..4c035978 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt @@ -24,6 +24,8 @@ import io.ktor.client.call.* import io.ktor.client.plugins.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* +import io.ktor.client.request.* +import io.ktor.http.* import io.ktor.utils.io.errors.* import io.rsocket.kotlin.ktor.client.RSocketSupport import kotlinx.coroutines.CancellationException @@ -49,6 +51,9 @@ public class KtorMeetacyEngine( ignoreUnknownKeys = true } } + defaultRequest { + header(HttpHeaders.ContentType, ContentType.Application.Json.toString()) + } } private val auth = AuthEngine(baseUrl, this.httpClient) diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/EditMeetingRequest.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/EditMeetingRequest.kt index 986c4bb4..7bf66f50 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/EditMeetingRequest.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/EditMeetingRequest.kt @@ -11,12 +11,12 @@ import app.meetacy.sdk.types.optional.Optional public data class EditMeetingRequest( public val token: Token, public val meetingId: MeetingId, - public val avatarId: Optional = Optional.Undefined, - public val title: String?, - public val description: String?, - public val location: Location?, - public val date: Date?, - public val visibility: Meeting.Visibility? + public val title: Optional, + public val description: Optional, + public val location: Optional, + public val date: Optional, + public val avatarId: Optional, + public val visibility: Optional ) : MeetacyRequest { public data class Response(val meeting: Meeting) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/AuthorizedMeetingsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/AuthorizedMeetingsApi.kt index 13482c8a..5c37365c 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/AuthorizedMeetingsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/AuthorizedMeetingsApi.kt @@ -55,22 +55,22 @@ public class AuthorizedMeetingsApi( visibility: Meeting.Visibility ): AuthorizedMeetingRepository = edit( meetingId = meetingId, - title = title, - date = date, - location = location, - description = description, + title = Optional.Present(title), + date = Optional.Present(date), + location = Optional.Present(location), + description = Optional.Present(description), avatarId = Optional.Present(avatarId), - visibility = visibility + visibility = Optional.Present(visibility), ) public suspend fun edit( meetingId: MeetingId, - title: String?, - date: Date?, - location: Location?, - description: String?, + title: Optional = Optional.Undefined, + date: Optional = Optional.Undefined, + location: Optional = Optional.Undefined, + description: Optional = Optional.Undefined, avatarId: Optional = Optional.Undefined, - visibility: Meeting.Visibility? + visibility: Optional = Optional.Undefined ): AuthorizedMeetingRepository { val meeting = api.base.meetings.edit( token = api.token, diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingRepository.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingRepository.kt index fa54dfb6..338aef6c 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingRepository.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingRepository.kt @@ -24,7 +24,7 @@ public class MeetingRepository( public val creator: User get() = data.creator public val date: Date get() = data.date public val location: Location get() = data.location - public val title: String? get() = data.title + public val title: String get() = data.title public val description: String? get() = data.description public val participantsCount: Int get() = data.participantsCount public val previewParticipants: List get() = data.previewParticipants @@ -36,30 +36,30 @@ public class MeetingRepository( public suspend fun edited( token: Token, - title: String?, - date: Date?, - location: Location?, + title: String, + date: Date, + location: Location, description: String?, avatarId: FileId?, - visibility: Meeting.Visibility? + visibility: Meeting.Visibility ): MeetingRepository = edited( token = token, - title = title, - date = date, - location = location, - description = description, + title = Optional.Present(title), + date = Optional.Present(date), + location = Optional.Present(location), + description = Optional.Present(description), avatarId = Optional.Present(avatarId), - visibility = visibility, + visibility = Optional.Present(visibility), ) public suspend fun edited( token: Token, - title: String?, - date: Date?, - location: Location?, - description: String?, + title: Optional = Optional.Undefined, + date: Optional = Optional.Undefined, + location: Optional = Optional.Undefined, + description: Optional = Optional.Undefined, avatarId: Optional = Optional.Undefined, - visibility: Meeting.Visibility? + visibility: Optional = Optional.Undefined ): MeetingRepository { return api.meetings.edit( token = token, diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingsApi.kt index ba047249..d7506c61 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/meetings/MeetingsApi.kt @@ -62,23 +62,23 @@ public class MeetingsApi(private val api: MeetacyApi) { ): MeetingRepository = edit( token = token, meetingId = meetingId, - title = title, - date = date, - location = location, - description = description, + title = Optional.Present(title), + date = Optional.Present(date), + location = Optional.Present(location), + description = Optional.Present(description), avatarId = Optional.Present(avatarId), - visibility = visibility, + visibility = Optional.Present(visibility), ) public suspend fun edit( token: Token, meetingId: MeetingId, - title: String?, - date: Date?, - location: Location?, - description: String?, + title: Optional = Optional.Undefined, + date: Optional = Optional.Undefined, + location: Optional = Optional.Undefined, + description: Optional = Optional.Undefined, avatarId: Optional = Optional.Undefined, - visibility: Meeting.Visibility? + visibility: Optional = Optional.Undefined ): MeetingRepository { val meeting = api.engine.execute( EditMeetingRequest( diff --git a/types/serializable/src/commonMain/kotlin/app/meetacy/sdk/types/serializable/meeting/MeetingSerializable.kt b/types/serializable/src/commonMain/kotlin/app/meetacy/sdk/types/serializable/meeting/MeetingSerializable.kt index 38073888..5dc2f304 100644 --- a/types/serializable/src/commonMain/kotlin/app/meetacy/sdk/types/serializable/meeting/MeetingSerializable.kt +++ b/types/serializable/src/commonMain/kotlin/app/meetacy/sdk/types/serializable/meeting/MeetingSerializable.kt @@ -22,7 +22,7 @@ public data class MeetingSerializable( val creator: UserSerializable, val date: DateSerializable, val location: LocationSerializable, - val title: String?, + val title: String, val description: String? = null, val participantsCount: Int, val previewParticipants: List, diff --git a/types/src/commonMain/kotlin/app/meetacy/sdk/types/meeting/Meeting.kt b/types/src/commonMain/kotlin/app/meetacy/sdk/types/meeting/Meeting.kt index a21d3da2..7c3426c7 100644 --- a/types/src/commonMain/kotlin/app/meetacy/sdk/types/meeting/Meeting.kt +++ b/types/src/commonMain/kotlin/app/meetacy/sdk/types/meeting/Meeting.kt @@ -15,7 +15,7 @@ public data class Meeting( val creator: User, val date: Date, val location: Location, - val title: String?, + val title: String, val description: String?, val participantsCount: Int, val previewParticipants: List,