/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.1 * User agent: apibuilder app.apibuilder.io/edsancha/medallia-api/0.0.1/http4s_0_18 */ package com.edsancha.medallia.api.v0.server import org.http4s.circe.decodeUri import org.http4s.circe.encodeUri import org.http4s.dsl.{io => _, _} import cats.effect._ import cats.implicits._ import scala.language.higherKinds import com.edsancha.medallia.api.v0.models.json._ import com.edsancha.survey.models.v0.models.json._ private[server] trait Matchers[F[_]] extends Http4sDsl[F] { implicit lazy val queryParamDecodeBigDecimal: org.http4s.QueryParamDecoder[BigDecimal] = org.http4s.QueryParamDecoder.fromUnsafeCast[BigDecimal](p => BigDecimal(p.value))("BigDecimal") implicit lazy val queryParamDecodeInstant: org.http4s.QueryParamDecoder[_root_.java.time.Instant] = org.http4s.QueryParamDecoder.fromUnsafeCast[_root_.java.time.Instant](p => _root_.java.time.OffsetDateTime.parse(p.value).toInstant)("_root_.java.time.Instant") implicit lazy val queryParamDecodeLocalDate: org.http4s.QueryParamDecoder[_root_.java.time.LocalDate] = org.http4s.QueryParamDecoder.fromUnsafeCast[_root_.java.time.LocalDate](p => _root_.java.time.LocalDate.parse(p.value))("_root_.java.time.LocalDate") implicit lazy val queryParamDecodeUUID: org.http4s.QueryParamDecoder[_root_.java.util.UUID] = org.http4s.QueryParamDecoder.fromUnsafeCast[_root_.java.util.UUID](p => _root_.java.util.UUID.fromString(p.value))("_root_.java.util.UUID") object ApiVersion { val ApiVersionMajor = { "X-Apidoc-Version-Major".ci } def apply(req: org.http4s.Message[F]): Boolean = req.headers.get(ApiVersionMajor) match { case Some(v) if v.value == "0" => true case _ => false } } } trait AccessTokenWrapperRoutes[F[_]] extends Matchers[F] { implicit def circeJsonDecoder[A](implicit decoder: _root_.io.circe.Decoder[A], sync: Sync[F]) = org.http4s.circe.jsonOf[F, A] implicit def circeJsonEncoder[A](implicit encoder: _root_.io.circe.Encoder[A], sync: Sync[F]) = org.http4s.circe.jsonEncoderOf[F, A] sealed trait PostAccessTokenResponse object PostAccessTokenResponse { case class HTTP200(value: com.edsancha.medallia.api.v0.models.AccessTokenWrapper, headers: Seq[org.http4s.Header] = Nil) extends PostAccessTokenResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends PostAccessTokenResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostAccessTokenResponse } def postAccessToken( _req: org.http4s.Request[F] ): F[PostAccessTokenResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "accessToken" if apiVersionMatch(_req) => postAccessToken(_req).flatMap { case PostAccessTokenResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostAccessTokenResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case PostAccessTokenResponse.UndocumentedResponse(response) => response } case _req @ POST -> Root / "accessToken" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait ConfigurationRoutes[F[_]] extends Matchers[F] { implicit def circeJsonDecoder[A](implicit decoder: _root_.io.circe.Decoder[A], sync: Sync[F]) = org.http4s.circe.jsonOf[F, A] implicit def circeJsonEncoder[A](implicit encoder: _root_.io.circe.Encoder[A], sync: Sync[F]) = org.http4s.circe.jsonEncoderOf[F, A] sealed trait GetConfigurationResponse object GetConfigurationResponse { case class HTTP200(value: com.edsancha.medallia.api.v0.models.Configuration, headers: Seq[org.http4s.Header] = Nil) extends GetConfigurationResponse case class HTTP400(headers: Seq[org.http4s.Header] = Nil) extends GetConfigurationResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends GetConfigurationResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetConfigurationResponse } def getConfiguration( _req: org.http4s.Request[F] ): F[GetConfigurationResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ GET -> Root / "configuration" if apiVersionMatch(_req) => getConfiguration(_req).flatMap { case GetConfigurationResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetConfigurationResponse.HTTP400(headers) => BadRequest(headers: _*) case GetConfigurationResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case GetConfigurationResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "configuration" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait FeedbackRoutes[F[_]] extends Matchers[F] { implicit def circeJsonDecoder[A](implicit decoder: _root_.io.circe.Decoder[A], sync: Sync[F]) = org.http4s.circe.jsonOf[F, A] implicit def circeJsonEncoder[A](implicit encoder: _root_.io.circe.Encoder[A], sync: Sync[F]) = org.http4s.circe.jsonEncoderOf[F, A] sealed trait PostFeedbackResponse object PostFeedbackResponse { case class HTTP200(headers: Seq[org.http4s.Header] = Nil) extends PostFeedbackResponse case class HTTP400(headers: Seq[org.http4s.Header] = Nil) extends PostFeedbackResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends PostFeedbackResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostFeedbackResponse } def postFeedback( _req: org.http4s.Request[F], body: => org.http4s.DecodeResult[F, com.edsancha.medallia.api.v0.models.Feedback] ): F[PostFeedbackResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "feedback" if apiVersionMatch(_req) => postFeedback(_req, _req.attemptAs[com.edsancha.medallia.api.v0.models.Feedback]).flatMap { case PostFeedbackResponse.HTTP200(headers) => Ok(headers: _*) case PostFeedbackResponse.HTTP400(headers) => BadRequest(headers: _*) case PostFeedbackResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case PostFeedbackResponse.UndocumentedResponse(response) => response } case _req @ POST -> Root / "feedback" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } }