Skip to content

Instantly share code, notes, and snippets.

@algorythmist
Last active August 29, 2015 14:03
Show Gist options
  • Save algorythmist/c16b7a93b10e633ead69 to your computer and use it in GitHub Desktop.
Save algorythmist/c16b7a93b10e633ead69 to your computer and use it in GitHub Desktop.
public class HttpMovieService extends AbstractTomatoService implements
MovieService {
@Override
public List<Movie> getBoxOfficeMovies(Locale country, int limit)
throws IOException {
String url = ROTTENTOMATOES_API + BOX_OFFICE_MOVIES;
GenericUrl request = getMovieRequest(country, limit, url);
HttpResponse response = executeRequest(request);
MovieFeed feed = response.parseAs(MovieFeed.class);
return feed.movies;
}
protected GenericUrl getMovieRequest(Locale country, int limit, String url) {
GenericUrl request = new GenericUrl(url);
request.set("apikey", getApiKey());
request.set("country", country.getCountry());
request.set("limit", limit);
return request;
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment