/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.2.16 * apibuilder 0.15.11 app.apibuilder.io/flow/github/0.2.16/http4s_0_15 */ package io.flow.github.v0.models { package object json { import io.circe.Decoder._ import io.circe.Encoder._ import scala.language.implicitConversions // See below - Make Scala 2.11 Either monadic import scala.util.Try import io.circe.{Json, JsonObject, Encoder, Decoder, DecodingFailure} import io.circe.syntax._ import io.flow.github.v0.models.json._ // Make Scala 2.11 Either monadic private[v0] implicit def eitherOps[A,B](e: Either[A,B]) = cats.implicits.catsSyntaxEither(e) private[v0] implicit val decodeUUID: Decoder[_root_.java.util.UUID] = Decoder.decodeString.emapTry(str => Try(_root_.java.util.UUID.fromString(str))) private[v0] implicit val encodeUUID: Encoder[_root_.java.util.UUID] = Encoder.encodeString.contramap[_root_.java.util.UUID](uuid => uuid.toString) private[v0] implicit val decodeInstant: Decoder[_root_.java.time.Instant] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.OffsetDateTime.parse(str).toInstant)) private[v0] implicit val encodeInstant: Encoder[_root_.java.time.Instant] = Encoder.encodeString.contramap[_root_.java.time.Instant](_.toString) private[v0] implicit val decodeLocalDate: Decoder[_root_.java.time.LocalDate] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.LocalDate.parse(str))) private[v0] implicit val encodeLocalDate: Encoder[_root_.java.time.LocalDate] = Encoder.encodeString.contramap[_root_.java.time.LocalDate](_.toString) implicit val jsonDecoderGithubContentsType: Decoder[io.flow.github.v0.models.ContentsType] = Decoder.decodeString.map(io.flow.github.v0.models.ContentsType(_)) implicit val jsonEncoderGithubContentsType: Encoder[io.flow.github.v0.models.ContentsType] = Encoder.encodeString.contramap[io.flow.github.v0.models.ContentsType](_.toString) implicit val jsonDecoderGithubEncoding: Decoder[io.flow.github.v0.models.Encoding] = Decoder.decodeString.map(io.flow.github.v0.models.Encoding(_)) implicit val jsonEncoderGithubEncoding: Encoder[io.flow.github.v0.models.Encoding] = Encoder.encodeString.contramap[io.flow.github.v0.models.Encoding](_.toString) implicit val jsonDecoderGithubHookEvent: Decoder[io.flow.github.v0.models.HookEvent] = Decoder.decodeString.map(io.flow.github.v0.models.HookEvent(_)) implicit val jsonEncoderGithubHookEvent: Encoder[io.flow.github.v0.models.HookEvent] = Encoder.encodeString.contramap[io.flow.github.v0.models.HookEvent](_.toString) implicit val jsonDecoderGithubNodeType: Decoder[io.flow.github.v0.models.NodeType] = Decoder.decodeString.map(io.flow.github.v0.models.NodeType(_)) implicit val jsonEncoderGithubNodeType: Encoder[io.flow.github.v0.models.NodeType] = Encoder.encodeString.contramap[io.flow.github.v0.models.NodeType](_.toString) implicit val jsonDecoderGithubOwnerType: Decoder[io.flow.github.v0.models.OwnerType] = Decoder.decodeString.map(io.flow.github.v0.models.OwnerType(_)) implicit val jsonEncoderGithubOwnerType: Encoder[io.flow.github.v0.models.OwnerType] = Encoder.encodeString.contramap[io.flow.github.v0.models.OwnerType](_.toString) implicit val jsonDecoderGithubVisibility: Decoder[io.flow.github.v0.models.Visibility] = Decoder.decodeString.map(io.flow.github.v0.models.Visibility(_)) implicit val jsonEncoderGithubVisibility: Encoder[io.flow.github.v0.models.Visibility] = Encoder.encodeString.contramap[io.flow.github.v0.models.Visibility](_.toString) implicit def decodeGithubBlob: Decoder[Blob] = Decoder.instance { c => for { content <- c.downField("content").as[String] encoding <- c.downField("encoding").as[io.flow.github.v0.models.Encoding] url <- c.downField("url").as[String] sha <- c.downField("sha").as[String] size <- c.downField("size").as[Long] } yield { Blob( content = content, encoding = encoding, url = url, sha = sha, size = size ) } } implicit def encodeGithubBlob: Encoder[Blob] = Encoder.instance { t => Json.fromFields(Seq( Some("content" -> t.content.asJson), Some("encoding" -> t.encoding.asJson), Some("url" -> t.url.asJson), Some("sha" -> t.sha.asJson), Some("size" -> t.size.asJson) ).flatten) } implicit def decodeGithubBlobCreated: Decoder[BlobCreated] = Decoder.instance { c => for { url <- c.downField("url").as[String] sha <- c.downField("sha").as[String] } yield { BlobCreated( url = url, sha = sha ) } } implicit def encodeGithubBlobCreated: Encoder[BlobCreated] = Encoder.instance { t => Json.fromFields(Seq( Some("url" -> t.url.asJson), Some("sha" -> t.sha.asJson) ).flatten) } implicit def decodeGithubBlobForm: Decoder[BlobForm] = Decoder.instance { c => for { content <- c.downField("content").as[String] encoding <- c.downField("encoding").as[io.flow.github.v0.models.Encoding] } yield { BlobForm( content = content, encoding = encoding ) } } implicit def encodeGithubBlobForm: Encoder[BlobForm] = Encoder.instance { t => Json.fromFields(Seq( Some("content" -> t.content.asJson), Some("encoding" -> t.encoding.asJson) ).flatten) } implicit def decodeGithubCommit: Decoder[Commit] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] htmlUrl <- c.downField("html_url").as[String] author <- c.downField("author").as[io.flow.github.v0.models.Person] committer <- c.downField("committer").as[io.flow.github.v0.models.Person] tree <- c.downField("tree").as[io.flow.github.v0.models.TreeSummary] message <- c.downField("message").as[String] parents <- c.downField("parents").as[Seq[io.flow.github.v0.models.CommitSummary]] } yield { Commit( sha = sha, url = url, htmlUrl = htmlUrl, author = author, committer = committer, tree = tree, message = message, parents = parents ) } } implicit def encodeGithubCommit: Encoder[Commit] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("html_url" -> t.htmlUrl.asJson), Some("author" -> t.author.asJson), Some("committer" -> t.committer.asJson), Some("tree" -> t.tree.asJson), Some("message" -> t.message.asJson), Some("parents" -> t.parents.asJson) ).flatten) } implicit def decodeGithubCommitForm: Decoder[CommitForm] = Decoder.instance { c => for { message <- c.downField("message").as[String] tree <- c.downField("tree").as[String] parents <- c.downField("parents").as[Seq[String]] author <- c.downField("author").as[io.flow.github.v0.models.Person] committer <- c.downField("committer").as[io.flow.github.v0.models.Person] } yield { CommitForm( message = message, tree = tree, parents = parents, author = author, committer = committer ) } } implicit def encodeGithubCommitForm: Encoder[CommitForm] = Encoder.instance { t => Json.fromFields(Seq( Some("message" -> t.message.asJson), Some("tree" -> t.tree.asJson), Some("parents" -> t.parents.asJson), Some("author" -> t.author.asJson), Some("committer" -> t.committer.asJson) ).flatten) } implicit def decodeGithubCommitResponse: Decoder[CommitResponse] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] author <- c.downField("author").as[io.flow.github.v0.models.Person] committer <- c.downField("committer").as[io.flow.github.v0.models.Person] message <- c.downField("message").as[String] tree <- c.downField("tree").as[io.flow.github.v0.models.TreeSummary] parents <- c.downField("parents").as[Seq[io.flow.github.v0.models.TreeSummary]] } yield { CommitResponse( sha = sha, url = url, author = author, committer = committer, message = message, tree = tree, parents = parents ) } } implicit def encodeGithubCommitResponse: Encoder[CommitResponse] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("author" -> t.author.asJson), Some("committer" -> t.committer.asJson), Some("message" -> t.message.asJson), Some("tree" -> t.tree.asJson), Some("parents" -> t.parents.asJson) ).flatten) } implicit def decodeGithubCommitSummary: Decoder[CommitSummary] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] } yield { CommitSummary( sha = sha, url = url ) } } implicit def encodeGithubCommitSummary: Encoder[CommitSummary] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson) ).flatten) } implicit def decodeGithubContents: Decoder[Contents] = Decoder.instance { c => for { __type__ <- c.downField("type").as[io.flow.github.v0.models.ContentsType] encoding <- c.downField("encoding").as[io.flow.github.v0.models.Encoding] size <- c.downField("size").as[Long] name <- c.downField("name").as[String] path <- c.downField("path").as[String] content <- c.downField("content").as[Option[String]] sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] gitUrl <- c.downField("git_url").as[String] htmlUrl <- c.downField("html_url").as[String] downloadUrl <- c.downField("download_url").as[String] } yield { Contents( `type` = __type__, encoding = encoding, size = size, name = name, path = path, content = content, sha = sha, url = url, gitUrl = gitUrl, htmlUrl = htmlUrl, downloadUrl = downloadUrl ) } } implicit def encodeGithubContents: Encoder[Contents] = Encoder.instance { t => Json.fromFields(Seq( Some("type" -> t.`type`.asJson), Some("encoding" -> t.encoding.asJson), Some("size" -> t.size.asJson), Some("name" -> t.name.asJson), Some("path" -> t.path.asJson), t.content.map(t => "content" -> t.asJson), Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("git_url" -> t.gitUrl.asJson), Some("html_url" -> t.htmlUrl.asJson), Some("download_url" -> t.downloadUrl.asJson) ).flatten) } implicit def decodeGithubCreateTreeForm: Decoder[CreateTreeForm] = Decoder.instance { c => for { baseTree <- c.downField("base_tree").as[String] tree <- c.downField("tree").as[Seq[io.flow.github.v0.models.TreeForm]] } yield { CreateTreeForm( baseTree = baseTree, tree = tree ) } } implicit def encodeGithubCreateTreeForm: Encoder[CreateTreeForm] = Encoder.instance { t => Json.fromFields(Seq( Some("base_tree" -> t.baseTree.asJson), Some("tree" -> t.tree.asJson) ).flatten) } implicit def decodeGithubCreateTreeResponse: Decoder[CreateTreeResponse] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] treeResult <- c.downField("tree_result").as[io.flow.github.v0.models.Tree] } yield { CreateTreeResponse( sha = sha, url = url, treeResult = treeResult ) } } implicit def encodeGithubCreateTreeResponse: Encoder[CreateTreeResponse] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("tree_result" -> t.treeResult.asJson) ).flatten) } implicit def decodeGithubError: Decoder[Error] = Decoder.instance { c => for { resource <- c.downField("resource").as[String] field <- c.downField("field").as[String] code <- c.downField("code").as[String] } yield { Error( resource = resource, field = field, code = code ) } } implicit def encodeGithubError: Encoder[Error] = Encoder.instance { t => Json.fromFields(Seq( Some("resource" -> t.resource.asJson), Some("field" -> t.field.asJson), Some("code" -> t.code.asJson) ).flatten) } implicit def decodeGithubGithubObject: Decoder[GithubObject] = Decoder.instance { c => for { __type__ <- c.downField("type").as[String] sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] } yield { GithubObject( `type` = __type__, sha = sha, url = url ) } } implicit def encodeGithubGithubObject: Encoder[GithubObject] = Encoder.instance { t => Json.fromFields(Seq( Some("type" -> t.`type`.asJson), Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson) ).flatten) } implicit def decodeGithubHook: Decoder[Hook] = Decoder.instance { c => for { id <- c.downField("id").as[Long] url <- c.downField("url").as[String] testUrl <- c.downField("test_url").as[String] pingUrl <- c.downField("ping_url").as[String] name <- c.downField("name").as[String] events <- c.downField("events").as[Seq[io.flow.github.v0.models.HookEvent]] active <- c.downField("active").as[Boolean] config <- c.downField("config").as[io.flow.github.v0.models.HookConfig] updatedAt <- c.downField("updated_at").as[_root_.java.time.Instant] createdAt <- c.downField("created_at").as[_root_.java.time.Instant] } yield { Hook( id = id, url = url, testUrl = testUrl, pingUrl = pingUrl, name = name, events = events, active = active, config = config, updatedAt = updatedAt, createdAt = createdAt ) } } implicit def encodeGithubHook: Encoder[Hook] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("url" -> t.url.asJson), Some("test_url" -> t.testUrl.asJson), Some("ping_url" -> t.pingUrl.asJson), Some("name" -> t.name.asJson), Some("events" -> t.events.asJson), Some("active" -> t.active.asJson), Some("config" -> t.config.asJson), Some("updated_at" -> t.updatedAt.asJson), Some("created_at" -> t.createdAt.asJson) ).flatten) } implicit def decodeGithubHookConfig: Decoder[HookConfig] = Decoder.instance { c => for { url <- c.downField("url").as[Option[String]] contentType <- c.downField("content_type").as[Option[String]] } yield { HookConfig( url = url, contentType = contentType ) } } implicit def encodeGithubHookConfig: Encoder[HookConfig] = Encoder.instance { t => Json.fromFields(Seq( t.url.map(t => "url" -> t.asJson), t.contentType.map(t => "content_type" -> t.asJson) ).flatten) } implicit def decodeGithubHookForm: Decoder[HookForm] = Decoder.instance { c => for { name <- c.downField("name").as[String] config <- c.downField("config").as[io.flow.github.v0.models.HookConfig] events <- c.downField("events").as[Seq[io.flow.github.v0.models.HookEvent]] active <- c.downField("active").as[Boolean] } yield { HookForm( name = name, config = config, events = events, active = active ) } } implicit def encodeGithubHookForm: Encoder[HookForm] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("config" -> t.config.asJson), Some("events" -> t.events.asJson), Some("active" -> t.active.asJson) ).flatten) } implicit def decodeGithubNode: Decoder[Node] = Decoder.instance { c => for { path <- c.downField("path").as[String] mode <- c.downField("mode").as[String] __type__ <- c.downField("type").as[io.flow.github.v0.models.NodeType] size <- c.downField("size").as[Long] sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] } yield { Node( path = path, mode = mode, `type` = __type__, size = size, sha = sha, url = url ) } } implicit def encodeGithubNode: Encoder[Node] = Encoder.instance { t => Json.fromFields(Seq( Some("path" -> t.path.asJson), Some("mode" -> t.mode.asJson), Some("type" -> t.`type`.asJson), Some("size" -> t.size.asJson), Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson) ).flatten) } implicit def decodeGithubNodeForm: Decoder[NodeForm] = Decoder.instance { c => for { path <- c.downField("path").as[String] mode <- c.downField("mode").as[String] __type__ <- c.downField("type").as[io.flow.github.v0.models.NodeType] sha <- c.downField("sha").as[String] } yield { NodeForm( path = path, mode = mode, `type` = __type__, sha = sha ) } } implicit def encodeGithubNodeForm: Encoder[NodeForm] = Encoder.instance { t => Json.fromFields(Seq( Some("path" -> t.path.asJson), Some("mode" -> t.mode.asJson), Some("type" -> t.`type`.asJson), Some("sha" -> t.sha.asJson) ).flatten) } implicit def decodeGithubPerson: Decoder[Person] = Decoder.instance { c => for { name <- c.downField("name").as[String] email <- c.downField("email").as[String] date <- c.downField("date").as[_root_.java.time.Instant] } yield { Person( name = name, email = email, date = date ) } } implicit def encodeGithubPerson: Encoder[Person] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("email" -> t.email.asJson), Some("date" -> t.date.asJson) ).flatten) } implicit def decodeGithubPullRequest: Decoder[PullRequest] = Decoder.instance { c => for { id <- c.downField("id").as[Long] url <- c.downField("url").as[String] number <- c.downField("number").as[Long] htmlUrl <- c.downField("html_url").as[String] head <- c.downField("head").as[io.flow.github.v0.models.PullRequestHead] } yield { PullRequest( id = id, url = url, number = number, htmlUrl = htmlUrl, head = head ) } } implicit def encodeGithubPullRequest: Encoder[PullRequest] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("url" -> t.url.asJson), Some("number" -> t.number.asJson), Some("html_url" -> t.htmlUrl.asJson), Some("head" -> t.head.asJson) ).flatten) } implicit def decodeGithubPullRequestForm: Decoder[PullRequestForm] = Decoder.instance { c => for { title <- c.downField("title").as[String] head <- c.downField("head").as[String] base <- c.downField("base").as[String] body <- c.downField("body").as[Option[String]] } yield { PullRequestForm( title = title, head = head, base = base, body = body ) } } implicit def encodeGithubPullRequestForm: Encoder[PullRequestForm] = Encoder.instance { t => Json.fromFields(Seq( Some("title" -> t.title.asJson), Some("head" -> t.head.asJson), Some("base" -> t.base.asJson), t.body.map(t => "body" -> t.asJson) ).flatten) } implicit def decodeGithubPullRequestHead: Decoder[PullRequestHead] = Decoder.instance { c => for { ref <- c.downField("ref").as[String] } yield { PullRequestHead( ref = ref ) } } implicit def encodeGithubPullRequestHead: Encoder[PullRequestHead] = Encoder.instance { t => Json.fromFields(Seq( Some("ref" -> t.ref.asJson) ).flatten) } implicit def decodeGithubRef: Decoder[Ref] = Decoder.instance { c => for { ref <- c.downField("ref").as[String] url <- c.downField("url").as[String] __object__ <- c.downField("object").as[io.flow.github.v0.models.GithubObject] } yield { Ref( ref = ref, url = url, `object` = __object__ ) } } implicit def encodeGithubRef: Encoder[Ref] = Encoder.instance { t => Json.fromFields(Seq( Some("ref" -> t.ref.asJson), Some("url" -> t.url.asJson), Some("object" -> t.`object`.asJson) ).flatten) } implicit def decodeGithubRefForm: Decoder[RefForm] = Decoder.instance { c => for { ref <- c.downField("ref").as[String] sha <- c.downField("sha").as[String] } yield { RefForm( ref = ref, sha = sha ) } } implicit def encodeGithubRefForm: Encoder[RefForm] = Encoder.instance { t => Json.fromFields(Seq( Some("ref" -> t.ref.asJson), Some("sha" -> t.sha.asJson) ).flatten) } implicit def decodeGithubRefUpdateForm: Decoder[RefUpdateForm] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] } yield { RefUpdateForm( sha = sha ) } } implicit def encodeGithubRefUpdateForm: Encoder[RefUpdateForm] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson) ).flatten) } implicit def decodeGithubRepository: Decoder[Repository] = Decoder.instance { c => for { id <- c.downField("id").as[Long] owner <- c.downField("owner").as[io.flow.github.v0.models.User] name <- c.downField("name").as[String] fullName <- c.downField("full_name").as[String] __private__ <- c.downField("private").as[Boolean] description <- c.downField("description").as[Option[String]] url <- c.downField("url").as[String] htmlUrl <- c.downField("html_url").as[String] } yield { Repository( id = id, owner = owner, name = name, fullName = fullName, `private` = __private__, description = description, url = url, htmlUrl = htmlUrl ) } } implicit def encodeGithubRepository: Encoder[Repository] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("owner" -> t.owner.asJson), Some("name" -> t.name.asJson), Some("full_name" -> t.fullName.asJson), Some("private" -> t.`private`.asJson), t.description.map(t => "description" -> t.asJson), Some("url" -> t.url.asJson), Some("html_url" -> t.htmlUrl.asJson) ).flatten) } implicit def decodeGithubTag: Decoder[Tag] = Decoder.instance { c => for { tag <- c.downField("tag").as[String] sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] message <- c.downField("message").as[String] tagger <- c.downField("tagger").as[io.flow.github.v0.models.Tagger] __object__ <- c.downField("object").as[io.flow.github.v0.models.GithubObject] } yield { Tag( tag = tag, sha = sha, url = url, message = message, tagger = tagger, `object` = __object__ ) } } implicit def encodeGithubTag: Encoder[Tag] = Encoder.instance { t => Json.fromFields(Seq( Some("tag" -> t.tag.asJson), Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("message" -> t.message.asJson), Some("tagger" -> t.tagger.asJson), Some("object" -> t.`object`.asJson) ).flatten) } implicit def decodeGithubTagForm: Decoder[TagForm] = Decoder.instance { c => for { tag <- c.downField("tag").as[String] message <- c.downField("message").as[String] __object__ <- c.downField("object").as[String] __type__ <- c.downField("type").as[String] tagger <- c.downField("tagger").as[io.flow.github.v0.models.Tagger] } yield { TagForm( tag = tag, message = message, `object` = __object__, `type` = __type__, tagger = tagger ) } } implicit def encodeGithubTagForm: Encoder[TagForm] = Encoder.instance { t => Json.fromFields(Seq( Some("tag" -> t.tag.asJson), Some("message" -> t.message.asJson), Some("object" -> t.`object`.asJson), Some("type" -> t.`type`.asJson), Some("tagger" -> t.tagger.asJson) ).flatten) } implicit def decodeGithubTagSummary: Decoder[TagSummary] = Decoder.instance { c => for { name <- c.downField("name").as[String] commit <- c.downField("commit").as[io.flow.github.v0.models.CommitSummary] } yield { TagSummary( name = name, commit = commit ) } } implicit def encodeGithubTagSummary: Encoder[TagSummary] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("commit" -> t.commit.asJson) ).flatten) } implicit def decodeGithubTagger: Decoder[Tagger] = Decoder.instance { c => for { name <- c.downField("name").as[String] email <- c.downField("email").as[String] date <- c.downField("date").as[_root_.java.time.Instant] } yield { Tagger( name = name, email = email, date = date ) } } implicit def encodeGithubTagger: Encoder[Tagger] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), Some("email" -> t.email.asJson), Some("date" -> t.date.asJson) ).flatten) } implicit def decodeGithubTree: Decoder[Tree] = Decoder.instance { c => for { sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] truncated <- c.downField("truncated").as[Boolean] tree <- c.downField("tree").as[Seq[io.flow.github.v0.models.Node]] } yield { Tree( sha = sha, url = url, truncated = truncated, tree = tree ) } } implicit def encodeGithubTree: Encoder[Tree] = Encoder.instance { t => Json.fromFields(Seq( Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson), Some("truncated" -> t.truncated.asJson), Some("tree" -> t.tree.asJson) ).flatten) } implicit def decodeGithubTreeForm: Decoder[TreeForm] = Decoder.instance { c => for { path <- c.downField("path").as[String] mode <- c.downField("mode").as[String] __type__ <- c.downField("type").as[io.flow.github.v0.models.NodeType] sha <- c.downField("sha").as[Option[String]] content <- c.downField("content").as[Option[String]] } yield { TreeForm( path = path, mode = mode, `type` = __type__, sha = sha, content = content ) } } implicit def encodeGithubTreeForm: Encoder[TreeForm] = Encoder.instance { t => Json.fromFields(Seq( Some("path" -> t.path.asJson), Some("mode" -> t.mode.asJson), Some("type" -> t.`type`.asJson), t.sha.map(t => "sha" -> t.asJson), t.content.map(t => "content" -> t.asJson) ).flatten) } implicit def decodeGithubTreeResult: Decoder[TreeResult] = Decoder.instance { c => for { path <- c.downField("path").as[String] mode <- c.downField("mode").as[String] __type__ <- c.downField("type").as[io.flow.github.v0.models.NodeType] size <- c.downField("size").as[Long] sha <- c.downField("sha").as[String] url <- c.downField("url").as[String] } yield { TreeResult( path = path, mode = mode, `type` = __type__, size = size, sha = sha, url = url ) } } implicit def encodeGithubTreeResult: Encoder[TreeResult] = Encoder.instance { t => Json.fromFields(Seq( Some("path" -> t.path.asJson), Some("mode" -> t.mode.asJson), Some("type" -> t.`type`.asJson), Some("size" -> t.size.asJson), Some("sha" -> t.sha.asJson), Some("url" -> t.url.asJson) ).flatten) } implicit def decodeGithubTreeSummary: Decoder[TreeSummary] = Decoder.instance { c => for { url <- c.downField("url").as[String] sha <- c.downField("sha").as[String] } yield { TreeSummary( url = url, sha = sha ) } } implicit def encodeGithubTreeSummary: Encoder[TreeSummary] = Encoder.instance { t => Json.fromFields(Seq( Some("url" -> t.url.asJson), Some("sha" -> t.sha.asJson) ).flatten) } implicit def decodeGithubUnprocessableEntity: Decoder[UnprocessableEntity] = Decoder.instance { c => for { message <- c.downField("message").as[String] errors <- c.downField("errors").as[Option[Seq[io.flow.github.v0.models.Error]]] } yield { UnprocessableEntity( message = message, errors = errors ) } } implicit def encodeGithubUnprocessableEntity: Encoder[UnprocessableEntity] = Encoder.instance { t => Json.fromFields(Seq( Some("message" -> t.message.asJson), t.errors.map(t => "errors" -> t.asJson) ).flatten) } implicit def decodeGithubUser: Decoder[User] = Decoder.instance { c => for { id <- c.downField("id").as[Long] login <- c.downField("login").as[String] name <- c.downField("name").as[Option[String]] email <- c.downField("email").as[Option[String]] avatarUrl <- c.downField("avatar_url").as[Option[String]] gravatarId <- c.downField("gravatar_id").as[Option[String]] url <- c.downField("url").as[String] htmlUrl <- c.downField("html_url").as[String] __type__ <- c.downField("type").as[io.flow.github.v0.models.OwnerType] } yield { User( id = id, login = login, name = name, email = email, avatarUrl = avatarUrl, gravatarId = gravatarId, url = url, htmlUrl = htmlUrl, `type` = __type__ ) } } implicit def encodeGithubUser: Encoder[User] = Encoder.instance { t => Json.fromFields(Seq( Some("id" -> t.id.asJson), Some("login" -> t.login.asJson), t.name.map(t => "name" -> t.asJson), t.email.map(t => "email" -> t.asJson), t.avatarUrl.map(t => "avatar_url" -> t.asJson), t.gravatarId.map(t => "gravatar_id" -> t.asJson), Some("url" -> t.url.asJson), Some("html_url" -> t.htmlUrl.asJson), Some("type" -> t.`type`.asJson) ).flatten) } implicit def decodeGithubUserEmail: Decoder[UserEmail] = Decoder.instance { c => for { email <- c.downField("email").as[String] verified <- c.downField("verified").as[Boolean] primary <- c.downField("primary").as[Boolean] } yield { UserEmail( email = email, verified = verified, primary = primary ) } } implicit def encodeGithubUserEmail: Encoder[UserEmail] = Encoder.instance { t => Json.fromFields(Seq( Some("email" -> t.email.asJson), Some("verified" -> t.verified.asJson), Some("primary" -> t.primary.asJson) ).flatten) } } }