Repository: google/go-github
Pull request #1413 (2020-02-08 21:11:30)

Add the AuthorAssociation field to PullRequestReview
#892 and #802, electric boogaloo.

gmlewis: Thank you, @qaisjp.

As in #892, could you please contact support@github.com and request that they update their examples where appropriate on this page: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
to include this field and report back their response?
qaisjp: sent.

I suspect there will be more places where this is missing, a future PR author can use this canned message:

```
Some of the responses on https://developer.github.com/v3/pulls/reviews/ are missing the `author_association` key, specifically https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request.

The API is returning that info, but it's not documented. Is that a documentation mistake or should `author_association` not actually be in the response?
```

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 72d200be..a17114ec 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -8708,6 +8708,14 @@ func (p *PullRequestMergeResult) GetSHA() string {
 	return *p.SHA
 }
 
+// GetAuthorAssociation returns the AuthorAssociation field if it's non-nil, zero value otherwise.
+func (p *PullRequestReview) GetAuthorAssociation() string {
+	if p == nil || p.AuthorAssociation == nil {
+		return ""
+	}
+	return *p.AuthorAssociation
+}
+
 // GetBody returns the Body field if it's non-nil, zero value otherwise.
 func (p *PullRequestReview) GetBody() string {
 	if p == nil || p.Body == nil {
diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go
index 88b82982..aee49147 100644
--- a/github/pulls_reviews.go
+++ b/github/pulls_reviews.go
@@ -22,6 +22,9 @@ type PullRequestReview struct {
 	HTMLURL        *string    `json:"html_url,omitempty"`
 	PullRequestURL *string    `json:"pull_request_url,omitempty"`
 	State          *string    `json:"state,omitempty"`
+	// AuthorAssociation is the comment author's relationship to the issue's repository.
+	// Possible values are "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".
+	AuthorAssociation *string `json:"author_association,omitempty"`
 }
 
 func (p PullRequestReview) String() string {


Test patch:
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index b156cc1d..a8050964 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -1012,16 +1012,17 @@ func TestPullRequestComment_String(t *testing.T) {
 
 func TestPullRequestReview_String(t *testing.T) {
 	v := PullRequestReview{
-		ID:             Int64(0),
-		NodeID:         String(""),
-		User:           &User{},
-		Body:           String(""),
-		CommitID:       String(""),
-		HTMLURL:        String(""),
-		PullRequestURL: String(""),
-		State:          String(""),
+		ID:                Int64(0),
+		NodeID:            String(""),
+		User:              &User{},
+		Body:              String(""),
+		CommitID:          String(""),
+		HTMLURL:           String(""),
+		PullRequestURL:    String(""),
+		State:             String(""),
+		AuthorAssociation: String(""),
 	}
-	want := `github.PullRequestReview{ID:0, NodeID:"", User:github.User{}, Body:"", CommitID:"", HTMLURL:"", PullRequestURL:"", State:""}`
+	want := `github.PullRequestReview{ID:0, NodeID:"", User:github.User{}, Body:"", CommitID:"", HTMLURL:"", PullRequestURL:"", State:"", AuthorAssociation:""}`
 	if got := v.String(); got != want {
 		t.Errorf("PullRequestReview.String = %v, want %v", got, want)
 	}