Skip to content

Instantly share code, notes, and snippets.

@wlk
Created June 20, 2017 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlk/4b011dfd6fdac360584e6cf7e581b689 to your computer and use it in GitHub Desktop.
Save wlk/4b011dfd6fdac360584e6cf7e581b689 to your computer and use it in GitHub Desktop.
case class Author(id: UUID, name: String, dateOfBirth: DateTime, dateOfDeath: Option[DateTime], createdAt: DateTime, updatedAt: DateTime)
def toJsonapi(author: Author) = {
ResourceObject(
`type` = author.`type`,
id = Some(author.id),
attributes = authorAttributes(author),
relationships = authorRelationships(author),
links = List(Links.Self(selfLink(author))
)
}
def authorAttributes(author: Autor): Map[String, String] = { … }
def authorRelationships(author: Author): Map[String, Relationship] = { … }
def selfLink(author: Author): Link = Link(“/v1/author/${author.id}”)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment