From eb9c112c032449e9a0b42fdabf54d676cde7351a Mon Sep 17 00:00:00 2001 From: Ehsan Mirsaeedi Date: Wed, 7 Nov 2018 07:18:21 -0500 Subject: [PATCH] Add Author Association for comments related models (#1877) * Add Author Association for comments related models * remove optional AuthorAssociation from constructors * tidy up whitespace/formatting --- Octokit/Models/Common/AuthorAssociation.cs | 52 +++++++++++++++++++ Octokit/Models/Response/IssueComment.cs | 8 ++- Octokit/Models/Response/PullRequestReview.cs | 8 ++- .../Response/PullRequestReviewComment.cs | 8 ++- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 Octokit/Models/Common/AuthorAssociation.cs diff --git a/Octokit/Models/Common/AuthorAssociation.cs b/Octokit/Models/Common/AuthorAssociation.cs new file mode 100644 index 00000000..2661c6d4 --- /dev/null +++ b/Octokit/Models/Common/AuthorAssociation.cs @@ -0,0 +1,52 @@ +using Octokit.Internal; + +namespace Octokit +{ + /// + /// States of a Team/Organization Membership + /// + public enum AuthorAssociation + { + /// + /// Author has been invited to collaborate on the repository. + /// + [Parameter(Value = "COLLABORATOR")] + Collaborator, + + /// + /// Author has previously committed to the repository. + /// + [Parameter(Value = "CONTRIBUTOR")] + Contributor, + + /// + /// Author has not previously committed to GitHub. + /// + [Parameter(Value = "FIRST_TIMER")] + FirstTimer, + + /// + /// Author has not previously committed to the repository. + /// + [Parameter(Value = "FIRST_TIME_CONTRIBUTOR")] + FirstTimeContributor, + + /// + /// Author is a member of the organization that owns the repository. + /// + [Parameter(Value = "MEMBER")] + Member, + + /// + /// Author is the owner of the repository. + /// + [Parameter(Value = "OWNER")] + Owner, + + /// + /// Author has no association with the repository. + /// + [Parameter(Value = "NONE")] + None + } +} diff --git a/Octokit/Models/Response/IssueComment.cs b/Octokit/Models/Response/IssueComment.cs index 989fe65e..9ef576f8 100644 --- a/Octokit/Models/Response/IssueComment.cs +++ b/Octokit/Models/Response/IssueComment.cs @@ -10,7 +10,7 @@ namespace Octokit { public IssueComment() { } - public IssueComment(int id, string nodeId, string url, string htmlUrl, string body, DateTimeOffset createdAt, DateTimeOffset? updatedAt, User user, ReactionSummary reactions) + public IssueComment(int id, string nodeId, string url, string htmlUrl, string body, DateTimeOffset createdAt, DateTimeOffset? updatedAt, User user, ReactionSummary reactions, AuthorAssociation authorAssociation) { Id = id; NodeId = nodeId; @@ -21,6 +21,7 @@ namespace Octokit UpdatedAt = updatedAt; User = user; Reactions = reactions; + AuthorAssociation = authorAssociation; } /// @@ -63,6 +64,11 @@ namespace Octokit /// public User User { get; protected set; } + /// + /// The comment author association with repository. + /// + public StringEnum AuthorAssociation { get; protected set; } + /// /// The reaction summary for this comment. /// diff --git a/Octokit/Models/Response/PullRequestReview.cs b/Octokit/Models/Response/PullRequestReview.cs index e6e1d33c..4334b2a2 100644 --- a/Octokit/Models/Response/PullRequestReview.cs +++ b/Octokit/Models/Response/PullRequestReview.cs @@ -15,7 +15,7 @@ namespace Octokit Id = id; } - public PullRequestReview(long id, string nodeId, string commitId, User user, string body, string htmlUrl, string pullRequestUrl, PullRequestReviewState state) + public PullRequestReview(long id, string nodeId, string commitId, User user, string body, string htmlUrl, string pullRequestUrl, PullRequestReviewState state, AuthorAssociation authorAssociation) { Id = id; NodeId = nodeId; @@ -25,6 +25,7 @@ namespace Octokit HtmlUrl = htmlUrl; PullRequestUrl = pullRequestUrl; State = state; + AuthorAssociation = authorAssociation; } /// @@ -67,6 +68,11 @@ namespace Octokit /// public string PullRequestUrl { get; protected set; } + /// + /// The comment author association with repository. + /// + public StringEnum AuthorAssociation { get; protected set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0}, State: {1}, User: {2}", Id, State.DebuggerDisplay, User.DebuggerDisplay); } diff --git a/Octokit/Models/Response/PullRequestReviewComment.cs b/Octokit/Models/Response/PullRequestReviewComment.cs index d6a71d42..6f2a9673 100644 --- a/Octokit/Models/Response/PullRequestReviewComment.cs +++ b/Octokit/Models/Response/PullRequestReviewComment.cs @@ -15,7 +15,7 @@ namespace Octokit Id = id; } - public PullRequestReviewComment(string url, int id, string nodeId, string diffHunk, string path, int? position, int? originalPosition, string commitId, string originalCommitId, User user, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, string htmlUrl, string pullRequestUrl, ReactionSummary reactions, int? inReplyToId, int? pullRequestReviewId) + public PullRequestReviewComment(string url, int id, string nodeId, string diffHunk, string path, int? position, int? originalPosition, string commitId, string originalCommitId, User user, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, string htmlUrl, string pullRequestUrl, ReactionSummary reactions, int? inReplyToId, int? pullRequestReviewId, AuthorAssociation authorAssociation) { PullRequestReviewId = pullRequestReviewId; Url = url; @@ -35,6 +35,7 @@ namespace Octokit PullRequestUrl = pullRequestUrl; Reactions = reactions; InReplyToId = inReplyToId; + AuthorAssociation = authorAssociation; } /// @@ -127,6 +128,11 @@ namespace Octokit /// public int? PullRequestReviewId { get; protected set; } + /// + /// The comment author association with repository. + /// + public StringEnum AuthorAssociation { get; protected set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0}, Path: {1}, User: {2}, Url: {3}", Id, Path, User.DebuggerDisplay, Url); }