Skip to content

Commit

Permalink
feat: API v7 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow committed Dec 4, 2024
1 parent 06c284a commit ff09fac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ internal open class ConversationApiV0 internal constructor(
}
}

private suspend fun handleServiceAddedResponse(
protected suspend fun handleServiceAddedResponse(
httpResponse: HttpResponse
): NetworkResponse<ServiceAddedResponse> =
when (httpResponse.status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@
package com.wire.kalium.network.api.v7.authenticated

import com.wire.kalium.network.AuthenticatedNetworkClient
import com.wire.kalium.network.api.authenticated.conversation.AddServiceRequest
import com.wire.kalium.network.api.authenticated.conversation.ConversationResponse
import com.wire.kalium.network.api.authenticated.conversation.ConversationResponseV6
import com.wire.kalium.network.api.model.ApiModelMapper
import com.wire.kalium.network.api.model.ApiModelMapperImpl
import com.wire.kalium.network.api.model.ConversationId
import com.wire.kalium.network.api.model.ServiceAddedResponse
import com.wire.kalium.network.api.model.UserId
import com.wire.kalium.network.api.v6.authenticated.ConversationApiV6
import com.wire.kalium.network.exceptions.KaliumException
import com.wire.kalium.network.utils.NetworkResponse
import com.wire.kalium.network.utils.mapSuccess
import com.wire.kalium.network.utils.wrapKaliumResponse
import io.ktor.client.request.get
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import okio.IOException

internal open class ConversationApiV7 internal constructor(
authenticatedNetworkClient: AuthenticatedNetworkClient,
Expand All @@ -42,7 +49,21 @@ internal open class ConversationApiV7 internal constructor(
apiModelMapper.fromApiV6(it)
}

override suspend fun addService(
addServiceRequest: AddServiceRequest,
conversationId: ConversationId
): NetworkResponse<ServiceAddedResponse> = try {
httpClient.post("$PATH_BOT/$PATH_CONVERSATIONS/${conversationId.value}") {
setBody(addServiceRequest)
}.let { response ->
handleServiceAddedResponse(response)
}
} catch (e: IOException) {
NetworkResponse.Error(KaliumException.GenericError(e))
}

protected companion object {
const val PATH_ONE_2_ONE_CONVERSATIONS = "one2one-conversations"
const val PATH_BOT = "bot"
}
}

0 comments on commit ff09fac

Please sign in to comment.