Created
May 27, 2015 12:19
-
-
Save gbougeard/a2eed5c58ca312843a5d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"id": 1, | |
"url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", | |
"html_url": "https://github.com/octocat/Hello-World/pull/1347", | |
"diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", | |
"patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch", | |
"issue_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", | |
"commits_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits", | |
"review_comments_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments", | |
"review_comment_url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/{number}", | |
"comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", | |
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", | |
"number": 1347, | |
"state": "open", | |
"title": "new-feature", | |
"body": "Please pull these awesome changes", | |
"created_at": "2011-01-26T19:01:12Z", | |
"updated_at": "2011-01-26T19:01:12Z", | |
"closed_at": "2011-01-26T19:01:12Z", | |
"merged_at": "2011-01-26T19:01:12Z", | |
"head": { | |
"label": "new-topic", | |
"ref": "new-topic", | |
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", | |
"user": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"repo": { | |
"id": 1296269, | |
"owner": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"name": "Hello-World", | |
"full_name": "octocat/Hello-World", | |
"description": "This your first repo!", | |
"private": false, | |
"fork": false, | |
"url": "https://api.github.com/repos/octocat/Hello-World", | |
"html_url": "https://github.com/octocat/Hello-World", | |
"clone_url": "https://github.com/octocat/Hello-World.git", | |
"git_url": "git://github.com/octocat/Hello-World.git", | |
"ssh_url": "[email protected]:octocat/Hello-World.git", | |
"svn_url": "https://svn.github.com/octocat/Hello-World", | |
"mirror_url": "git://git.example.com/octocat/Hello-World", | |
"homepage": "https://github.com", | |
"language": null, | |
"forks_count": 9, | |
"stargazers_count": 80, | |
"watchers_count": 80, | |
"size": 108, | |
"default_branch": "master", | |
"open_issues_count": 0, | |
"has_issues": true, | |
"has_wiki": true, | |
"has_pages": false, | |
"has_downloads": true, | |
"pushed_at": "2011-01-26T19:06:43Z", | |
"created_at": "2011-01-26T19:01:12Z", | |
"updated_at": "2011-01-26T19:14:43Z", | |
"permissions": { | |
"admin": false, | |
"push": false, | |
"pull": true | |
} | |
} | |
}, | |
"base": { | |
"label": "master", | |
"ref": "master", | |
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", | |
"user": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"repo": { | |
"id": 1296269, | |
"owner": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"name": "Hello-World", | |
"full_name": "octocat/Hello-World", | |
"description": "This your first repo!", | |
"private": false, | |
"fork": false, | |
"url": "https://api.github.com/repos/octocat/Hello-World", | |
"html_url": "https://github.com/octocat/Hello-World", | |
"clone_url": "https://github.com/octocat/Hello-World.git", | |
"git_url": "git://github.com/octocat/Hello-World.git", | |
"ssh_url": "[email protected]:octocat/Hello-World.git", | |
"svn_url": "https://svn.github.com/octocat/Hello-World", | |
"mirror_url": "git://git.example.com/octocat/Hello-World", | |
"homepage": "https://github.com", | |
"language": null, | |
"forks_count": 9, | |
"stargazers_count": 80, | |
"watchers_count": 80, | |
"size": 108, | |
"default_branch": "master", | |
"open_issues_count": 0, | |
"has_issues": true, | |
"has_wiki": true, | |
"has_pages": false, | |
"has_downloads": true, | |
"pushed_at": "2011-01-26T19:06:43Z", | |
"created_at": "2011-01-26T19:01:12Z", | |
"updated_at": "2011-01-26T19:14:43Z", | |
"permissions": { | |
"admin": false, | |
"push": false, | |
"pull": true | |
} | |
} | |
}, | |
"_links": { | |
"self": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347" | |
}, | |
"html": { | |
"href": "https://github.com/octocat/Hello-World/pull/1347" | |
}, | |
"issue": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/issues/1347" | |
}, | |
"comments": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments" | |
}, | |
"review_comments": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments" | |
}, | |
"review_comment": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/{number}" | |
}, | |
"commits": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits" | |
}, | |
"statuses": { | |
"href": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e" | |
} | |
}, | |
"user": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"merge_commit_sha": "e5bd3914e2e596debea16f433f57875b5b90bcd6", | |
"merged": false, | |
"mergeable": true, | |
"merged_by": { | |
"login": "octocat", | |
"id": 1, | |
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | |
"gravatar_id": "", | |
"url": "https://api.github.com/users/octocat", | |
"html_url": "https://github.com/octocat", | |
"followers_url": "https://api.github.com/users/octocat/followers", | |
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | |
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | |
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | |
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | |
"organizations_url": "https://api.github.com/users/octocat/orgs", | |
"repos_url": "https://api.github.com/users/octocat/repos", | |
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | |
"received_events_url": "https://api.github.com/users/octocat/received_events", | |
"type": "User", | |
"site_admin": false | |
}, | |
"comments": 10, | |
"commits": 3, | |
"additions": 100, | |
"deletions": 3, | |
"changed_files": 5 | |
} |
This file contains hidden or 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
package tv.teads.github.api.models | |
import play.api.data.mapping._ | |
import play.api.libs.json.{JsObject, JsValue} | |
trait PullRequestUrlsFormats { | |
implicit lazy val pullRequestUrlsJsonWrite : Write[PullRequestUrls, JsValue] = { | |
import play.api.data.mapping.json.Writes._ | |
Write.gen[PullRequestUrls, JsObject] | |
} | |
implicit lazy val pullRequestUrlsJsonRead = From[JsValue] { __ => | |
import play.api.data.mapping.json.Rules._ | |
( | |
(__ \ "html_url").read[String] ~ | |
(__ \ "diff_url").read[String] ~ | |
(__ \ "patch_url").read[String] ~ | |
(__ \ "issue_url").read[String] ~ | |
(__ \ "commits_url").read[String] ~ | |
(__ \ "review_comments_url").read[String] ~ | |
(__ \ "review_comment_url").read[String] ~ | |
(__ \ "comments_url").read[String] ~ | |
(__ \ "statuses_url").read[String] | |
)(PullRequestUrls.apply _) | |
} | |
} | |
case class PullRequestUrls(html_url: String, | |
diff_url: String, | |
patch_url: String, | |
issue_url: String, | |
commits_url: String, | |
review_comments_url: String, | |
review_comment_url: String, | |
comments_url: String, | |
statuses_url: String) | |
trait TimeMetadataFormats { | |
// implicit lazy val timeMetadataJsonWrite : Write[TimeMetadata, JsValue] = { | |
// import play.api.data.mapping.json.Writes._ | |
// Write.gen[TimeMetadata, JsObject] | |
// } | |
implicit lazy val timeMetadataJsonRead = From[JsValue] { __ => | |
import play.api.data.mapping.json.Rules._ | |
( | |
(__ \ "created_at").read[String] ~ | |
(__ \ "updated_at").read[String] ~ | |
(__ \ "closed_at").read[Option[String]] ~ | |
(__ \ "merged_at").read[Option[String]] ~ | |
(__ \ "merge_commit_sha").read[Option[String]] | |
)(TimeMetadata.apply _) | |
} | |
} | |
case class TimeMetadata(created_at: String, | |
updated_at: String, | |
closed_at: Option[String], | |
merged_at: Option[String], | |
merge_commit_sha: Option[String]) | |
trait ChangeMetadataFormats { | |
// implicit lazy val changeMetadataJsonWrite: Write[ChangeMetadata, JsValue] = { | |
// import play.api.data.mapping.json.Writes._ | |
// Write.gen[ChangeMetadata, JsObject] | |
// } | |
implicit lazy val changeMetadataJsonRead = From[JsValue] { __ => | |
import play.api.data.mapping.json.Rules._ | |
( | |
(__ \ "comments").read[Long] ~ | |
(__ \ "review_comments").read[Long] ~ | |
(__ \ "commits").read[Long] ~ | |
(__ \ "additions").read[Long] ~ | |
(__ \ "review_comments").read[Long] ~ | |
(__ \ "deletions").read[Long] | |
)(ChangeMetadata.apply _) | |
} | |
} | |
case class ChangeMetadata(comments: Long, | |
review_comments: Long, | |
commits: Long, | |
additions: Long, | |
deletions: Long, | |
changed_files: Long | |
) | |
trait PullRequestFormats { | |
self :UserFormats with PullRequestUrlsFormats with PullRequestLinksFormats with TimeMetadataFormats with ChangeMetadataFormats with HeadFormats => | |
// implicit lazy val pullRequestJsonWrite : Write[PullRequest, JsValue] = { | |
// import play.api.data.mapping.json.Writes._ | |
// Write.gen[PullRequest, JsObject] | |
// } | |
implicit lazy val pullRequestJsonRead = From[JsValue]{ __ => | |
import play.api.data.mapping.json.Rules._ | |
( | |
(__ \ "url").read[String] ~ | |
(__ \ "id").read[Long] ~ | |
(__ \ "number").read[Long] ~ | |
(__ \ "state").read[String] ~ | |
(__ \ "locked").read[Boolean] ~ | |
(__ \ "title").read[String] ~ | |
(__ \ "user").read[User] ~ | |
(__ \ "body").read[String] ~ | |
(__ \ "assignee").read[Option[User]] ~ | |
(__ \ "milestone").read[String] ~ | |
(__ \ "head").read[Head] ~ | |
(__ \ "base").read[Head] ~ | |
(__ \ "merged").read[Option[Boolean]] ~ | |
(__ \ "mergeable").read[Option[Boolean]] ~ | |
(__ \ "mergeable_state").read[Option[String]] ~ | |
(__ \ "merged_by").read[Option[User]] ~ | |
(__ \ "_links").read[PullRequestLinks] // I have to combine/add the other readers | |
)(PullRequest.apply _) | |
} | |
} | |
case class PullRequest( | |
url : String, | |
id: Long, | |
number: Long, | |
state: String, | |
locked: Boolean, | |
title: String, | |
user: User, | |
body: String, | |
assignee: Option[User], | |
milestone: String, | |
head: Head, | |
base: Head, | |
merged: Option[Boolean], | |
mergeable: Option[Boolean], | |
mergeable_state: Option[String], | |
merged_by: Option[User], | |
links: PullRequestLinks, | |
urls: PullRequestUrls, | |
timeMetadata: TimeMetadata, | |
changeMetadata: ChangeMetadata | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment