/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.2-dev * User agent: apibuilder app.apibuilder.io/mard/mard2p-api/0.0.2-dev/http4s_0_18 */ package payp.mard2p.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 io.apibuilder.common.v0.models.json._ import io.apibuilder.generator.v0.models.json._ import io.apibuilder.spec.v0.models.json._ import payp.mard2p.api.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 } } object LongVal { def unapply(s: String): Option[Long] = scala.util.Try(s.toLong).toOption } object AccountidLongMatcher extends QueryParamDecoderMatcher[Long]("accountid") object ActoridStringMatcher extends QueryParamDecoderMatcher[String]("actorid") object AmountDoubleMatcher extends QueryParamDecoderMatcher[Double]("amount") object CurrencyStringMatcher extends QueryParamDecoderMatcher[String]("currency") object DebitDoubleMatcher extends QueryParamDecoderMatcher[Double]("debit") object DepidLongMatcher extends QueryParamDecoderMatcher[Long]("depid") object OperatoridStringMatcher extends QueryParamDecoderMatcher[String]("operatorid") object OwneridStringMatcher extends QueryParamDecoderMatcher[String]("ownerid") object PayidLongMatcher extends QueryParamDecoderMatcher[Long]("payid") object PaymentContextStringMatcher extends QueryParamDecoderMatcher[String]("payment_context") object PaymentMethodStringMatcher extends QueryParamDecoderMatcher[String]("payment_method") object PhoneLongMatcher extends QueryParamDecoderMatcher[Long]("phone") object PinIntMatcher extends QueryParamDecoderMatcher[Int]("pin") object PinLongMatcher extends QueryParamDecoderMatcher[Long]("pin") object RefAccountidLongMatcher extends QueryParamDecoderMatcher[Long]("ref_accountid") object RefAccountidReceiverLongMatcher extends QueryParamDecoderMatcher[Long]("ref_accountid_receiver") object RefAccountidSenderLongMatcher extends QueryParamDecoderMatcher[Long]("ref_accountid_sender") object SenderidStringMatcher extends QueryParamDecoderMatcher[String]("senderid") object SoldDoubleMatcher extends QueryParamDecoderMatcher[Double]("sold") object TotalAmountDoubleMatcher extends QueryParamDecoderMatcher[Double]("total_amount") object TransferidLongMatcher extends QueryParamDecoderMatcher[Long]("transferid") } trait AccountRoutes[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] case class PostCreateRequest(accountid: Long, ownerid: String, totalAmount: Double, sold: Double, debit: Double, currency: String) implicit val PostCreateRequestDecoder: _root_.io.circe.Decoder[PostCreateRequest] = _root_.io.circe.Decoder.instance { a => for { accountid <- a.downField("accountid").as[Long] ownerid <- a.downField("ownerid").as[String] totalAmount <- a.downField("total_amount").as[Double] sold <- a.downField("sold").as[Double] debit <- a.downField("debit").as[Double] currency <- a.downField("currency").as[String] } yield { PostCreateRequest( accountid = accountid, ownerid = ownerid, totalAmount = totalAmount, sold = sold, debit = debit, currency = currency ) } } sealed trait PostCreateResponse object PostCreateResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Account, headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostCreateResponse } def postCreate( _req: org.http4s.Request[F], accountid: Long, ownerid: String, totalAmount: Double, sold: Double, debit: Double, currency: String ): F[PostCreateResponse] case class PutUpdateByAccountidRequest(accountid: Long, ownerid: String, totalAmount: Double, currency: String, sold: Double, debit: Double) implicit val PutUpdateByAccountidRequestDecoder: _root_.io.circe.Decoder[PutUpdateByAccountidRequest] = _root_.io.circe.Decoder.instance { a => for { accountid <- a.downField("accountid").as[Long] ownerid <- a.downField("ownerid").as[String] totalAmount <- a.downField("total_amount").as[Double] currency <- a.downField("currency").as[String] sold <- a.downField("sold").as[Double] debit <- a.downField("debit").as[Double] } yield { PutUpdateByAccountidRequest( accountid = accountid, ownerid = ownerid, totalAmount = totalAmount, currency = currency, sold = sold, debit = debit ) } } sealed trait PutUpdateByAccountidResponse object PutUpdateByAccountidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Account, headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByAccountidResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByAccountidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PutUpdateByAccountidResponse } def putUpdateByAccountid( _req: org.http4s.Request[F], accountid: Long, ownerid: String, totalAmount: Double, currency: String, sold: Double, debit: Double ): F[PutUpdateByAccountidResponse] sealed trait DeleteDeleteByAccountidResponse object DeleteDeleteByAccountidResponse { case class HTTP204(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByAccountidResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByAccountidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByAccountidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends DeleteDeleteByAccountidResponse } def deleteDeleteByAccountid( _req: org.http4s.Request[F], accountid: Long ): F[DeleteDeleteByAccountidResponse] sealed trait GetByAccountidResponse object GetByAccountidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Account, headers: Seq[org.http4s.Header] = Nil) extends GetByAccountidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByAccountidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByAccountidResponse } def getByAccountid( _req: org.http4s.Request[F], accountid: Long, ownerid: String, totalAmount: Double, sold: Double, debit: Double, currency: String ): F[GetByAccountidResponse] sealed trait GetListResponse object GetListResponse { case class HTTP200(value: Seq[payp.mard2p.api.v0.models.Account], headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetListResponse } def getList( _req: org.http4s.Request[F], accountid: Long, ownerid: String, totalAmount: Double, currency: String, sold: Double, debit: Double ): F[GetListResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "accounts" / "create" if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PostCreateRequest].value.flatMap{ case Right(req) => postCreate(_req, req.accountid, req.ownerid, req.totalAmount, req.sold, req.debit, req.currency).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { accountid <- req.getFirst("accountid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) ownerid <- req.getFirst("ownerid") totalAmount <- req.getFirst("total_amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) sold <- req.getFirst("sold").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) debit <- req.getFirst("debit").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) currency <- req.getFirst("currency") } yield { postCreate(_req, accountid, ownerid, totalAmount, sold, debit, currency).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ POST -> Root / "accounts" / "create" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ PUT -> Root / "accounts" / "update" / LongVal(accountid) if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PutUpdateByAccountidRequest].value.flatMap{ case Right(req) => putUpdateByAccountid(_req, req.accountid, req.ownerid, req.totalAmount, req.currency, req.sold, req.debit).flatMap { case PutUpdateByAccountidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByAccountidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByAccountidResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { accountid <- req.getFirst("accountid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) ownerid <- req.getFirst("ownerid") totalAmount <- req.getFirst("total_amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) currency <- req.getFirst("currency") sold <- req.getFirst("sold").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) debit <- req.getFirst("debit").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) } yield { putUpdateByAccountid(_req, accountid, ownerid, totalAmount, currency, sold, debit).flatMap { case PutUpdateByAccountidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByAccountidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByAccountidResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ PUT -> Root / "accounts" / "update" / LongVal(accountid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ DELETE -> Root / "accounts" / "delete" / LongVal(accountid) if apiVersionMatch(_req) => deleteDeleteByAccountid(_req, accountid).flatMap { case DeleteDeleteByAccountidResponse.HTTP204(headers) => NoContent(headers: _*) case DeleteDeleteByAccountidResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case DeleteDeleteByAccountidResponse.HTTP404(headers) => NotFound(headers: _*) case DeleteDeleteByAccountidResponse.UndocumentedResponse(response) => response } case _req @ DELETE -> Root / "accounts" / "delete" / LongVal(accountid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "accounts" / LongVal(accountid) :? OwneridStringMatcher(ownerid) +& TotalAmountDoubleMatcher(totalAmount) +& SoldDoubleMatcher(sold) +& DebitDoubleMatcher(debit) +& CurrencyStringMatcher(currency) if apiVersionMatch(_req) => getByAccountid(_req, accountid, ownerid, totalAmount, sold, debit, currency).flatMap { case GetByAccountidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByAccountidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByAccountidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "accounts" / LongVal(accountid) :? OwneridStringMatcher(ownerid) +& TotalAmountDoubleMatcher(totalAmount) +& SoldDoubleMatcher(sold) +& DebitDoubleMatcher(debit) +& CurrencyStringMatcher(currency) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "accounts" / "list" :? AccountidLongMatcher(accountid) +& OwneridStringMatcher(ownerid) +& TotalAmountDoubleMatcher(totalAmount) +& CurrencyStringMatcher(currency) +& SoldDoubleMatcher(sold) +& DebitDoubleMatcher(debit) if apiVersionMatch(_req) => getList(_req, accountid, ownerid, totalAmount, currency, sold, debit).flatMap { case GetListResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetListResponse.HTTP404(headers) => NotFound(headers: _*) case GetListResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "accounts" / "list" :? AccountidLongMatcher(accountid) +& OwneridStringMatcher(ownerid) +& TotalAmountDoubleMatcher(totalAmount) +& CurrencyStringMatcher(currency) +& SoldDoubleMatcher(sold) +& DebitDoubleMatcher(debit) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait DepositRoutes[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 DeleteDeleteByDepidResponse object DeleteDeleteByDepidResponse { case class HTTP204(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByDepidResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByDepidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByDepidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends DeleteDeleteByDepidResponse } def deleteDeleteByDepid( _req: org.http4s.Request[F], depid: Long ): F[DeleteDeleteByDepidResponse] sealed trait GetByDepidResponse object GetByDepidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends GetByDepidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByDepidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByDepidResponse } def getByDepid( _req: org.http4s.Request[F], depid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetByDepidResponse] sealed trait GetListResponse object GetListResponse { case class HTTP200(value: Seq[payp.mard2p.api.v0.models.Payment], headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetListResponse } def getList( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetListResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ DELETE -> Root / "deposits" / "delete" / LongVal(depid) if apiVersionMatch(_req) => deleteDeleteByDepid(_req, depid).flatMap { case DeleteDeleteByDepidResponse.HTTP204(headers) => NoContent(headers: _*) case DeleteDeleteByDepidResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case DeleteDeleteByDepidResponse.HTTP404(headers) => NotFound(headers: _*) case DeleteDeleteByDepidResponse.UndocumentedResponse(response) => response } case _req @ DELETE -> Root / "deposits" / "delete" / LongVal(depid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "deposits" / LongVal(depid) :? PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getByDepid(_req, depid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetByDepidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByDepidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByDepidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "deposits" / LongVal(depid) :? PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "deposits" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getList(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetListResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetListResponse.HTTP404(headers) => NotFound(headers: _*) case GetListResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "deposits" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait PaymentRoutes[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] case class PostCreateRequest(payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, currency: String, phone: Long, pin: Int, paymentContext: String) implicit val PostCreateRequestDecoder: _root_.io.circe.Decoder[PostCreateRequest] = _root_.io.circe.Decoder.instance { a => for { payid <- a.downField("payid").as[Long] paymentMethod <- a.downField("payment_method").as[String] actorid <- a.downField("actorid").as[String] refAccountid <- a.downField("ref_accountid").as[Long] operatorid <- a.downField("operatorid").as[String] amount <- a.downField("amount").as[Double] currency <- a.downField("currency").as[String] phone <- a.downField("phone").as[Long] pin <- a.downField("pin").as[Int] paymentContext <- a.downField("payment_context").as[String] } yield { PostCreateRequest( payid = payid, paymentMethod = paymentMethod, actorid = actorid, refAccountid = refAccountid, operatorid = operatorid, amount = amount, currency = currency, phone = phone, pin = pin, paymentContext = paymentContext ) } } sealed trait PostCreateResponse object PostCreateResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostCreateResponse } def postCreate( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, currency: String, phone: Long, pin: Int, paymentContext: String ): F[PostCreateResponse] case class PutUpdateByPayidRequest(payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Int, currency: String, paymentContext: String) implicit val PutUpdateByPayidRequestDecoder: _root_.io.circe.Decoder[PutUpdateByPayidRequest] = _root_.io.circe.Decoder.instance { a => for { payid <- a.downField("payid").as[Long] paymentMethod <- a.downField("payment_method").as[String] actorid <- a.downField("actorid").as[String] refAccountid <- a.downField("ref_accountid").as[Long] operatorid <- a.downField("operatorid").as[String] amount <- a.downField("amount").as[Double] phone <- a.downField("phone").as[Long] pin <- a.downField("pin").as[Int] currency <- a.downField("currency").as[String] paymentContext <- a.downField("payment_context").as[String] } yield { PutUpdateByPayidRequest( payid = payid, paymentMethod = paymentMethod, actorid = actorid, refAccountid = refAccountid, operatorid = operatorid, amount = amount, phone = phone, pin = pin, currency = currency, paymentContext = paymentContext ) } } sealed trait PutUpdateByPayidResponse object PutUpdateByPayidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByPayidResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByPayidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PutUpdateByPayidResponse } def putUpdateByPayid( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Int, currency: String, paymentContext: String ): F[PutUpdateByPayidResponse] sealed trait DeleteDeleteByPayidResponse object DeleteDeleteByPayidResponse { case class HTTP204(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByPayidResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByPayidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByPayidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends DeleteDeleteByPayidResponse } def deleteDeleteByPayid( _req: org.http4s.Request[F], payid: Long ): F[DeleteDeleteByPayidResponse] sealed trait GetByPayidResponse object GetByPayidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends GetByPayidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByPayidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByPayidResponse } def getByPayid( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetByPayidResponse] sealed trait GetByRefAccountidResponse object GetByRefAccountidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends GetByRefAccountidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByRefAccountidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByRefAccountidResponse } def getByRefAccountid( _req: org.http4s.Request[F], refAccountid: Long, payid: Long, paymentMethod: String, actorid: String, operatorid: String, amount: Double, phone: Long, pin: Int, currency: String, paymentContext: String ): F[GetByRefAccountidResponse] sealed trait GetListResponse object GetListResponse { case class HTTP200(value: Seq[payp.mard2p.api.v0.models.Payment], headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetListResponse } def getList( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetListResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "payments" / "create" if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PostCreateRequest].value.flatMap{ case Right(req) => postCreate(_req, req.payid, req.paymentMethod, req.actorid, req.refAccountid, req.operatorid, req.amount, req.currency, req.phone, req.pin, req.paymentContext).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { payid <- req.getFirst("payid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) paymentMethod <- req.getFirst("payment_method") actorid <- req.getFirst("actorid") refAccountid <- req.getFirst("ref_accountid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) operatorid <- req.getFirst("operatorid") amount <- req.getFirst("amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) currency <- req.getFirst("currency") phone <- req.getFirst("phone").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) pin <- req.getFirst("pin").flatMap(f => _root_.io.circe.parser.decode[Int](f).toOption) paymentContext <- req.getFirst("payment_context") } yield { postCreate(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, currency, phone, pin, paymentContext).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ POST -> Root / "payments" / "create" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ PUT -> Root / "payments" / "update" / LongVal(payid) if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PutUpdateByPayidRequest].value.flatMap{ case Right(req) => putUpdateByPayid(_req, req.payid, req.paymentMethod, req.actorid, req.refAccountid, req.operatorid, req.amount, req.phone, req.pin, req.currency, req.paymentContext).flatMap { case PutUpdateByPayidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByPayidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByPayidResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { payid <- req.getFirst("payid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) paymentMethod <- req.getFirst("payment_method") actorid <- req.getFirst("actorid") refAccountid <- req.getFirst("ref_accountid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) operatorid <- req.getFirst("operatorid") amount <- req.getFirst("amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) phone <- req.getFirst("phone").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) pin <- req.getFirst("pin").flatMap(f => _root_.io.circe.parser.decode[Int](f).toOption) currency <- req.getFirst("currency") paymentContext <- req.getFirst("payment_context") } yield { putUpdateByPayid(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case PutUpdateByPayidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByPayidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByPayidResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ PUT -> Root / "payments" / "update" / LongVal(payid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ DELETE -> Root / "payments" / "delete" / LongVal(payid) if apiVersionMatch(_req) => deleteDeleteByPayid(_req, payid).flatMap { case DeleteDeleteByPayidResponse.HTTP204(headers) => NoContent(headers: _*) case DeleteDeleteByPayidResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case DeleteDeleteByPayidResponse.HTTP404(headers) => NotFound(headers: _*) case DeleteDeleteByPayidResponse.UndocumentedResponse(response) => response } case _req @ DELETE -> Root / "payments" / "delete" / LongVal(payid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "payments" / LongVal(payid) :? PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getByPayid(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetByPayidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByPayidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByPayidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "payments" / LongVal(payid) :? PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "payments" / LongVal(refAccountid) :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinIntMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getByRefAccountid(_req, refAccountid, payid, paymentMethod, actorid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetByRefAccountidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByRefAccountidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByRefAccountidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "payments" / LongVal(refAccountid) :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinIntMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "payments" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getList(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetListResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetListResponse.HTTP404(headers) => NotFound(headers: _*) case GetListResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "payments" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait TransferRoutes[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] case class PostCreateRequest(transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long) implicit val PostCreateRequestDecoder: _root_.io.circe.Decoder[PostCreateRequest] = _root_.io.circe.Decoder.instance { a => for { transferid <- a.downField("transferid").as[Long] senderid <- a.downField("senderid").as[String] amount <- a.downField("amount").as[Double] currency <- a.downField("currency").as[String] refAccountidReceiver <- a.downField("ref_accountid_receiver").as[Long] refAccountidSender <- a.downField("ref_accountid_sender").as[Long] } yield { PostCreateRequest( transferid = transferid, senderid = senderid, amount = amount, currency = currency, refAccountidReceiver = refAccountidReceiver, refAccountidSender = refAccountidSender ) } } sealed trait PostCreateResponse object PostCreateResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Transfer, headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PostCreateResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostCreateResponse } def postCreate( _req: org.http4s.Request[F], transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long ): F[PostCreateResponse] case class PutUpdateByTransferidRequest(transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long) implicit val PutUpdateByTransferidRequestDecoder: _root_.io.circe.Decoder[PutUpdateByTransferidRequest] = _root_.io.circe.Decoder.instance { a => for { transferid <- a.downField("transferid").as[Long] senderid <- a.downField("senderid").as[String] amount <- a.downField("amount").as[Double] currency <- a.downField("currency").as[String] refAccountidReceiver <- a.downField("ref_accountid_receiver").as[Long] refAccountidSender <- a.downField("ref_accountid_sender").as[Long] } yield { PutUpdateByTransferidRequest( transferid = transferid, senderid = senderid, amount = amount, currency = currency, refAccountidReceiver = refAccountidReceiver, refAccountidSender = refAccountidSender ) } } sealed trait PutUpdateByTransferidResponse object PutUpdateByTransferidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Transfer, headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByTransferidResponse case class HTTP409(headers: Seq[org.http4s.Header] = Nil) extends PutUpdateByTransferidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PutUpdateByTransferidResponse } def putUpdateByTransferid( _req: org.http4s.Request[F], transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long ): F[PutUpdateByTransferidResponse] sealed trait DeleteDeleteByTransferidResponse object DeleteDeleteByTransferidResponse { case class HTTP204(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByTransferidResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByTransferidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByTransferidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends DeleteDeleteByTransferidResponse } def deleteDeleteByTransferid( _req: org.http4s.Request[F], transferid: Long ): F[DeleteDeleteByTransferidResponse] sealed trait GetByTransferidResponse object GetByTransferidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Account, headers: Seq[org.http4s.Header] = Nil) extends GetByTransferidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByTransferidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByTransferidResponse } def getByTransferid( _req: org.http4s.Request[F], transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long ): F[GetByTransferidResponse] sealed trait GetListResponse object GetListResponse { case class HTTP200(value: Seq[payp.mard2p.api.v0.models.Account], headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetListResponse } def getList( _req: org.http4s.Request[F], transferid: Long, senderid: String, amount: Double, currency: String, refAccountidReceiver: Long, refAccountidSender: Long ): F[GetListResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "transfers" / "create" if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PostCreateRequest].value.flatMap{ case Right(req) => postCreate(_req, req.transferid, req.senderid, req.amount, req.currency, req.refAccountidReceiver, req.refAccountidSender).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { transferid <- req.getFirst("transferid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) senderid <- req.getFirst("senderid") amount <- req.getFirst("amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) currency <- req.getFirst("currency") refAccountidReceiver <- req.getFirst("ref_accountid_receiver").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) refAccountidSender <- req.getFirst("ref_accountid_sender").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) } yield { postCreate(_req, transferid, senderid, amount, currency, refAccountidReceiver, refAccountidSender).flatMap { case PostCreateResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostCreateResponse.HTTP409(headers) => Conflict(headers: _*) case PostCreateResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ POST -> Root / "transfers" / "create" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ PUT -> Root / "transfers" / "update" / LongVal(transferid) if apiVersionMatch(_req) => if (_req.contentType.exists(_.mediaType == _root_.org.http4s.MediaType.`application/json`)) { _req.attemptAs[PutUpdateByTransferidRequest].value.flatMap{ case Right(req) => putUpdateByTransferid(_req, req.transferid, req.senderid, req.amount, req.currency, req.refAccountidReceiver, req.refAccountidSender).flatMap { case PutUpdateByTransferidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByTransferidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByTransferidResponse.UndocumentedResponse(response) => response } case Left(_) => BadRequest() } } else { _req.decode[_root_.org.http4s.UrlForm] { req => val responseOpt = for { transferid <- req.getFirst("transferid").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) senderid <- req.getFirst("senderid") amount <- req.getFirst("amount").flatMap(f => _root_.io.circe.parser.decode[Double](f).toOption) currency <- req.getFirst("currency") refAccountidReceiver <- req.getFirst("ref_accountid_receiver").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) refAccountidSender <- req.getFirst("ref_accountid_sender").flatMap(f => _root_.io.circe.parser.decode[Long](f).toOption) } yield { putUpdateByTransferid(_req, transferid, senderid, amount, currency, refAccountidReceiver, refAccountidSender).flatMap { case PutUpdateByTransferidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PutUpdateByTransferidResponse.HTTP409(headers) => Conflict(headers: _*) case PutUpdateByTransferidResponse.UndocumentedResponse(response) => response } } responseOpt.getOrElse(BadRequest()) } } case _req @ PUT -> Root / "transfers" / "update" / LongVal(transferid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ DELETE -> Root / "transfers" / "delete" / LongVal(transferid) if apiVersionMatch(_req) => deleteDeleteByTransferid(_req, transferid).flatMap { case DeleteDeleteByTransferidResponse.HTTP204(headers) => NoContent(headers: _*) case DeleteDeleteByTransferidResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case DeleteDeleteByTransferidResponse.HTTP404(headers) => NotFound(headers: _*) case DeleteDeleteByTransferidResponse.UndocumentedResponse(response) => response } case _req @ DELETE -> Root / "transfers" / "delete" / LongVal(transferid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "transfers" / LongVal(transferid) :? SenderidStringMatcher(senderid) +& AmountDoubleMatcher(amount) +& CurrencyStringMatcher(currency) +& RefAccountidReceiverLongMatcher(refAccountidReceiver) +& RefAccountidSenderLongMatcher(refAccountidSender) if apiVersionMatch(_req) => getByTransferid(_req, transferid, senderid, amount, currency, refAccountidReceiver, refAccountidSender).flatMap { case GetByTransferidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByTransferidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByTransferidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "transfers" / LongVal(transferid) :? SenderidStringMatcher(senderid) +& AmountDoubleMatcher(amount) +& CurrencyStringMatcher(currency) +& RefAccountidReceiverLongMatcher(refAccountidReceiver) +& RefAccountidSenderLongMatcher(refAccountidSender) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "transfers" / "list" :? TransferidLongMatcher(transferid) +& SenderidStringMatcher(senderid) +& AmountDoubleMatcher(amount) +& CurrencyStringMatcher(currency) +& RefAccountidReceiverLongMatcher(refAccountidReceiver) +& RefAccountidSenderLongMatcher(refAccountidSender) if apiVersionMatch(_req) => getList(_req, transferid, senderid, amount, currency, refAccountidReceiver, refAccountidSender).flatMap { case GetListResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetListResponse.HTTP404(headers) => NotFound(headers: _*) case GetListResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "transfers" / "list" :? TransferidLongMatcher(transferid) +& SenderidStringMatcher(senderid) +& AmountDoubleMatcher(amount) +& CurrencyStringMatcher(currency) +& RefAccountidReceiverLongMatcher(refAccountidReceiver) +& RefAccountidSenderLongMatcher(refAccountidSender) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait ValidationRoutes[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 PostResponse object PostResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Validation, headers: Seq[org.http4s.Header] = Nil) extends PostResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends PostResponse } def post( _req: org.http4s.Request[F], body: => org.http4s.DecodeResult[F, String] ): F[PostResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ POST -> Root / "validations" if apiVersionMatch(_req) => post(_req, _req.attemptAs[String]).flatMap { case PostResponse.HTTP200(value, headers) => Ok(value, headers: _*) case PostResponse.UndocumentedResponse(response) => response } case _req @ POST -> Root / "validations" if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } } trait WithdrawRoutes[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 DeleteDeleteByWdwidResponse object DeleteDeleteByWdwidResponse { case class HTTP204(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByWdwidResponse case class HTTP401(authenticate: org.http4s.headers.`WWW-Authenticate`, headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByWdwidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends DeleteDeleteByWdwidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends DeleteDeleteByWdwidResponse } def deleteDeleteByWdwid( _req: org.http4s.Request[F], wdwid: Long ): F[DeleteDeleteByWdwidResponse] sealed trait GetByWdwidResponse object GetByWdwidResponse { case class HTTP200(value: payp.mard2p.api.v0.models.Payment, headers: Seq[org.http4s.Header] = Nil) extends GetByWdwidResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetByWdwidResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetByWdwidResponse } def getByWdwid( _req: org.http4s.Request[F], wdwid: Long, depid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetByWdwidResponse] sealed trait GetListResponse object GetListResponse { case class HTTP200(value: Seq[payp.mard2p.api.v0.models.Payment], headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class HTTP404(headers: Seq[org.http4s.Header] = Nil) extends GetListResponse case class UndocumentedResponse(response: F[org.http4s.Response[F]]) extends GetListResponse } def getList( _req: org.http4s.Request[F], payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ): F[GetListResponse] def apiVersionMatch(req: org.http4s.Message[F]): Boolean = ApiVersion(req) def service()(implicit sync: Sync[F]) = org.http4s.HttpService[F] { case _req @ DELETE -> Root / "withdraws" / "delete" / LongVal(wdwid) if apiVersionMatch(_req) => deleteDeleteByWdwid(_req, wdwid).flatMap { case DeleteDeleteByWdwidResponse.HTTP204(headers) => NoContent(headers: _*) case DeleteDeleteByWdwidResponse.HTTP401(authenticate, headers) => Unauthorized(authenticate, headers: _*) case DeleteDeleteByWdwidResponse.HTTP404(headers) => NotFound(headers: _*) case DeleteDeleteByWdwidResponse.UndocumentedResponse(response) => response } case _req @ DELETE -> Root / "withdraws" / "delete" / LongVal(wdwid) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "withdraws" / LongVal(wdwid) :? DepidLongMatcher(depid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getByWdwid(_req, wdwid, depid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetByWdwidResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetByWdwidResponse.HTTP404(headers) => NotFound(headers: _*) case GetByWdwidResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "withdraws" / LongVal(wdwid) :? DepidLongMatcher(depid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") case _req @ GET -> Root / "withdraws" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if apiVersionMatch(_req) => getList(_req, payid, paymentMethod, actorid, refAccountid, operatorid, amount, phone, pin, currency, paymentContext).flatMap { case GetListResponse.HTTP200(value, headers) => Ok(value, headers: _*) case GetListResponse.HTTP404(headers) => NotFound(headers: _*) case GetListResponse.UndocumentedResponse(response) => response } case _req @ GET -> Root / "withdraws" / "list" :? PayidLongMatcher(payid) +& PaymentMethodStringMatcher(paymentMethod) +& ActoridStringMatcher(actorid) +& RefAccountidLongMatcher(refAccountid) +& OperatoridStringMatcher(operatorid) +& AmountDoubleMatcher(amount) +& PhoneLongMatcher(phone) +& PinLongMatcher(pin) +& CurrencyStringMatcher(currency) +& PaymentContextStringMatcher(paymentContext) if !_req.headers.get(ApiVersion.ApiVersionMajor).isDefined => BadRequest(s"Missing required request header: ${ApiVersion.ApiVersionMajor}.") } }