Skip to content

Commit

Permalink
fix: supported protocols is only available since API v5
Browse files Browse the repository at this point in the history
  • Loading branch information
typfel committed Oct 12, 2023
1 parent 29e1c0c commit 9a2063e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportedProtocolDTO>
): NetworkResponse<Unit> = wrapKaliumResponse {
httpClient.put("$PATH_SELF/$PATH_SUPPORTED_PROTOCOLS") {
setBody(UpdateSupportedProtocolsRequest(protocols))
}
}

companion object {
const val PATH_SUPPORTED_PROTOCOLS = "supported-protocols"
}

}
) : SelfApiV3(authenticatedNetworkClient, sessionManager)
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportedProtocolDTO>
): NetworkResponse<Unit> = wrapKaliumResponse {
httpClient.put("$PATH_SELF/$PATH_SUPPORTED_PROTOCOLS") {
setBody(UpdateSupportedProtocolsRequest(protocols))
}
}

companion object {
const val PATH_SUPPORTED_PROTOCOLS = "supported-protocols"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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())
}
Expand Down

0 comments on commit 9a2063e

Please sign in to comment.