Created
February 13, 2021 13:06
-
-
Save tjarvstrand/eb05e68305bdbef41d4374a583f8745d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.http.scaladsl.model.Uri | |
import enumeratum.Enum | |
import enumeratum.EnumEntry | |
import java.time.ZonedDateTime | |
object Activity { | |
sealed abstract class Type extends EnumEntry.Lowercase | |
object Type extends Enum[Type] { | |
case object Post extends Type | |
case object Comment extends Type | |
override def values: IndexedSeq[Type] = findValues | |
} | |
case class Parent(id: String, author: User) | |
object Target { | |
sealed abstract class Type extends EnumEntry.Lowercase | |
object Type extends Enum[Type] { | |
case object Topic extends Type | |
case object Group extends Type | |
case object User extends Type | |
override def values: IndexedSeq[Type] = findValues | |
} | |
} | |
case class Target(id: String, `type`: Target.Type) | |
object Content { | |
sealed abstract class Attachment | |
object Attachment { | |
case class Video(video: Uri) extends Attachment | |
case class Image(image: Uri) extends Attachment | |
} | |
} | |
case class Content(language: String, | |
text: String, | |
enriched_text: String, | |
attachments: Seq[Content.Attachment]) | |
} | |
sealed trait Activity { | |
def id: String | |
def `type`: Activity.Type | |
def author: User | |
def content: Activity.Content | |
def target: Activity.Target | |
def created_at: ZonedDateTime | |
def version: String | |
} | |
case class Post(id: String, | |
author: User, | |
content: Activity.Content, | |
target: Activity.Target, | |
created_at: ZonedDateTime, | |
version: String = "2") extends Activity { | |
val `type`: Activity.Type = Activity.Type.Post | |
} | |
case class Comment(id: String, | |
author: User, | |
content: Activity.Content, | |
target: Activity.Target, | |
parent: Activity.Parent, | |
created_at: ZonedDateTime, | |
version: String = "2") extends Activity { | |
val `type`: Activity.Type = Activity.Type.Comment | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment