Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bio, hireable, and twitter_username fields to Person #838

Merged
merged 3 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public abstract class GHPerson extends GHObject {
protected String login, avatar_url;

// other fields (that only show up in full data)
protected String location, blog, email, name, company, type;
protected String location, blog, email, bio, name, company, type, twitter_username;
protected String html_url;
protected int followers, following, public_repos, public_gists;
protected boolean site_admin;
protected boolean site_admin, hireable;

// other fields (that only show up in full data) that require privileged scope
protected Integer total_private_repos;
Expand Down Expand Up @@ -237,6 +237,18 @@ public String getLocation() throws IOException {
return location;
}

/**
* Gets the Twitter Username of this user, like "GitHub"
*
* @return the Twitter username
* @throws IOException
* the io exception
*/
public String getTwitterUsername() throws IOException {
populate();
return twitter_username;
}

public Date getCreatedAt() throws IOException {
populate();
return super.getCreatedAt();
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/kohsuke/github/GHUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ public boolean isPublicMemberOf(GHOrganization org) {
return org.hasPublicMember(this);
}

/**
* Returns true if this user is marked as hireable, false otherwise
*
* @return if the user is marked as hireable
*/
public boolean isHireable() {
return hireable;
}

public String getBio() {
return bio;
}

static GHUser[] wrap(GHUser[] users, GitHub root) {
for (GHUser f : users)
f.root = root;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/kohsuke/github/GHObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void test_toString() throws Exception {
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
assertThat(org.toString(),
containsString(
"login=hub4j-test-org,location=<null>,blog=<null>,email=<null>,name=<null>,company=<null>,type=Organization,followers=0,following=0"));
"login=hub4j-test-org,location=<null>,blog=<null>,email=<null>,bio=<null>,name=<null>,company=<null>,type=Organization,followers=0,following=0,hireable=false"));

// getResponseHeaderFields is deprecated but we should not break it.
assertThat(org.getResponseHeaderFields(), notNullValue());
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/org/kohsuke/github/GHUserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,12 @@ public void createAndCountPrivateRepos() throws IOException {
repository.delete();
}
}

@Test
public void verifyBioAndHireable() throws IOException {
GHUser u = gitHub.getUser("Chew");
assertThat(u.getBio(), equalTo("I like to program things and I hope to program something cool one day :D"));
assertTrue(u.isHireable());
assertNotNull(u.getTwitterUsername());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"login": "Chew",
"id": 8278263,
"node_id": "MDQ6VXNlcjgyNzgyNjM=",
"avatar_url": "https://avatars3.githubusercontent.com/u/8278263?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Chew",
"html_url": "https://github.com/Chew",
"followers_url": "https://api.github.com/users/Chew/followers",
"following_url": "https://api.github.com/users/Chew/following{/other_user}",
"gists_url": "https://api.github.com/users/Chew/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Chew/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Chew/subscriptions",
"organizations_url": "https://api.github.com/users/Chew/orgs",
"repos_url": "https://api.github.com/users/Chew/repos",
"events_url": "https://api.github.com/users/Chew/events{/privacy}",
"received_events_url": "https://api.github.com/users/Chew/received_events",
"type": "User",
"site_admin": false,
"name": "Olivia",
"company": "@Memerator",
"blog": "https://chew.pw",
"location": null,
"email": null,
"hireable": true,
"bio": "I like to program things and I hope to program something cool one day :D",
"twitter_username": "ChewCraft",
"public_repos": 96,
"public_gists": 4,
"followers": 29,
"following": 3,
"created_at": "2014-07-26T23:41:36Z",
"updated_at": "2020-06-06T20:16:06Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"id": "39860a04-002b-45da-aae7-70c97031c79e",
"name": "users_chew",
"request": {
"url": "/users/Chew",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "users_chew-1.json",
"headers": {
"server": "GitHub.com",
"date": "Sun, 07 Jun 2020 19:58:59 GMT",
"content-type": "application/json; charset=utf-8",
"status": "200 OK",
"cache-control": "public, max-age=60, s-maxage=60",
"vary": "Accept, Accept-Encoding, Accept, X-Requested-With",
"etag": "W/\"960f568b7a2dd1591a136e36748cc44e\"",
"last-modified": "Sat, 06 Jun 2020 20:16:06 GMT",
"x-github-media-type": "unknown, github.v3",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
"x-frame-options": "deny",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"content-security-policy": "default-src 'none'",
"X-Ratelimit-Limit": "60",
"X-Ratelimit-Remaining": "59",
"X-Ratelimit-Reset": "1591563539",
"Accept-Ranges": "bytes",
"X-GitHub-Request-Id": "C2D3:7B67:11221D7:27FD7A4:5EDD4703"
}
},
"uuid": "39860a04-002b-45da-aae7-70c97031c79e",
"persistent": true,
"insertionIndex": 1
}