diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/keypackage/KeyPackageApi.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/keypackage/KeyPackageApi.kt index 6ed53697bae..ed1c8326861 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/keypackage/KeyPackageApi.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/keypackage/KeyPackageApi.kt @@ -53,6 +53,15 @@ interface KeyPackageApi { */ suspend fun uploadKeyPackages(clientId: String, keyPackages: List): NetworkResponse + /** + * Delete a batch key packages from the server + * + * @param clientId client ID + * @param keyPackages list of key packages + * + */ + suspend fun deleteKeyPackages(clientId: String, keyPackages: List): NetworkResponse + /** * Get the number of available key packages for the self client * diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt index a6efa417a4c..d259f3ef79a 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt @@ -39,6 +39,13 @@ internal open class KeyPackageApiV0 internal constructor() : KeyPackageApi { APINotSupported("MLS: uploadKeyPackages api is only available on API V5") ) + override suspend fun deleteKeyPackages( + clientId: String, + keyPackages: List + ): NetworkResponse = NetworkResponse.Error( + APINotSupported("MLS: uploadKeyPackages api is only available on API V5") + ) + override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse = NetworkResponse.Error( APINotSupported("MLS: getAvailableKeyPackageCount api is only available on API V5") diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt index 06fa01ddb9e..58d37bc988a 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt @@ -28,6 +28,7 @@ import com.wire.kalium.network.api.v4.authenticated.KeyPackageApiV4 import com.wire.kalium.network.kaliumLogger import com.wire.kalium.network.utils.NetworkResponse import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.delete import io.ktor.client.request.get import io.ktor.client.request.parameter import io.ktor.client.request.post @@ -53,12 +54,23 @@ internal open class KeyPackageApiV5 internal constructor( keyPackages: List ): NetworkResponse = wrapKaliumResponse { - kaliumLogger.v("Keypackages Count: ${keyPackages.size}") + kaliumLogger.v("Keypackages Count to upload: ${keyPackages.size}") httpClient.post("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") { setBody(KeyPackageList(keyPackages)) } } + override suspend fun deleteKeyPackages( + clientId: String, + keyPackages: List + ): NetworkResponse = + wrapKaliumResponse { + kaliumLogger.v("Keypackages Count to delete: ${keyPackages.size}") + httpClient.delete("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") { + setBody(KeyPackageList(keyPackages)) + } + } + override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse = wrapKaliumResponse { httpClient.get("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId/$PATH_COUNT") }