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

io.github.quafadas.dairect.MessageToSend.scala Maven / Gradle / Ivy

package io.github.quafadas.dairect

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.union

sealed trait MessageToSend extends scala.Product with scala.Serializable { self =>
  @inline final def widen: MessageToSend = this
  def $ordinal: Int

  object project {
    def text: Option[TextToSend] = MessageToSend.TextCase.alt.project.lift(self).map(_.text)
    def image_file: Option[ImageFile] = MessageToSend.Image_fileCase.alt.project.lift(self).map(_.image_file)
    def image_url: Option[ImageUrl] = MessageToSend.Image_urlCase.alt.project.lift(self).map(_.image_url)
  }

  def accept[A](visitor: MessageToSend.Visitor[A]): A = this match {
    case value: MessageToSend.TextCase => visitor.text(value.text)
    case value: MessageToSend.Image_fileCase => visitor.image_file(value.image_file)
    case value: MessageToSend.Image_urlCase => visitor.image_url(value.image_url)
  }
}
object MessageToSend extends ShapeTag.Companion[MessageToSend] {

  def text(text: TextToSend): MessageToSend = TextCase(text)
  def image_file(image_file: ImageFile): MessageToSend = Image_fileCase(image_file)
  def image_url(image_url: ImageUrl): MessageToSend = Image_urlCase(image_url)

  val id: ShapeId = ShapeId("io.github.quafadas.dairect", "MessageToSend")

  val hints: Hints = Hints(
    alloy.Discriminated("type"),
  ).lazily

  final case class TextCase(text: TextToSend) extends MessageToSend { final def $ordinal: Int = 0 }
  final case class Image_fileCase(image_file: ImageFile) extends MessageToSend { final def $ordinal: Int = 1 }
  final case class Image_urlCase(image_url: ImageUrl) extends MessageToSend { final def $ordinal: Int = 2 }

  object TextCase {
    val hints: Hints = Hints.empty
    val schema: Schema[MessageToSend.TextCase] = bijection(TextToSend.schema.addHints(hints), MessageToSend.TextCase(_), _.text)
    val alt = schema.oneOf[MessageToSend]("text")
  }
  object Image_fileCase {
    val hints: Hints = Hints.empty
    val schema: Schema[MessageToSend.Image_fileCase] = bijection(ImageFile.schema.addHints(hints), MessageToSend.Image_fileCase(_), _.image_file)
    val alt = schema.oneOf[MessageToSend]("image_file")
  }
  object Image_urlCase {
    val hints: Hints = Hints.empty
    val schema: Schema[MessageToSend.Image_urlCase] = bijection(ImageUrl.schema.addHints(hints), MessageToSend.Image_urlCase(_), _.image_url)
    val alt = schema.oneOf[MessageToSend]("image_url")
  }

  trait Visitor[A] {
    def text(value: TextToSend): A
    def image_file(value: ImageFile): A
    def image_url(value: ImageUrl): A
  }

  object Visitor {
    trait Default[A] extends Visitor[A] {
      def default: A
      def text(value: TextToSend): A = default
      def image_file(value: ImageFile): A = default
      def image_url(value: ImageUrl): A = default
    }
  }

  implicit val schema: Schema[MessageToSend] = union(
    MessageToSend.TextCase.alt,
    MessageToSend.Image_fileCase.alt,
    MessageToSend.Image_urlCase.alt,
  ){
    _.$ordinal
  }.withId(id).addHints(hints)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy