[PM-31615] feat: Updated Send network models to support email verification (#6519)

This commit is contained in:
aj-rosado
2026-02-12 16:43:05 +00:00
committed by GitHub
parent bb44586d76
commit afa9c28341
10 changed files with 99 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
package com.bitwarden.network.model
import androidx.annotation.Keep
import com.bitwarden.core.data.serializer.BaseEnumeratedIntSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents different types of send Authentication.
*/
@Serializable(SendAuthTypeSerializer::class)
enum class SendAuthTypeJson {
/**
* Email-based OTP authentication.
*/
@SerialName("0")
EMAIL,
/**
* Password-based authentication.
*/
@SerialName("1")
PASSWORD,
/**
* No authentication required.
*/
@SerialName("2")
NONE,
}
@Keep
private class SendAuthTypeSerializer : BaseEnumeratedIntSerializer<SendAuthTypeJson>(
className = "SendAuthTypeJson",
values = SendAuthTypeJson.entries.toTypedArray(),
)

View File

@@ -9,6 +9,7 @@ import java.time.ZonedDateTime
* Represents a send request.
*
* @property type The type of send.
* @property authType The type of authentication method required to access this Send.
* @property name The name of the send (nullable).
* @property notes The notes of the send (nullable).
* @property key The send key.
@@ -21,12 +22,16 @@ import java.time.ZonedDateTime
* @property password The password protecting this send (nullable).
* @property isDisabled Indicate if this send is disabled.
* @property shouldHideEmail Should the email address of the sender be hidden (nullable).
* @property emails The emails allowed to authenticate this send (nullable).
*/
@Serializable
data class SendJsonRequest(
@SerialName("type")
val type: SendTypeJson,
@SerialName("authType")
val authType: SendAuthTypeJson?,
@SerialName("name")
val name: String?,
@@ -64,4 +69,7 @@ data class SendJsonRequest(
@SerialName("hideEmail")
val shouldHideEmail: Boolean?,
@SerialName("emails")
val emails: String?,
)

View File

@@ -899,8 +899,12 @@ data class SyncResponseJson(
* @property maxAccessCount The max access count of the send object (nullable).
* @property shouldHideEmail If the send object should hide the email.
* @property type The type of send object.
* @property authType Specifies the authentication method required to access this Send.
* @property accessId The access ID of the send object (nullable).
* @property password The password of the send object (nullable).
* Mutually exclusive with [emails]
* @property emails Comma-separated list of emails that may access the send using OTP
* authentication. Mutually exclusive with [password]
* @property file The file of the send object.
* @property deletionDate The max access count of the send object.
* @property name The name of the send object (nullable).
@@ -931,12 +935,18 @@ data class SyncResponseJson(
@SerialName("type")
val type: SendTypeJson,
@SerialName("authType")
val authType: SendAuthTypeJson?,
@SerialName("accessId")
val accessId: String?,
@SerialName("password")
val password: String?,
@SerialName("emails")
val emails: String?,
@SerialName("file")
val file: File?,

View File

@@ -226,7 +226,8 @@ private const val CREATE_UPDATE_SEND_SUCCESS_JSON = """
"revisionDate": "2023-10-27T12:00:00.00Z",
"expirationDate": "2023-10-27T12:00:00.00Z",
"deletionDate": "2023-10-27T12:00:00.00Z",
"hideEmail": false
"hideEmail": false,
"authType": 1,
}
"""
@@ -258,7 +259,8 @@ private const val CREATE_FILE_SEND_SUCCESS_JSON = """
"revisionDate": "2023-10-27T12:00:00.00Z",
"expirationDate": "2023-10-27T12:00:00.00Z",
"deletionDate": "2023-10-27T12:00:00.00Z",
"hideEmail": false
"hideEmail": false,
"authType": 1
}
}
"""

View File

@@ -388,7 +388,8 @@ private const val SYNC_SUCCESS_JSON = """
"text": "mockText-1"
},
"key": "mockKey-1",
"expirationDate": "2023-10-27T12:00:00.00Z"
"expirationDate": "2023-10-27T12:00:00.00Z",
"authType": 1
}
]
}

View File

@@ -21,6 +21,8 @@ fun createMockSendJsonRequest(
password: String? = "mockPassword-$number",
isDisabled: Boolean = false,
shouldHideEmail: Boolean? = false,
authTypeJson: SendAuthTypeJson = SendAuthTypeJson.PASSWORD,
emails: String? = null,
): SendJsonRequest =
SendJsonRequest(
name = name,
@@ -36,4 +38,6 @@ fun createMockSendJsonRequest(
password = password,
isDisabled = isDisabled,
shouldHideEmail = shouldHideEmail,
authType = authTypeJson,
emails = emails,
)

View File

@@ -39,6 +39,8 @@ fun createMockSend(
text: SyncResponseJson.Send.Text? = createMockText(number = number),
key: String? = "mockKey-$number",
expirationDate: ZonedDateTime? = ZonedDateTime.parse("2023-10-27T12:00:00Z"),
authTypeJson: SendAuthTypeJson = SendAuthTypeJson.PASSWORD,
emails: String? = null,
): SyncResponseJson.Send =
SyncResponseJson.Send(
accessCount = accessCount,
@@ -57,6 +59,8 @@ fun createMockSend(
text = text,
key = key,
expirationDate = expirationDate,
authType = authTypeJson,
emails = emails,
)
/**