Skip to content

Instantly share code, notes, and snippets.

@miquelbeltran
Last active October 23, 2016 10:31
Show Gist options
  • Save miquelbeltran/6d771c94999271ffbb2f2b5a7a3bbbf8 to your computer and use it in GitHub Desktop.
Save miquelbeltran/6d771c94999271ffbb2f2b5a7a3bbbf8 to your computer and use it in GitHub Desktop.
public interface BooksInteractor {
Call<BookSearchResult> search(String search);
}
public class BooksInteractorImpl implements BooksInteractor {
private GoogleBooksService service;
public BooksInteractorImpl() {
// Configure Retrofit
Retrofit retrofit = new Retrofit.Builder()
// Base URL can change for endpoints (dev, staging, live..)
.baseUrl("https://www.googleapis.com")
// Takes care of converting the JSON response into java objects
.addConverterFactory(GsonConverterFactory.create())
.build();
// Create the Google Book API Service
service = retrofit.create(GoogleBooksService.class);
}
@Override
public Call<BookSearchResult> search(String search) {
return service.search("search+" + search);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment