S
S
SerGio13132016-11-23 15:20:15
Java
SerGio1313, 2016-11-23 15:20:15

How to get the number of github repositories and subscribers?

Good afternoon.
I get a list of random github users, select two users from there. You need to get the number of subscribers and public repositories. However I receive each time - "0".
I use Retrofit, github API

final Call<List<GithubUser>> call = service.getListOfUsers(new Random().nextInt(4000000));
                call.enqueue(new Callback<List<GithubUser>>() {
                    @Override
                    public void onResponse(Call<List<GithubUser>> call, Response<List<GithubUser>> response) {
                        if (response.isSuccessful()) {
                            GithubUser user1 = response.body().get(new  Random().nextInt(30));
                            GithubUser user2 = response.body().get(new Random().nextInt(30));

                            Picasso.with(MainActivity.this).load(user1.getAvatarUrl()).into(userAvatar1);
                 
                            userData1.setText(user1.getLogin() +
                                    "\n" + String.valueOf(user1.getFollowers()));
                              }
                        else { }
                    }

                    @Override
                    public void onFailure(Call<List<GithubUser>> call, Throwable t) {}
                });

//описание запроса 
@GET("/users")
    Call<List<GithubUser>> getListOfUsers(@Query("since") int number);
//для генерации POJO класса использую <a href="http://jsonschema2pojo.org">генератор</a>

for the generator I use the following form
{
    "login": "user",
    "id": 66742423,
    "public_repos": 0,
    "public_gists": 0,
    "followers": 1,
    "following": 0,
  }

Tell me why the list that came from the server does not contain data on the required parameters (contains "0")?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Smith, 2016-11-25
@Braidner

since does not return full user info, 0 because primitives cannot be null.

{
    "login": "josh",
    "id": 137,
    "avatar_url": "https://avatars.githubusercontent.com/u/137?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/josh",
    "html_url": "https://github.com/josh",
    "followers_url": "https://api.github.com/users/josh/followers",
    "following_url": "https://api.github.com/users/josh/following{/other_user}",
    "gists_url": "https://api.github.com/users/josh/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/josh/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/josh/subscriptions",
    "organizations_url": "https://api.github.com/users/josh/orgs",
    "repos_url": "https://api.github.com/users/josh/repos",
    "events_url": "https://api.github.com/users/josh/events{/privacy}",
    "received_events_url": "https://api.github.com/users/josh/received_events",
    "type": "User",
    "site_admin": true
  },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question