[PM-19857] Migrate AuthenticatedOrganizationApi and models to network module (#4987)

This commit is contained in:
Patrick Honkonen
2025-04-03 17:34:35 -04:00
committed by GitHub
parent f6d5302a73
commit d5de173431
8 changed files with 18 additions and 18 deletions

View File

@@ -0,0 +1,41 @@
package com.bitwarden.network.api
import com.bitwarden.network.model.NetworkResult
import com.bitwarden.network.model.OrganizationAutoEnrollStatusResponseJson
import com.bitwarden.network.model.OrganizationKeysResponseJson
import com.bitwarden.network.model.OrganizationResetPasswordEnrollRequestJson
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Path
/**
* Defines raw calls under the authenticated /organizations API.
*/
interface AuthenticatedOrganizationApi {
/**
* Enrolls this user in the organization's password reset.
*/
@PUT("/organizations/{orgId}/users/{userId}/reset-password-enrollment")
suspend fun organizationResetPasswordEnroll(
@Path("orgId") organizationId: String,
@Path("userId") userId: String,
@Body body: OrganizationResetPasswordEnrollRequestJson,
): NetworkResult<Unit>
/**
* Checks whether this organization auto enrolls users in password reset.
*/
@GET("/organizations/{identifier}/auto-enroll-status")
suspend fun getOrganizationAutoEnrollResponse(
@Path("identifier") organizationIdentifier: String,
): NetworkResult<OrganizationAutoEnrollStatusResponseJson>
/**
* Gets the public and private keys for this organization.
*/
@GET("/organizations/{id}/keys")
suspend fun getOrganizationKeys(
@Path("id") organizationId: String,
): NetworkResult<OrganizationKeysResponseJson>
}

View File

@@ -0,0 +1,17 @@
package com.bitwarden.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Response object returned when requesting organization domain SSO details.
*
* @property organizationId The ID of this organization.
* @property isResetPasswordEnabled Indicates whether the auto-enroll reset password functionality
* is enabled.
*/
@Serializable
data class OrganizationAutoEnrollStatusResponseJson(
@SerialName("id") val organizationId: String,
@SerialName("resetPasswordEnabled") val isResetPasswordEnabled: Boolean,
)

View File

@@ -0,0 +1,16 @@
package com.bitwarden.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Response object containing keys for this organization.
*
* @property privateKey The private key for this organization.
* @property publicKey The public key for this organization.
*/
@Serializable
data class OrganizationKeysResponseJson(
@SerialName("privateKey") val privateKey: String?,
@SerialName("publicKey") val publicKey: String,
)

View File

@@ -0,0 +1,17 @@
package com.bitwarden.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Request body object when enrolling a user in reset password functionality for this organization.
*
* @param passwordHash The hash of this user's password. This is not required if the user does not
* have a password.
* @param resetPasswordKey The key used for password reset.
*/
@Serializable
data class OrganizationResetPasswordEnrollRequestJson(
@SerialName("masterPasswordHash") val passwordHash: String?,
@SerialName("resetPasswordKey") val resetPasswordKey: String,
)