Repository: google/go-github
Pull request #1548 (2020-05-31 16:04:06)

Add missing fields to user and org types
I noticed that there were a few fields in the `User` and `Organization` responses from GitHub that weren't in the types defined here.

https://developer.github.com/v3/users/
https://developer.github.com/v3/orgs/

For both: twitter_username
For orgs: is_verified, has_organization_projects, has_repository_projects

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=h1) Report
> Merging [#1548](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=desc) into [master](https://codecov.io/gh/google/go-github/commit/407d73650d4bff607beaf8fb7a69eb9e9987af02&el=desc) will **increase** coverage by `5.17%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1548/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1548      +/-   ##
==========================================
+ Coverage   67.92%   73.10%   +5.17%     
==========================================
  Files          94       94              
  Lines        8670     6978    -1692     
==========================================
- Hits         5889     5101     -788     
+ Misses       1880      976     -904     
  Partials      901      901              
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/orgs.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL29yZ3MuZ28=) | `74.68% <ø> (+4.98%)` | :arrow_up: |
| [github/users.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL3VzZXJzLmdv) | `62.35% <ø> (+8.95%)` | :arrow_up: |
| [github/github.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL2dpdGh1Yi5nbw==) | `89.62% <0.00%> (-0.03%)` | :arrow_down: |
| [github/admin.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL2FkbWluLmdv) | `100.00% <0.00%> (ø)` | |
| [github/strings.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL3N0cmluZ3MuZ28=) | `100.00% <0.00%> (ø)` | |
| [github/activity.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL2FjdGl2aXR5Lmdv) | `100.00% <0.00%> (ø)` | |
| [github/timestamp.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL3RpbWVzdGFtcC5nbw==) | `100.00% <0.00%> (ø)` | |
| [github/admin\_stats.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL2FkbWluX3N0YXRzLmdv) | `100.00% <0.00%> (ø)` | |
| [github/repos\_traffic.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL3JlcG9zX3RyYWZmaWMuZ28=) | `100.00% <0.00%> (ø)` | |
| [github/pulls\_reviewers.go](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree#diff-Z2l0aHViL3B1bGxzX3Jldmlld2Vycy5nbw==) | `100.00% <0.00%> (ø)` | |
| ... and [83 more](https://codecov.io/gh/google/go-github/pull/1548/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=footer). Last update [407d736...14b0f10](https://codecov.io/gh/google/go-github/pull/1548?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 4489e4dc..a344a557 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -6692,6 +6692,22 @@ func (o *Organization) GetFollowing() int {
 	return *o.Following
 }
 
+// GetHasOrganizationProjects returns the HasOrganizationProjects field if it's non-nil, zero value otherwise.
+func (o *Organization) GetHasOrganizationProjects() bool {
+	if o == nil || o.HasOrganizationProjects == nil {
+		return false
+	}
+	return *o.HasOrganizationProjects
+}
+
+// GetHasRepositoryProjects returns the HasRepositoryProjects field if it's non-nil, zero value otherwise.
+func (o *Organization) GetHasRepositoryProjects() bool {
+	if o == nil || o.HasRepositoryProjects == nil {
+		return false
+	}
+	return *o.HasRepositoryProjects
+}
+
 // GetHooksURL returns the HooksURL field if it's non-nil, zero value otherwise.
 func (o *Organization) GetHooksURL() string {
 	if o == nil || o.HooksURL == nil {
@@ -6724,6 +6740,14 @@ func (o *Organization) GetIssuesURL() string {
 	return *o.IssuesURL
 }
 
+// GetIsVerified returns the IsVerified field if it's non-nil, zero value otherwise.
+func (o *Organization) GetIsVerified() bool {
+	if o == nil || o.IsVerified == nil {
+		return false
+	}
+	return *o.IsVerified
+}
+
 // GetLocation returns the Location field if it's non-nil, zero value otherwise.
 func (o *Organization) GetLocation() string {
 	if o == nil || o.Location == nil {
@@ -6868,6 +6892,14 @@ func (o *Organization) GetTotalPrivateRepos() int {
 	return *o.TotalPrivateRepos
 }
 
+// GetTwitterUsername returns the TwitterUsername field if it's non-nil, zero value otherwise.
+func (o *Organization) GetTwitterUsername() string {
+	if o == nil || o.TwitterUsername == nil {
+		return ""
+	}
+	return *o.TwitterUsername
+}
+
 // GetTwoFactorRequirementEnabled returns the TwoFactorRequirementEnabled field if it's non-nil, zero value otherwise.
 func (o *Organization) GetTwoFactorRequirementEnabled() bool {
 	if o == nil || o.TwoFactorRequirementEnabled == nil {
@@ -13484,6 +13516,14 @@ func (u *User) GetTotalPrivateRepos() int {
 	return *u.TotalPrivateRepos
 }
 
+// GetTwitterUsername returns the TwitterUsername field if it's non-nil, zero value otherwise.
+func (u *User) GetTwitterUsername() string {
+	if u == nil || u.TwitterUsername == nil {
+		return ""
+	}
+	return *u.TwitterUsername
+}
+
 // GetTwoFactorAuthentication returns the TwoFactorAuthentication field if it's non-nil, zero value otherwise.
 func (u *User) GetTwoFactorAuthentication() bool {
 	if u == nil || u.TwoFactorAuthentication == nil {
diff --git a/github/orgs.go b/github/orgs.go
index 564231bc..4065b014 100644
--- a/github/orgs.go
+++ b/github/orgs.go
@@ -29,6 +29,7 @@ type Organization struct {
 	Blog                        *string    `json:"blog,omitempty"`
 	Location                    *string    `json:"location,omitempty"`
 	Email                       *string    `json:"email,omitempty"`
+	TwitterUsername             *string    `json:"twitter_username,omitempty"`
 	Description                 *string    `json:"description,omitempty"`
 	PublicRepos                 *int       `json:"public_repos,omitempty"`
 	PublicGists                 *int       `json:"public_gists,omitempty"`
@@ -45,6 +46,9 @@ type Organization struct {
 	Type                        *string    `json:"type,omitempty"`
 	Plan                        *Plan      `json:"plan,omitempty"`
 	TwoFactorRequirementEnabled *bool      `json:"two_factor_requirement_enabled,omitempty"`
+	IsVerified                  *bool      `json:"is_verified,omitempty"`
+	HasOrganizationProjects     *bool      `json:"has_organization_projects,omitempty"`
+	HasRepositoryProjects       *bool      `json:"has_repository_projects,omitempty"`
 
 	// DefaultRepoPermission can be one of: "read", "write", "admin", or "none". (Default: "read").
 	// It is only used in OrganizationsService.Edit.
diff --git a/github/users.go b/github/users.go
index 97747f71..1db2d323 100644
--- a/github/users.go
+++ b/github/users.go
@@ -31,6 +31,7 @@ type User struct {
 	Email                   *string    `json:"email,omitempty"`
 	Hireable                *bool      `json:"hireable,omitempty"`
 	Bio                     *string    `json:"bio,omitempty"`
+	TwitterUsername         *string    `json:"twitter_username,omitempty"`
 	PublicRepos             *int       `json:"public_repos,omitempty"`
 	PublicGists             *int       `json:"public_gists,omitempty"`
 	Followers               *int       `json:"followers,omitempty"`


Test patch:
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index df474203..96d2baf2 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -854,6 +854,7 @@ func TestOrganization_String(t *testing.T) {
 		Blog:                                 String(""),
 		Location:                             String(""),
 		Email:                                String(""),
+		TwitterUsername:                      String(""),
 		Description:                          String(""),
 		PublicRepos:                          Int(0),
 		PublicGists:                          Int(0),
@@ -868,6 +869,9 @@ func TestOrganization_String(t *testing.T) {
 		Type:                                 String(""),
 		Plan:                                 &Plan{},
 		TwoFactorRequirementEnabled:          Bool(false),
+		IsVerified:                           Bool(false),
+		HasOrganizationProjects:              Bool(false),
+		HasRepositoryProjects:                Bool(false),
 		DefaultRepoPermission:                String(""),
 		DefaultRepoSettings:                  String(""),
 		MembersCanCreateRepos:                Bool(false),
@@ -883,7 +887,7 @@ func TestOrganization_String(t *testing.T) {
 		PublicMembersURL:                     String(""),
 		ReposURL:                             String(""),
 	}
-	want := `github.Organization{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Description:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, BillingEmail:"", Type:"", Plan:github.Plan{}, TwoFactorRequirementEnabled:false, DefaultRepoPermission:"", DefaultRepoSettings:"", MembersCanCreateRepos:false, MembersCanCreatePublicRepos:false, MembersCanCreatePrivateRepos:false, MembersCanCreateInternalRepos:false, MembersAllowedRepositoryCreationType:"", URL:"", EventsURL:"", HooksURL:"", IssuesURL:"", MembersURL:"", PublicMembersURL:"", ReposURL:""}`
+	want := `github.Organization{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", Name:"", Company:"", Blog:"", Location:"", Email:"", TwitterUsername:"", Description:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, BillingEmail:"", Type:"", Plan:github.Plan{}, TwoFactorRequirementEnabled:false, IsVerified:false, HasOrganizationProjects:false, HasRepositoryProjects:false, DefaultRepoPermission:"", DefaultRepoSettings:"", MembersCanCreateRepos:false, MembersCanCreatePublicRepos:false, MembersCanCreatePrivateRepos:false, MembersCanCreateInternalRepos:false, MembersAllowedRepositoryCreationType:"", URL:"", EventsURL:"", HooksURL:"", IssuesURL:"", MembersURL:"", PublicMembersURL:"", ReposURL:""}`
 	if got := v.String(); got != want {
 		t.Errorf("Organization.String = %v, want %v", got, want)
 	}
@@ -1555,6 +1559,7 @@ func TestUser_String(t *testing.T) {
 		Email:                   String(""),
 		Hireable:                Bool(false),
 		Bio:                     String(""),
+		TwitterUsername:         String(""),
 		PublicRepos:             Int(0),
 		PublicGists:             Int(0),
 		Followers:               Int(0),
@@ -1583,7 +1588,7 @@ func TestUser_String(t *testing.T) {
 		StarredURL:              String(""),
 		SubscriptionsURL:        String(""),
 	}
-	want := `github.User{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", GravatarID:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Hireable:false, Bio:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Type:"", SiteAdmin:false, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, TwoFactorAuthentication:false, Plan:github.Plan{}, LdapDn:"", URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:""}`
+	want := `github.User{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", GravatarID:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Hireable:false, Bio:"", TwitterUsername:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Type:"", SiteAdmin:false, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, TwoFactorAuthentication:false, Plan:github.Plan{}, LdapDn:"", URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:""}`
 	if got := v.String(); got != want {
 		t.Errorf("User.String = %v, want %v", got, want)
 	}
diff --git a/github/orgs_test.go b/github/orgs_test.go
index cf69453c..e60a01f6 100644
--- a/github/orgs_test.go
+++ b/github/orgs_test.go
@@ -22,9 +22,13 @@ func TestOrganization_marshal(t *testing.T) {
 		Blog:                                 String("https://github.com/blog"),
 		Company:                              String("GitHub"),
 		Email:                                String("support@github.com"),
+		TwitterUsername:                      String("github"),
 		Location:                             String("San Francisco"),
 		Name:                                 String("github"),
 		Description:                          String("GitHub, the company."),
+		IsVerified:                           Bool(true),
+		HasOrganizationProjects:              Bool(true),
+		HasRepositoryProjects:                Bool(true),
 		DefaultRepoPermission:                String("read"),
 		MembersCanCreateRepos:                Bool(true),
 		MembersCanCreateInternalRepos:        Bool(true),
@@ -38,9 +42,13 @@ func TestOrganization_marshal(t *testing.T) {
 			"blog": "https://github.com/blog",
 			"company": "GitHub",
 			"email": "support@github.com",
+			"twitter_username": "github",
 			"location": "San Francisco",
 			"name": "github",
 			"description": "GitHub, the company.",
+			"is_verified": true,
+			"has_organization_projects": true,
+			"has_repository_projects": true,
 			"default_repository_permission": "read",
 			"members_can_create_repositories": true,
 			"members_can_create_public_repositories": false,
diff --git a/github/users_test.go b/github/users_test.go
index d1ce7e39..e97e8e1b 100644
--- a/github/users_test.go
+++ b/github/users_test.go
@@ -18,22 +18,24 @@ func TestUser_marshall(t *testing.T) {
 	testJSONMarshal(t, &User{}, "{}")
 
 	u := &User{
-		Login:       String("l"),
-		ID:          Int64(1),
-		URL:         String("u"),
-		AvatarURL:   String("a"),
-		GravatarID:  String("g"),
-		Name:        String("n"),
-		Company:     String("c"),
-		Blog:        String("b"),
-		Location:    String("l"),
-		Email:       String("e"),
-		Hireable:    Bool(true),
-		PublicRepos: Int(1),
-		Followers:   Int(1),
-		Following:   Int(1),
-		CreatedAt:   &Timestamp{referenceTime},
-		SuspendedAt: &Timestamp{referenceTime},
+		Login:           String("l"),
+		ID:              Int64(1),
+		URL:             String("u"),
+		AvatarURL:       String("a"),
+		GravatarID:      String("g"),
+		Name:            String("n"),
+		Company:         String("c"),
+		Blog:            String("b"),
+		Location:        String("l"),
+		Email:           String("e"),
+		Hireable:        Bool(true),
+		Bio:             String("b"),
+		TwitterUsername: String("t"),
+		PublicRepos:     Int(1),
+		Followers:       Int(1),
+		Following:       Int(1),
+		CreatedAt:       &Timestamp{referenceTime},
+		SuspendedAt:     &Timestamp{referenceTime},
 	}
 	want := `{
 		"login": "l",
@@ -46,6 +48,8 @@ func TestUser_marshall(t *testing.T) {
 		"location": "l",
 		"email": "e",
 		"hireable": true,
+		"bio": "b",
+		"twitter_username": "t",
 		"public_repos": 1,
 		"followers": 1,
 		"following": 1,