mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
Add twitter_username to Person and bio and hireable to User
This commit is contained in:
@@ -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;
|
||||
@@ -237,6 +237,18 @@ public abstract class GHPerson extends GHObject {
|
||||
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();
|
||||
|
||||
@@ -173,6 +173,19 @@ public class GHUser extends GHPerson {
|
||||
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;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class GHObjectTest extends org.kohsuke.github.AbstractGitHubWireMockTest
|
||||
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());
|
||||
|
||||
@@ -102,4 +102,11 @@ public class GHUserTest extends AbstractGitHubWireMockTest {
|
||||
repository.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyBioAndHireable() throws IOException {
|
||||
GHUser u = gitHub.getUser("GitHub");
|
||||
assertNotNull(u.getBio());
|
||||
assertNotNull(u.isHireable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"login": "github",
|
||||
"id": 9919,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/9919?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/github",
|
||||
"html_url": "https://github.com/github",
|
||||
"followers_url": "https://api.github.com/users/github/followers",
|
||||
"following_url": "https://api.github.com/users/github/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/github/orgs",
|
||||
"repos_url": "https://api.github.com/users/github/repos",
|
||||
"events_url": "https://api.github.com/users/github/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/github/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false,
|
||||
"name": "GitHub",
|
||||
"company": null,
|
||||
"blog": "https://github.com/about",
|
||||
"location": "San Francisco, CA",
|
||||
"email": "support@github.com",
|
||||
"hireable": null,
|
||||
"bio": "How people build software.",
|
||||
"twitter_username": null,
|
||||
"public_repos": 346,
|
||||
"public_gists": 0,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"created_at": "2008-05-11T04:37:31Z",
|
||||
"updated_at": "2020-02-07T13:08:07Z"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"id": "b0a81aff-fa31-4f8a-8934-5816b7db5d28",
|
||||
"name": "users_github",
|
||||
"request": {
|
||||
"url": "/users/GitHub",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "users_github-1.json",
|
||||
"headers": {
|
||||
"server": "GitHub.com",
|
||||
"date": "Sun, 07 Jun 2020 05:50:33 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/\"98a98fb1f7b75195fb721356df6181b5\"",
|
||||
"last-modified": "Fri, 07 Feb 2020 13:08:07 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": "50",
|
||||
"X-Ratelimit-Reset": "1591510189",
|
||||
"Accept-Ranges": "bytes",
|
||||
"X-GitHub-Request-Id": "C067:2C3F:70CA28:11A5488:5EDC8029"
|
||||
}
|
||||
},
|
||||
"uuid": "b0a81aff-fa31-4f8a-8934-5816b7db5d28",
|
||||
"persistent": true,
|
||||
"insertionIndex": 1
|
||||
}
|
||||
Reference in New Issue
Block a user