Skip to content

Commit

Permalink
Merge pull request #74 from Infomaniak/get-added-deeplink-transfer-uuid
Browse files Browse the repository at this point in the history
feat: Return the added transfer by deeplink UUID
  • Loading branch information
LunarX authored Nov 1, 2024
2 parents e76d21b + 74e4cc6 commit 30683e7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit 30683e7

Please sign in to comment.