/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.4.67 * User agent: apibuilder app.apibuilder.io/flow/github/0.4.67/play_2_6 */ package io.flow.github.v0.models package object bindables { import play.api.mvc.{PathBindable, QueryStringBindable} // import models directly for backwards compatibility with prior versions of the generator import Core._ import Models._ object Core { implicit def pathBindableDateTimeIso8601( implicit stringBinder: QueryStringBindable[String] ): PathBindable[_root_.java.time.OffsetDateTime] = ApibuilderPathBindable(ApibuilderTypes.dateTimeIso8601) implicit def queryStringBindableDateTimeIso8601( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[_root_.java.time.OffsetDateTime] = ApibuilderQueryStringBindable(ApibuilderTypes.dateTimeIso8601) implicit def pathBindableDateIso8601( implicit stringBinder: QueryStringBindable[String] ): PathBindable[_root_.java.time.LocalDate] = ApibuilderPathBindable(ApibuilderTypes.dateIso8601) implicit def queryStringBindableDateIso8601( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[_root_.java.time.LocalDate] = ApibuilderQueryStringBindable(ApibuilderTypes.dateIso8601) } object Models { import io.flow.github.v0.models._ val contentsTypeConverter: ApibuilderTypeConverter[io.flow.github.v0.models.ContentsType] = new ApibuilderTypeConverter[io.flow.github.v0.models.ContentsType] { override def convert(value: String): io.flow.github.v0.models.ContentsType = io.flow.github.v0.models.ContentsType(value) override def convert(value: io.flow.github.v0.models.ContentsType): String = value.toString override def example: io.flow.github.v0.models.ContentsType = io.flow.github.v0.models.ContentsType.File override def validValues: Seq[io.flow.github.v0.models.ContentsType] = io.flow.github.v0.models.ContentsType.all } implicit def pathBindableContentsType( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.ContentsType] = ApibuilderPathBindable(contentsTypeConverter) implicit def queryStringBindableContentsType( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.ContentsType] = ApibuilderQueryStringBindable(contentsTypeConverter) val encodingConverter: ApibuilderTypeConverter[io.flow.github.v0.models.Encoding] = new ApibuilderTypeConverter[io.flow.github.v0.models.Encoding] { override def convert(value: String): io.flow.github.v0.models.Encoding = io.flow.github.v0.models.Encoding(value) override def convert(value: io.flow.github.v0.models.Encoding): String = value.toString override def example: io.flow.github.v0.models.Encoding = io.flow.github.v0.models.Encoding.Base64 override def validValues: Seq[io.flow.github.v0.models.Encoding] = io.flow.github.v0.models.Encoding.all } implicit def pathBindableEncoding( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.Encoding] = ApibuilderPathBindable(encodingConverter) implicit def queryStringBindableEncoding( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.Encoding] = ApibuilderQueryStringBindable(encodingConverter) val hookEventConverter: ApibuilderTypeConverter[io.flow.github.v0.models.HookEvent] = new ApibuilderTypeConverter[io.flow.github.v0.models.HookEvent] { override def convert(value: String): io.flow.github.v0.models.HookEvent = io.flow.github.v0.models.HookEvent(value) override def convert(value: io.flow.github.v0.models.HookEvent): String = value.toString override def example: io.flow.github.v0.models.HookEvent = io.flow.github.v0.models.HookEvent.Push override def validValues: Seq[io.flow.github.v0.models.HookEvent] = io.flow.github.v0.models.HookEvent.all } implicit def pathBindableHookEvent( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.HookEvent] = ApibuilderPathBindable(hookEventConverter) implicit def queryStringBindableHookEvent( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.HookEvent] = ApibuilderQueryStringBindable(hookEventConverter) val nodeTypeConverter: ApibuilderTypeConverter[io.flow.github.v0.models.NodeType] = new ApibuilderTypeConverter[io.flow.github.v0.models.NodeType] { override def convert(value: String): io.flow.github.v0.models.NodeType = io.flow.github.v0.models.NodeType(value) override def convert(value: io.flow.github.v0.models.NodeType): String = value.toString override def example: io.flow.github.v0.models.NodeType = io.flow.github.v0.models.NodeType.Blob override def validValues: Seq[io.flow.github.v0.models.NodeType] = io.flow.github.v0.models.NodeType.all } implicit def pathBindableNodeType( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.NodeType] = ApibuilderPathBindable(nodeTypeConverter) implicit def queryStringBindableNodeType( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.NodeType] = ApibuilderQueryStringBindable(nodeTypeConverter) val ownerTypeConverter: ApibuilderTypeConverter[io.flow.github.v0.models.OwnerType] = new ApibuilderTypeConverter[io.flow.github.v0.models.OwnerType] { override def convert(value: String): io.flow.github.v0.models.OwnerType = io.flow.github.v0.models.OwnerType(value) override def convert(value: io.flow.github.v0.models.OwnerType): String = value.toString override def example: io.flow.github.v0.models.OwnerType = io.flow.github.v0.models.OwnerType.User override def validValues: Seq[io.flow.github.v0.models.OwnerType] = io.flow.github.v0.models.OwnerType.all } implicit def pathBindableOwnerType( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.OwnerType] = ApibuilderPathBindable(ownerTypeConverter) implicit def queryStringBindableOwnerType( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.OwnerType] = ApibuilderQueryStringBindable(ownerTypeConverter) val visibilityConverter: ApibuilderTypeConverter[io.flow.github.v0.models.Visibility] = new ApibuilderTypeConverter[io.flow.github.v0.models.Visibility] { override def convert(value: String): io.flow.github.v0.models.Visibility = io.flow.github.v0.models.Visibility(value) override def convert(value: io.flow.github.v0.models.Visibility): String = value.toString override def example: io.flow.github.v0.models.Visibility = io.flow.github.v0.models.Visibility.All override def validValues: Seq[io.flow.github.v0.models.Visibility] = io.flow.github.v0.models.Visibility.all } implicit def pathBindableVisibility( implicit stringBinder: QueryStringBindable[String] ): PathBindable[io.flow.github.v0.models.Visibility] = ApibuilderPathBindable(visibilityConverter) implicit def queryStringBindableVisibility( implicit stringBinder: QueryStringBindable[String] ): QueryStringBindable[io.flow.github.v0.models.Visibility] = ApibuilderQueryStringBindable(visibilityConverter) } trait ApibuilderTypeConverter[T] { def convert(value: String): T def convert(value: T): String def example: T def validValues: Seq[T] = Nil def errorMessage(key: String, value: String, ex: java.lang.Exception): String = { val base = s"Invalid value '$value' for parameter '$key'. " validValues.toList match { case Nil => base + "Ex: " + convert(example) case values => base + ". Valid values are: " + values.mkString("'", "', '", "'") } } } object ApibuilderTypes { val dateTimeIso8601: ApibuilderTypeConverter[_root_.java.time.OffsetDateTime] = new ApibuilderTypeConverter[_root_.java.time.OffsetDateTime] { override def convert(value: String): _root_.java.time.OffsetDateTime = _root_.java.time.OffsetDateTime.parse(value) override def convert(value: _root_.java.time.OffsetDateTime): String = value.toString override def example: _root_.java.time.OffsetDateTime = _root_.java.time.OffsetDateTime.now } val dateIso8601: ApibuilderTypeConverter[_root_.java.time.LocalDate] = new ApibuilderTypeConverter[_root_.java.time.LocalDate] { override def convert(value: String): _root_.java.time.LocalDate = _root_.java.time.LocalDate.parse(value) override def convert(value: _root_.java.time.LocalDate): String = value.toString override def example: _root_.java.time.LocalDate = _root_.java.time.LocalDate.now } } final case class ApibuilderQueryStringBindable[T]( converters: ApibuilderTypeConverter[T] ) extends QueryStringBindable[T] { override def bind( key: String, params: Map[String, Seq[String]] ): _root_.scala.Option[_root_.scala.Either[String, T]] = { params.getOrElse(key, Nil).headOption.map { v => try { Right( converters.convert(v) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, v, ex) ) } } } override def unbind(key: String, value: T): String = { s"$key=${converters.convert(value)}" } } final case class ApibuilderPathBindable[T]( converters: ApibuilderTypeConverter[T] ) extends PathBindable[T] { override def bind(key: String, value: String): _root_.scala.Either[String, T] = { try { Right( converters.convert(value) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, value, ex) ) } } override def unbind(key: String, value: T): String = { converters.convert(value) } } }