From 74e4cc6cc0741faa839f2c38e1ea142445cae0f1 Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 1 Nov 2024 10:22:13 +0100 Subject: [PATCH] feat: Return the added transfer by deeplink UUID --- .../managers/TransferManager.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/TransferManager.kt b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/TransferManager.kt index e1b041a9..4a8dc5aa 100644 --- a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/TransferManager.kt +++ b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/TransferManager.kt @@ -121,6 +121,9 @@ class TransferManager internal constructor( * @see getTransfers * * @param url The URL associated with the transfer to retrieve. + * + * @return The transferUUID of the added transfer, otherwise null if the api doesn't return the transfer + * * @throws CancellationException If the operation is cancelled. * @throws ApiException If there is an error related to the API during transfer retrieval. * @throws UnexpectedApiErrorFormatException Unparsable api error response. @@ -135,8 +138,10 @@ class TransferManager internal constructor( UnknownException::class, RealmException::class, ) - suspend fun addTransferByUrl(url: String): Unit = withContext(Dispatchers.IO) { - addTransfer(transferRepository.getTransferByUrl(url).data, TransferDirection.RECEIVED) + suspend fun addTransferByUrl(url: String): String? = withContext(Dispatchers.IO) { + val transferApi = transferRepository.getTransferByUrl(url).data ?: return@withContext null + addTransfer(transferApi, TransferDirection.RECEIVED) + return@withContext transferApi.linkUUID } private suspend fun addTransfer(transferApi: TransferApi?, transferDirection: TransferDirection) {