-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-15054] Add API for importing ciphers (#4339)
- Loading branch information
1 parent
050b3b3
commit 89935ac
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
.../java/com/x8bit/bitwarden/data/vault/datasource/network/model/ImportCiphersJsonRequest.kt
This file contains 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,37 @@ | ||
package com.x8bit.bitwarden.data.vault.datasource.network.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents an import ciphers request. | ||
* | ||
* @property folders A list of folders to import. | ||
* @property ciphers A list of ciphers to import. | ||
* @property folderRelationships A map of cipher folder relationships to import. Key correlates to | ||
* the index of the cipher in the ciphers list. Value correlates to the index of the folder in the | ||
* folders list. | ||
*/ | ||
@Serializable | ||
data class ImportCiphersJsonRequest( | ||
@SerialName("folders") | ||
val folders: List<FolderWithIdJsonRequest>, | ||
@SerialName("ciphers") | ||
val ciphers: List<CipherJsonRequest>, | ||
@SerialName("folderRelationships") | ||
val folderRelationships: Map<Int, Int>, | ||
) { | ||
/** | ||
* Represents a folder request with an optional [id] if the folder already exists. | ||
* | ||
* @property name The name of the folder. | ||
* @property id The ID of the folder, if it already exists. Null otherwise. | ||
**/ | ||
@Serializable | ||
data class FolderWithIdJsonRequest( | ||
@SerialName("name") | ||
val name: String?, | ||
@SerialName("id") | ||
val id: String?, | ||
) | ||
} |
41 changes: 41 additions & 0 deletions
41
...java/com/x8bit/bitwarden/data/vault/datasource/network/model/ImportCiphersResponseJson.kt
This file contains 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,41 @@ | ||
package com.x8bit.bitwarden.data.vault.datasource.network.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* The response body for importing ciphers. | ||
*/ | ||
@Serializable | ||
sealed class ImportCiphersResponseJson { | ||
|
||
/** | ||
* Models a successful json response. | ||
*/ | ||
@Serializable | ||
object Success : ImportCiphersResponseJson() | ||
|
||
/** | ||
* Represents the json body of an invalid request. | ||
* | ||
* @param validationErrors a map where each value is a list of error messages for each key. | ||
* The values in the array should be used for display to the user, since the keys tend to come | ||
* back as nonsense. (eg: empty string key) | ||
*/ | ||
@Serializable | ||
data class Invalid( | ||
@SerialName("message") | ||
private val invalidMessage: String? = null, | ||
|
||
@SerialName("Message") | ||
private val errorMessage: String? = null, | ||
|
||
@SerialName("validationErrors") | ||
val validationErrors: Map<String, List<String>>?, | ||
) : ImportCiphersResponseJson() { | ||
/** | ||
* A generic error message. | ||
*/ | ||
val message: String? get() = invalidMessage ?: errorMessage | ||
} | ||
} |
This file contains 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 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 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