Skip to content

Commit

Permalink
network: Update Repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Jul 9, 2024
1 parent 894e8ad commit 44888b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,33 @@

package com.infomaniak.multiplatform_swisstransfer.network.repositories

import com.infomaniak.multiplatform_swisstransfer.common.exceptions.UnknownException
import com.infomaniak.multiplatform_swisstransfer.network.ApiClientProvider
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.ApiException
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.NetworkException
import com.infomaniak.multiplatform_swisstransfer.network.exceptions.UnknownApiException
import com.infomaniak.multiplatform_swisstransfer.network.models.ApiResponse
import com.infomaniak.multiplatform_swisstransfer.network.models.transfer.TransferApi
import com.infomaniak.multiplatform_swisstransfer.network.requests.TransferRequest
import io.ktor.client.HttpClient
import kotlinx.serialization.json.Json
import kotlin.coroutines.cancellation.CancellationException

class TransferRepository internal constructor(private val transferRequest: TransferRequest) {

constructor(json: Json, httpClient: HttpClient) : this(TransferRequest(json, httpClient))
constructor(apiClientProvider: ApiClientProvider = ApiClientProvider()) : this(
json = apiClientProvider.json,
httpClient = apiClientProvider.httpClient,
)

internal constructor(json: Json, httpClient: HttpClient) : this(TransferRequest(json, httpClient))

@Throws(
CancellationException::class,
ApiException::class,
UnknownApiException::class,
NetworkException::class,
UnknownException::class,
)
suspend fun getTransfer(linkUUID: String): ApiResponse<TransferApi> = transferRequest.getTransfer(linkUUID)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@

package com.infomaniak.multiplatform_swisstransfer.network.repositories

import com.infomaniak.multiplatform_swisstransfer.network.ApiClientProvider
import com.infomaniak.multiplatform_swisstransfer.network.requests.UploadRequest
import io.ktor.client.HttpClient
import kotlinx.serialization.json.Json

class UploadRepository internal constructor(private val uploadRequest: UploadRequest) {

constructor(json: Json, httpClient: HttpClient) : this(UploadRequest(json, httpClient))
constructor(apiClientProvider: ApiClientProvider = ApiClientProvider()) : this(
apiClientProvider.json,
apiClientProvider.httpClient,
)

internal constructor(json: Json, httpClient: HttpClient) : this(UploadRequest(json, httpClient))

// TODO: implement method here
}

0 comments on commit 44888b8

Please sign in to comment.