All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lucuma.core.model.OrcidProfile.scala Maven / Gradle / Ivy

There is a newer version: 0.108.0
Show newest version
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.core.model

import cats.*
import cats.implicits.*

/** An ORCID profile is an OrcidId and a set of optional fields. */
final case class OrcidProfile(
  orcidId:      OrcidId,
  givenName:    Option[String],
  familyName:   Option[String],
  creditName:   Option[String],
  primaryEmail: Option[String],
) {

  /** The best display name we can provide, based on available information. */
  def displayName: String = (
    creditName                                       <+>
    (givenName, familyName).mapN((g, f) => s"$g $f") <+>
    familyName                                       <+>
    givenName
  ).getOrElse(orcidId.value.toString())

}

object OrcidProfile {
  given Eq[OrcidProfile] =
    Eq.by(x => (x.orcidId, x.givenName, x.familyName, x.creditName, x.primaryEmail))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy