Skip to content

Instantly share code, notes, and snippets.

@digitalbuddha
Last active January 2, 2017 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalbuddha/eb6195e6486f90904992 to your computer and use it in GitHub Desktop.
Save digitalbuddha/eb6195e6486f90904992 to your computer and use it in GitHub Desktop.
//Create a Model that represents your JSON data (It’s ok if fields are missing that are present in JSON)
public class User {
public String avatar_url;
public String login;
}
//Create an interface
public interface Github {
@GET(“/search/users”) UserResponse users(@Query(“q”) String name);
}
//Auto Generate implementation from Interface
Github api = new RestAdapter.Builder()
.setEndpoint(“https://api.github.com")
.build()
.create(Github.class)
// user your endpoint
UserResponse response =api.users(request.getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment