Skip to content

Commit

Permalink
Merge pull request #73 from Infomaniak/share-transfer-url
Browse files Browse the repository at this point in the history
feat: Generate a share transfer url
  • Loading branch information
LunarX authored Nov 1, 2024
2 parents 1f8aae0 + c8370d2 commit e76d21b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class SharedApiUrlCreator internal constructor(
private val uploadController: UploadController,
) {

fun shareTransferUrl(transferUUID: String) = SharedApiRoutes.shareTransfer(transferUUID)

@Throws(RealmException::class)
fun downloadFilesUrl(transferUUID: String): String? {
val transfer = transferController.getTransfer(transferUUID) ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class UploadManager(
* @throws CancellationException If the operation is cancelled.
*/
@Throws(RealmException::class, CancellationException::class)
suspend fun createAnGetUpload(newUploadSession: NewUploadSession): UploadSession = withContext(Dispatchers.IO) {
suspend fun createAndGetUpload(newUploadSession: NewUploadSession): UploadSession = withContext(Dispatchers.IO) {
uploadController.insertAndGet(newUploadSession)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import kotlinx.serialization.json.Json
internal open class BaseRequest(protected val json: Json, protected val httpClient: HttpClient) {

protected fun createUrl(path: String, vararg queries: Pair<String, String>): Url {
val baseUrl = Url(ApiRoutes.baseUrl + path)
val baseUrl = Url(ApiRoutes.API_BASE_URL + path)
return URLBuilder(baseUrl).apply {
queries.forEach { parameters.append(it.first, it.second) }
}.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package com.infomaniak.multiplatform_swisstransfer.network.utils

internal object ApiRoutes {

private const val prodUrl = "https://www.swisstransfer.com/api/"
private const val preprodBaseUrl = "https://swisstransfer.preprod.dev.infomaniak.ch/api/"
const val baseUrl = preprodBaseUrl
private const val PROD_URL = "https://www.swisstransfer.com"
private const val PREPROD_BASE_URL = "https://swisstransfer.preprod.dev.infomaniak.ch"
const val BASE_URL = PREPROD_BASE_URL
const val API_BASE_URL = "$BASE_URL/api/"

//region Transfer
fun getTransfer(linkUUID: String): String = "links/$linkUUID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package com.infomaniak.multiplatform_swisstransfer.network.utils

object SharedApiRoutes {

fun shareTransfer(linkUUID: String): String = "${ApiRoutes.BASE_URL}/d/$linkUUID"

fun downloadFiles(downloadHost: String, linkUUID: String): String = "https://$downloadHost/api/download/$linkUUID"

fun downloadFile(downloadHost: String, linkUUID: String, fileUUID: String?): String {
Expand Down

0 comments on commit e76d21b

Please sign in to comment.