Skip to content

Commit

Permalink
Merge pull request #115 from Infomaniak/feat-author-email-token
Browse files Browse the repository at this point in the history
feat: Add authorEmailToken
  • Loading branch information
sirambd authored Dec 12, 2024
2 parents a100628 + 2129ccd commit bca0506
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface UploadSession {
val uuid: String
val duration: ValidityPeriod get() = ValidityPeriod.THIRTY
val authorEmail: String
val authorEmailToken: String?
val password: String
val message: String
val numberOfDownload: DownloadLimit get() = DownloadLimit.TWO_HUNDRED_FIFTY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.ValidityPeriod
data class NewUploadSession(
override val duration: ValidityPeriod,
override val authorEmail: String,
override val authorEmailToken: String?,
override val password: String,
override val message: String,
override val numberOfDownload: DownloadLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class UploadSessionDB() : UploadSession, RealmObject {
override var uuid: String = RealmUUID.random().toString()
private var _duration: Int = AppSettingsDB.DEFAULT_VALIDITY_PERIOD.value
override var authorEmail: String = ""
override var authorEmailToken: String? = null
override var password: String = ""
override var message: String = ""
private var _numberOfDownload: Int = AppSettingsDB.DEFAULT_DOWNLOAD_LIMIT.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ object DummyUpload {
override val uuid: String = "upload1"
override val duration: ValidityPeriod = ValidityPeriod.THIRTY
override val authorEmail: String = ""
override val authorEmailToken: String? = null
override val password: String = ""
override val message: String = ""
override val numberOfDownload: DownloadLimit = DownloadLimit.ONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import kotlinx.serialization.json.Json
class InitUploadBody(
val duration: String = "",
val authorEmail: String = "",
val authorEmailToken: String? = null,
val password: String = "",
val message: String = "",
val sizeOfUpload: Long = 0L,
Expand All @@ -43,6 +44,7 @@ class InitUploadBody(
constructor(uploadSession: UploadSession, recaptcha: String) : this(
duration = uploadSession.duration.value.toString(),
authorEmail = uploadSession.authorEmail,
authorEmailToken = uploadSession.authorEmailToken,
password = uploadSession.password,
message = uploadSession.message,
sizeOfUpload = uploadSession.files.sumOf { it.size },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ import io.ktor.client.request.setBody
import io.ktor.http.ContentType
import io.ktor.http.contentType
import io.ktor.http.isSuccess
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject

internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(json, httpClient) {

suspend fun initUpload(initUploadBody: InitUploadBody): InitUploadResponseApi {
return post(url = createUrl(ApiRoutes.initUpload), initUploadBody)
val nullableJson = Json(json) {
explicitNulls = false
}
val encodedInitUploadBody = nullableJson.encodeToString(initUploadBody)
return post(url = createUrl(ApiRoutes.initUpload), encodedInitUploadBody)
}

suspend fun verifyEmailCode(verifyEmailCodeBody: VerifyEmailCodeBody): AuthorEmailToken {
Expand Down

0 comments on commit bca0506

Please sign in to comment.