Skip to content

Commit

Permalink
feat(api): Map user from model to API
Browse files Browse the repository at this point in the history
Signed-off-by: Jyrki Keisala <[email protected]>
  • Loading branch information
Etsija committed Oct 16, 2024
1 parent c738ede commit d46a73c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v1/mapping/src/commonMain/kotlin/Mappings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import org.eclipse.apoapsis.ortserver.api.v1.model.Severity as ApiSeverity
import org.eclipse.apoapsis.ortserver.api.v1.model.SortDirection as ApiSortDirection
import org.eclipse.apoapsis.ortserver.api.v1.model.SortProperty as ApiSortProperty
import org.eclipse.apoapsis.ortserver.api.v1.model.SourceCodeOrigin as ApiSourceCodeOrigin
import org.eclipse.apoapsis.ortserver.api.v1.model.User as ApiUser
import org.eclipse.apoapsis.ortserver.api.v1.model.VcsInfo as ApiVcsInfo
import org.eclipse.apoapsis.ortserver.api.v1.model.Vulnerability as ApiVulnerability
import org.eclipse.apoapsis.ortserver.api.v1.model.VulnerabilityReference as ApiVulnerabilityReference
Expand Down Expand Up @@ -119,6 +120,7 @@ import org.eclipse.apoapsis.ortserver.model.ScannerJobConfiguration
import org.eclipse.apoapsis.ortserver.model.Secret
import org.eclipse.apoapsis.ortserver.model.Severity
import org.eclipse.apoapsis.ortserver.model.SourceCodeOrigin
import org.eclipse.apoapsis.ortserver.model.User
import org.eclipse.apoapsis.ortserver.model.VulnerabilityWithIdentifier
import org.eclipse.apoapsis.ortserver.model.runs.Identifier
import org.eclipse.apoapsis.ortserver.model.runs.Issue
Expand Down Expand Up @@ -759,3 +761,5 @@ fun ApiSourceCodeOrigin.mapToModel() =
ApiSourceCodeOrigin.ARTIFACT -> SourceCodeOrigin.ARTIFACT
ApiSourceCodeOrigin.VCS -> SourceCodeOrigin.VCS
}

fun User.mapToApi() = ApiUser(username, firstName, lastName, email)
11 changes: 10 additions & 1 deletion api/v1/model/src/commonMain/kotlin/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ import kotlinx.serialization.Serializable
*/
@Serializable
data class User(
val id: String,
/** The username of the user. */
val username: String,

/** The first name of the user. */
val firstName: String? = null,

/** The last name of the user. */
val lastName: String? = null,

/** The mail address of the user. */
val email: String? = null,
)

@Serializable
Expand Down

0 comments on commit d46a73c

Please sign in to comment.