+ fun path: String do return json["path"].as(String)
+end
+
+# Comments made on Github issue and pull request pages.
+#
+# Should be accessed from `GithubAPI::load_issue_comment`.
+#
+# See <https://developer.github.com/v3/issues/comments/>.
+class IssueComment
+ super Comment
+
+ redef var key is lazy do return "{repo.key}/issues/comments/{id}"
+
+ # Issue that contains `self`.
+ fun issue: Issue do
+ var number = issue_url.split("/").last.to_i
+ return api.load_issue(repo, number).as(not null)
+ end
+
+ # Link to the issue document on API.
+ fun issue_url: String do return json["issue_url"].as(String)
+end
+
+# Comments made on Github pull request diffs.
+#
+# Should be accessed from `GithubAPI::load_diff_comment`.
+#
+# See <https://developer.github.com/v3/pulls/comments/>.
+class ReviewComment
+ super Comment
+
+ redef var key is lazy do return "{repo.key}/pulls/comments/{id}"
+
+ # Pull request that contains `self`.
+ fun pull: PullRequest do
+ var number = pull_request_url.split("/").last.to_i
+ return api.load_pull(repo, number).as(not null)
+ end
+
+ # Link to the pull request on API.
+ fun pull_request_url: String do return json["pull_request_url"].as(String)
+
+ # Diff hunk.
+ fun diff_hunk: String do return json["diff_hunk"].as(String)
+
+ # Path of commented file.
+ fun path: String do return json["path"].as(String)
+
+ # Position of the comment on the file.
+ fun position: Int do return json["position"].as(Int)
+
+ # Original position in the diff.
+ fun original_position: Int do return json["original_position"].as(Int)
+
+ # Commit referenced by this comment.
+ fun commit_id: String do return json["commit_id"].as(String)
+
+ # Original commit id.
+ fun original_commit_id: String do return json["original_commit_id"].as(String)
+end
+
+# An event that occurs on a Github `Issue`.
+#
+# Should be accessed from `GithubAPI::load_issue_event`.
+#
+# See <https://developer.github.com/v3/issues/events/>.
+class IssueEvent
+ super RepoEntity
+
+ redef var key is lazy do return "{repo.key}/issues/events/{id}"
+
+ # Event id on Github.
+ var id: Int
+
+ redef init from_json(api, repo, json) do
+ self.id = json["id"].as(Int)
+ super
+ end
+
+ # Issue that contains `self`.
+ fun issue: Issue do
+ return new Issue.from_json(api, repo, json["issue"].as(JsonObject))
+ end
+
+ # User that initiated the event.
+ fun actor: User do
+ return new User.from_json(api, json["actor"].as(JsonObject))
+ end
+
+ # Creation time in ISODate format.
+ fun created_at: ISODate do
+ return new ISODate.from_string(json["created_at"].as(String))
+ end
+
+ # Event descriptor.
+ fun event: String do return json["event"].as(String)
+
+ # Commit linked to this event (if any).
+ fun commit_id: nullable String do
+ var res = json.get_or_null("commit_id")
+ if res isa String then return res
+ return null
+ end
+
+ # Label linked to this event (if any).
+ fun labl: nullable Label do
+ var res = json.get_or_null("label")
+ if res isa JsonObject then return new Label.from_json(api, repo, res)
+ return null
+ end
+
+ # User linked to this event (if any).
+ fun assignee: nullable User do
+ var res = json.get_or_null("assignee")
+ if res isa JsonObject then return new User.from_json(api, res)
+ return null
+ end
+
+ # Milestone linked to this event (if any).
+ fun milestone: nullable Milestone do
+ var res = json.get_or_null("milestone")
+ if res isa JsonObject then return new Milestone.from_json(api, repo, res)
+ return null
+ end
+
+ # Rename linked to this event (if any).
+ fun rename: nullable RenameAction do
+ var res = json.get_or_null("rename")
+ if res isa JsonObject then return new RenameAction(res)
+ return null
+ end
+end
+
+# A rename action maintains the name before and after a renaming action.
+class RenameAction
+
+ # JSON content.
+ var json: JsonObject
+
+ # Name before renaming.
+ fun from: String do return json["from"].as(String)
+
+ # Name after renaming.
+ fun to: String do return json["to"].as(String)
+end
+
+# Contributors list with additions, deletions, and commit counts.
+#
+# Should be accessed from `Repo::contrib_stats`.
+#
+# See <https://developer.github.com/v3/repos/statistics/>.
+class ContributorStats
+ super Comparable
+
+ redef type OTHER: ContributorStats
+
+ # Github API client.
+ var api: GithubAPI
+
+ # Json content.
+ var json: JsonObject
+
+ # Init `self` from a `json` object.
+ init from_json(api: GithubAPI, json: JsonObject) do
+ self.api = api
+ self.json = json
+ end
+
+ # User these statistics are about.
+ fun author: User do
+ return new User.from_json(api, json["author"].as(JsonObject))
+ end
+
+ # Total number of commit.
+ fun total: Int do return json["total"].as(Int)
+
+ # Are of weeks of activity with detailed statistics.
+ fun weeks: JsonArray do return json["weeks"].as(JsonArray)
+
+ # ContributorStats can be compared on the total amount of commits.
+ redef fun <(o) do return total < o.total
+end
+
+# A Github file representation.
+#
+# Mostly a wrapper around a json object.
+class GithubFile
+
+ # Json content.
+ var json: JsonObject
+
+ # File name.
+ fun filename: String do return json["filename"].as(String)