package chatops4s import cats.effect.IO object UsageExample { val inbound: InboundGateway = ??? val outbound: OutboundGateway = ??? for { approveAction <- inbound.registerAction(ctx => IO(println(s"Approved by ${ctx.userId}"))) rejectAction <- inbound.registerAction(ctx => IO(println(s"Rejected by ${ctx.userId}"))) msg = Message( text = "Deploy to production?", interactions = Seq( approveAction.render("Approve"), rejectAction.render("Reject"), ), ) response <- outbound.sendToChannel("channel123", msg) _ <- outbound.sendToThread(response.messageId, Message("Thanks for your feedback")) } yield () } // allows to put data into the platform, probably based on sttp trait OutboundGateway { def sendToChannel(channelId: String, message: Message): IO[MessageResponse] def sendToThread(messageId: String, message: Message): IO[MessageResponse] } case class Message( text: String, interactions: Seq[Button] = Seq(), ) case class MessageResponse( messageId: String, ) // allows to receive data from the platform trait InboundGateway { // todo: id will be required to keep processing between restarts def registerAction(handler: InteractionContext => IO[Unit]): IO[ButtonInteraction] } // who clicked what where case class InteractionContext( userId: String, channelId: String, messageId: String, ) // registered interaction // handler was registered and produced this object that can be used to accept data trait ButtonInteraction { def render(label: String): Button } // Direct mapping of api - object we put in the request case class Button(label: String, value: String)