+ var creator: nullable User is writable
+
+ # Due time as String (if any).
+ var due_on: nullable String is writable
+
+ # Last update time as String (if any).
+ var updated_at: nullable String is writable
+
+ # Close time as String (if any).
+ var closed_at: nullable String is writable
+end
+
+# A Github comment
+#
+# There is two kinds of comments:
+#
+# * `CommitComment` are made on a commit page.
+# * `IssueComment` are made on an issue or pull request page.
+# * `PullComment` are made on the diff associated to a pull request.
+abstract class Comment
+ serialize
+
+ # Identifier of this comment.
+ var id: Int is writable
+
+ # User that made this comment.
+ var user: User is writable
+
+ # Creation time as String.
+ var created_at: String is writable
+
+ # Last update time as String (if any).
+ var updated_at: nullable String is writable
+
+ # Comment body text.
+ var body: String is writable
+
+ # Does the comment contain an acknowledgement (+1)
+ fun is_ack: Bool do
+ return body.has("\\+1\\b".to_re) or body.has(":+1:") or body.has(":shipit:")
+ end
+end
+
+# A comment made on a commit.
+class CommitComment
+ super Comment
+ serialize
+
+ # Commented commit.
+ var commit_id: String is writable
+
+ # Position of the comment on the line.
+ var position: nullable Int is writable
+
+ # Line of the comment.
+ var line: nullable Int is writable
+
+ # Path of the commented file.
+ var path: nullable String is writable
+end
+
+# Status of a commit
+#
+# Can contain sub-status for reviews, CI etc.
+class CommitStatus
+ serialize
+
+ # Global state of this commit
+ var state: nullable String = null is optional, writable
+
+ # Sha of the commit this status is for
+ var sha: nullable String = null is optional, writable
+
+ # Repository the commit belongs to
+ var repository: nullable Repo = null is optional, writable
+
+ # All sub statuses (one for each check)
+ var statuses = new Array[RepoStatus] is optional, writable
+
+ # Total count of sub statuses
+ var total_count: nullable Int = null is optional, writable
+end
+
+# Sub status of a CommitStatus
+#
+# Represents a check applied to a commit (reviews, CI, ...).
+class RepoStatus
+ serialize
+
+ # State of this check
+ var state: nullable String = null is optional, writable
+
+ # Description of this check
+ var description: nullable String = null is optional, writable
+
+ # External URL
+ var target_url: nullable String = null is optional, writable
+
+ # Context this status is related to
+ #
+ # Used to hold the name of the check applied.
+ var context: nullable String = null is optional, writable
+
+ # Date when this status was created
+ var created_at: nullable String = null is optional, writable
+
+ # Last date this status was updated
+ var updated_at: nullable String = null is optional, writable
+end
+
+# Comments made on Github issue and pull request pages.
+#
+# Should be accessed from `GithubAPI::get_issue_comment`.
+#
+# See <https://developer.github.com/v3/issues/comments/>.
+class IssueComment
+ super Comment
+ serialize
+
+ # Issue that contains `self`.
+ fun issue_number: Int do return issue_url.split("/").last.to_i
+
+ # Link to the issue document on API.
+ var issue_url: String is writable
+end
+
+# Comments made on Github pull request diffs.
+#
+# Should be accessed from `GithubAPI::get_diff_comment`.
+#
+# See <https://developer.github.com/v3/pulls/comments/>.
+class PullComment
+ super Comment
+ serialize
+
+ # Pull request that contains `self`.
+ fun pull_number: Int do return pull_request_url.split("/").last.to_i
+
+ # Link to the pull request on API.
+ var pull_request_url: String is writable
+
+ # Diff hunk.
+ var diff_hunk: String is writable
+
+ # Path of commented file.
+ var path: String is writable
+
+ # Position of the comment on the file.
+ var position: nullable Int is writable
+
+ # Original position in the diff.
+ var original_position: Int is writable
+
+ # Commit referenced by this comment.
+ var commit_id: String is writable
+
+ # Original commit id.
+ var original_commit_id: String is writable
+end
+
+# An event that occurs on a Github `Issue`.
+#
+# Should be accessed from `GithubAPI::get_issue_event`.
+#
+# See <https://developer.github.com/v3/issues/events/>.
+class IssueEvent
+ serialize
+
+ # Event id on Github.
+ var id: Int is writable
+
+ # User that initiated the event.
+ var actor: User is writable
+
+ # Creation time as String.
+ var created_at: String is writable
+
+ # Event descriptor.
+ var event: String is writable
+
+ # Commit linked to this event (if any).
+ var commit_id: nullable String is writable
+
+ # Label linked to this event (if any).
+ var labl: nullable Label is writable, serialize_as("label")
+
+ # User linked to this event (if any).
+ var assignee: nullable User is writable
+
+ # Milestone linked to this event (if any).
+ var milestone: nullable Milestone is writable
+
+ # Rename linked to this event (if any).
+ var rename: nullable RenameAction is writable
+end
+
+# A rename action maintains the name before and after a renaming action.
+class RenameAction
+ serialize
+
+ # Name before renaming.
+ var from: String is writable
+
+ # Name after renaming.
+ var to: String is writable
+end
+
+#
+# Should be accessed from `Repo::contrib_stats`.
+#
+# See <https://developer.github.com/v3/repos/statistics/>.
+class ContributorStats
+ super Comparable
+ serialize
+
+ redef type OTHER: ContributorStats
+
+ # User these statistics are about.
+ var author: User is writable
+
+ # Total number of commit.
+ var total: Int is writable
+
+ # Array of weeks of activity with detailed statistics.
+ var weeks: Array[ContributorWeek] is writable
+
+ # ContributorStats can be compared on the total amount of commits.
+ redef fun <(o) do return total < o.total
+end
+
+# Contributor stats weekly hash
+class ContributorWeek
+ serialize
+
+ # Start of week given a Unix timestamp
+ var w: Int
+
+ # Number of additions
+ var a: Int
+
+ # Number of deletions
+ var d: Int
+
+ # Number of commits
+ var c: Int
+end
+
+# A Github file representation.
+#
+# Mostly a wrapper around a json object.
+class GithubFile
+ serialize
+
+ # File name.
+ var filename: String is writable
+end
+
+# A list of results returned buy `/search`
+class SearchResults
+ serialize
+
+ # Total count with other pages
+ var total_count: Int
+
+ # Does this page contain all the results?
+ var incomplete_results: Bool
+
+ # Results in this page
+ var items: Array[Object]
+end
+
+# JsonDeserializer specific for Github objects.
+class GithubDeserializer
+ super JsonDeserializer
+
+ private var pattern_base = "https://api.github.com"
+
+ # Url patterns to class names
+ var url_patterns: Map[Regex, String] is lazy do
+ var map = new HashMap[Regex, String]
+ map["{pattern_base}/users/[^/]*$".to_re] = "User"
+ map["{pattern_base}/repos/[^/]*/[^/]*$".to_re] = "Repo"
+ map["{pattern_base}/repos/[^/]*/[^/]*/labels/[^/]+$".to_re] = "Label"
+ map["{pattern_base}/repos/[^/]*/[^/]*/milestones/[0-9]+$".to_re] = "Milestone"
+ map["{pattern_base}/repos/[^/]*/[^/]*/issues/[0-9]+$".to_re] = "Issue"
+ map["{pattern_base}/repos/[^/]*/[^/]*/issues/comments/[0-9]+$".to_re] = "IssueComment"
+ map["{pattern_base}/repos/[^/]*/[^/]*/issues/events/[0-9]+$".to_re] = "IssueEvent"
+ map["{pattern_base}/repos/[^/]*/[^/]*/pulls/[0-9]+$".to_re] = "PullRequest"
+ map["{pattern_base}/repos/[^/]*/[^/]*/pulls/comments/[0-9]+$".to_re] = "PullComment"
+ map["{pattern_base}/repos/[^/]*/[^/]*/comments/[0-9]+$".to_re] = "CommitComment"
+ map["{pattern_base}/repos/[^/]*/[^/]*/commits/[a-f0-9]+$".to_re] = "Commit"
+ map["{pattern_base}/repos/[^/]*/[^/]*/commits/[a-f0-9]+/status$".to_re] = "CommitStatus"
+ map["{pattern_base}/repos/[^/]*/[^/]*/statuses/[a-f0-9]+$".to_re] = "RepoStatus"
+ return map