in modules/core/src/main/scala/org/scalasteward/core/forge/gitlab/GitLabApiAlg.scala [312:336]
private def getUserIdForUsername(username: String): F[Option[Int]] = {
val userIdOrError: F[Decoder.Result[Int]] = client
.get[Json](url.users.withQueryParam("username", username), modify)
.flatMap { usersReponse =>
usersReponse.hcursor.values match {
case Some(users) =>
users.headOption match {
case Some(user) => F.pure(user.hcursor.get[Int]("id"))
case None => F.raiseError(new RuntimeException("user not found"))
}
case None =>
F.raiseError(
new RuntimeException(
s"unexpected response from api, Json array expected: $usersReponse"
)
)
}
}
F.rethrow(userIdOrError)
.map(Option(_))
.handleErrorWith { error =>
logger.error(error)(s"failed to get mappings for user '$username'").as(none[Int])
}
}