From 8dd7a3c7d4496fd1fff21a7be81981555a9e1d54 Mon Sep 17 00:00:00 2001 From: Jacob Persson <7156+typfel@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:41:08 +0200 Subject: [PATCH] fix: supported protocols is only available since API v5 --- .../network/api/v4/authenticated/SelfApiV4.kt | 22 +------------------ .../network/api/v5/authenticated/SelfApiV5.kt | 20 ++++++++++++++++- .../SelfApiV4Test.kt => v5/SelfApiV5Test.kt} | 8 +++---- 3 files changed, 24 insertions(+), 26 deletions(-) rename network/src/commonTest/kotlin/com/wire/kalium/api/{v4/user/self/SelfApiV4Test.kt => v5/SelfApiV5Test.kt} (89%) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/SelfApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/SelfApiV4.kt index ebc6c153351..8dd28fde0b3 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/SelfApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/SelfApiV4.kt @@ -19,30 +19,10 @@ package com.wire.kalium.network.api.v4.authenticated import com.wire.kalium.network.AuthenticatedNetworkClient -import com.wire.kalium.network.api.base.authenticated.self.UpdateSupportedProtocolsRequest -import com.wire.kalium.network.api.base.model.SupportedProtocolDTO import com.wire.kalium.network.api.v3.authenticated.SelfApiV3 import com.wire.kalium.network.session.SessionManager -import com.wire.kalium.network.utils.NetworkResponse -import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.put -import io.ktor.client.request.setBody internal open class SelfApiV4 internal constructor( authenticatedNetworkClient: AuthenticatedNetworkClient, sessionManager: SessionManager -) : SelfApiV3(authenticatedNetworkClient, sessionManager) { - - override suspend fun updateSupportedProtocols( - protocols: List - ): NetworkResponse = wrapKaliumResponse { - httpClient.put("$PATH_SELF/$PATH_SUPPORTED_PROTOCOLS") { - setBody(UpdateSupportedProtocolsRequest(protocols)) - } - } - - companion object { - const val PATH_SUPPORTED_PROTOCOLS = "supported-protocols" - } - -} +) : SelfApiV3(authenticatedNetworkClient, sessionManager) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt index a37cf428262..939f4c98c43 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt @@ -19,10 +19,28 @@ package com.wire.kalium.network.api.v5.authenticated import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.self.UpdateSupportedProtocolsRequest +import com.wire.kalium.network.api.base.model.SupportedProtocolDTO import com.wire.kalium.network.api.v4.authenticated.SelfApiV4 import com.wire.kalium.network.session.SessionManager +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.put +import io.ktor.client.request.setBody internal open class SelfApiV5 internal constructor( authenticatedNetworkClient: AuthenticatedNetworkClient, sessionManager: SessionManager -) : SelfApiV4(authenticatedNetworkClient, sessionManager) +) : SelfApiV4(authenticatedNetworkClient, sessionManager) { + override suspend fun updateSupportedProtocols( + protocols: List + ): NetworkResponse = wrapKaliumResponse { + httpClient.put("$PATH_SELF/$PATH_SUPPORTED_PROTOCOLS") { + setBody(UpdateSupportedProtocolsRequest(protocols)) + } + } + + companion object { + const val PATH_SUPPORTED_PROTOCOLS = "supported-protocols" + } +} diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/user/self/SelfApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/SelfApiV5Test.kt similarity index 89% rename from network/src/commonTest/kotlin/com/wire/kalium/api/v4/user/self/SelfApiV4Test.kt rename to network/src/commonTest/kotlin/com/wire/kalium/api/v5/SelfApiV5Test.kt index f1e39013ae7..f6d35e248d7 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/user/self/SelfApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/SelfApiV5Test.kt @@ -16,11 +16,11 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -package com.wire.kalium.api.v4.user.self +package com.wire.kalium.api.v5 import com.wire.kalium.api.ApiTest import com.wire.kalium.network.api.base.model.SupportedProtocolDTO -import com.wire.kalium.network.api.v4.authenticated.SelfApiV4 +import com.wire.kalium.network.api.v5.authenticated.SelfApiV5 import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.HttpStatusCode import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -29,7 +29,7 @@ import kotlin.test.Test import kotlin.test.assertTrue @ExperimentalCoroutinesApi -internal class SelfApiV4Test : ApiTest() { +internal class SelfApiV5Test : ApiTest() { @Test fun givenValidRequest_whenUpdatingSupportedProtocols_theRequestShouldBeConfiguredCorrectly() = runTest { @@ -42,7 +42,7 @@ internal class SelfApiV4Test : ApiTest() { assertPathEqual("$PATH_SELF/$PATH_SUPPORTED_PROTOCOLS") } ) - val selfApi = SelfApiV4(networkClient, TEST_SESSION_MANAGER) + val selfApi = SelfApiV5(networkClient, TEST_SESSION_MANAGER) val response = selfApi.updateSupportedProtocols(listOf(SupportedProtocolDTO.MLS)) assertTrue(response.isSuccessful()) }