-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Handle api v2 calls with api repository for api v2 #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
4d2c9d7
chore: Add File and Transfer shared interfaces
sirambd 497e708
chore: Add v2 file and transfer models
sirambd 8cc4a1c
chore: Add ApiV2ErrorException to handle api v2 errors
sirambd b94c55a
chore: Add local thumbnail path in File common model
sirambd ddde307
chore: Rename linkUUID into id
sirambd 255a586
chore: Update ApiEnvironment to support apiV2
sirambd 42f2fd1
chore: Add isAuth method in AccountManager
sirambd 1ad75f6
chore: Add Transfer routes for ApiV2
sirambd b535054
chore: Update the Base Request to support apiV2 calls
sirambd afa66e2
chore: Add missing apiV2 errors exceptions
sirambd b187c78
chore: Add apiV2 TransferRepository
sirambd 03890bd
chore: Update api v1 TransferRequest
sirambd e6ba985
chore: Add ApiResponse for error
sirambd 11ac6f1
chore: Update ApiClient to support apiV2
sirambd a0864ce
chore: Remove useless code
sirambd ab90d8d
chore: Handle DNS errors
sirambd 107d30b
chore: Rename isNetworkException into isRetryableNetworkException
sirambd 1ab2ab6
chore: Add missing api-v2 exceptions
sirambd 8be9a16
chore: Re-throw api exceptions
sirambd 4641eb2
chore: Add new unit tests
sirambd e80c764
chore: Remove useless isAuth function
sirambd 8157432
chore: Add api v2 exceptions classes
sirambd 706aae2
chore: Add apiv2 urls
sirambd 8176b28
chore: Add SharedApiV2Routes
sirambd d07c311
chore: Add TooManyRequestException and UnauthorizedException
sirambd 8f3052b
chore: Add api v2 request and response models
sirambd 5dcca76
chore: Add api v2 UploadRequest
sirambd 90cbe7f
chore: New UploadV2Repository for apiv2
sirambd d9d54b5
chore: Support token in TransferRequest
sirambd 9037ab7
chore: Rewrite in pascal case
sirambd 96f613d
chore: Add isFolder in File
sirambd 348f113
chore: Handle bearer token from BaseRequest
sirambd 47393a5
chore: Add default token for api v1
sirambd 831972f
chore: Replace potentially confusing return keyword with expression body
LouisCAD cb0fd27
chore: Extract function to avoid duplicated code
LouisCAD f32f94f
fix: Use the correct type in Throws declaration
LouisCAD 2269d63
fix: Remove extra slash in url
LouisCAD f4db38a
fix: Fix type of presignedDownloadUrl
LouisCAD 4968620
fix: Declare DownloadLimitReached in throws on the delete function
LouisCAD fe0e617
chore: Remove unneeded ByteArray taking overload of uploadChunkToEtag
LouisCAD a9081e5
chore: Remove unneeded import
LouisCAD ebf8622
fix: Remove extra leading slash
LouisCAD c386361
chore: Remove unneeded ByteArray taking overload of uploadChunk
LouisCAD b096791
fix: Add missing serializable annotation
LouisCAD dcea8d4
chore: Extract ApiResponseForError from ApiResponse file
LouisCAD eb2a598
fix: Fix case of endregion comment to have the IDE recognize it
LouisCAD 8797403
chore: Introduce ApiResponseV2Success
LouisCAD a90952a
refactor: Stop exposing ApiResponseV2Success in repositories
LouisCAD ef71403
chore: Forward requestContextId
LouisCAD e79dc46
fix: Fix throws declarations and make their order consistent
LouisCAD 89864a5
chore: Lower visibility of ApiResponseV2Success to internal
LouisCAD f4cc0b8
chore: Remove unneeded opt-in annotation
LouisCAD fedf2c9
fix: Replace body with decode (was likely a mistake)
LouisCAD caa490f
chore: Forward cause into UnexpectedApiErrorFormatException
LouisCAD eb2bd56
chore: Lower visibility of ApiResponseForError to internal
LouisCAD 19151e9
test: Add TransferV2RepositoryTest
LouisCAD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/transfers/v2/File.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.common.interfaces.transfers.v2 | ||
|
|
||
| interface File { | ||
| val id: String | ||
| val path: String | ||
| val size: Long | ||
| val mimeType: String? get() = null | ||
|
|
||
| // Local | ||
| val thumbnailPath: String? get() = null | ||
| val isFolder: Boolean get() = false | ||
| // utils | ||
| val name get() = path.substringAfterLast("/") | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
...lin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/transfers/v2/Transfer.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.common.interfaces.transfers.v2 | ||
|
|
||
| import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection | ||
| import com.infomaniak.multiplatform_swisstransfer.common.models.TransferStatus | ||
|
|
||
| interface Transfer { | ||
| val id: String | ||
| val senderEmail: String | ||
| val title: String? | ||
| val message: String? | ||
| val createdAt: Long | ||
| val expiresAt: Long | ||
| val files: List<File> get() = emptyList() | ||
| val totalSize: Long | ||
|
|
||
| //region Only local | ||
| val password: String? get() = null | ||
| val transferDirection: TransferDirection? get() = null | ||
| val transferStatus: TransferStatus? get() = null | ||
| val recipientsEmails: Set<String> get() = emptySet() | ||
| //endregion | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../com/infomaniak/multiplatform_swisstransfer/network/exceptions/TooManyRequestException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.network.exceptions | ||
|
|
||
| class TooManyRequestException(requestContextId: String) : ApiException( | ||
| errorMessage = "", | ||
| cause = null, | ||
| requestContextId = requestContextId | ||
| ) |
30 changes: 30 additions & 0 deletions
30
...in/com/infomaniak/multiplatform_swisstransfer/network/exceptions/UnauthorizedException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.network.exceptions | ||
|
|
||
| /** | ||
| * Exception thrown when an API request fails due to missing or invalid Bearer token authorization. | ||
| * | ||
| * This exception indicates that the request requires a valid Bearer token for authentication, | ||
| * but either no token was provided or the token was invalid/expired. | ||
| */ | ||
| class UnauthorizedException(requestContextId: String) : ApiException( | ||
| errorMessage = "", | ||
| cause = null, | ||
| requestContextId = requestContextId | ||
| ) |
38 changes: 38 additions & 0 deletions
38
...in/com/infomaniak/multiplatform_swisstransfer/network/exceptions/UploadErrorsException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.network.exceptions | ||
|
|
||
| sealed class UploadErrorsException(requestContextId: String) : ApiException.ApiV2ErrorException( | ||
| code = "", | ||
| description = "", | ||
| requestContextId = requestContextId | ||
| ) { | ||
|
|
||
| class NotFoundException(requestContextId: String) : UploadErrorsException(requestContextId = requestContextId) | ||
| class TransferCancelled(requestContextId: String) : UploadErrorsException(requestContextId = requestContextId) | ||
| class TransferExpired(requestContextId: String) : UploadErrorsException(requestContextId = requestContextId) | ||
| class TransferFailed(requestContextId: String) : UploadErrorsException(requestContextId = requestContextId) | ||
| } | ||
|
|
||
| internal fun ApiException.ApiV2ErrorException.toUploadErrorsException() = when (code) { | ||
| "object_not_found" -> UploadErrorsException.NotFoundException(requestContextId) | ||
| "transfer_cancelled" -> UploadErrorsException.TransferCancelled(requestContextId) | ||
| "transfer_expired" -> UploadErrorsException.TransferExpired(requestContextId) | ||
| "transfer_failed" -> UploadErrorsException.TransferFailed(requestContextId) | ||
| else -> this | ||
| } |
26 changes: 26 additions & 0 deletions
26
...commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/ApiErrorV2.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2024 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.network.models | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class ApiErrorV2( | ||
| val code: String, | ||
| val description: String, | ||
| ) |
26 changes: 26 additions & 0 deletions
26
...n/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/ApiResponseForError.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Infomaniak SwissTransfer - Multiplatform | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.multiplatform_swisstransfer.network.models | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| internal data class ApiResponseForError( | ||
| val responseStatus: ApiResponseStatus = ApiResponseStatus.ERROR, | ||
| val error: ApiErrorV2 | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.