Last active
October 23, 2016 10:31
-
-
Save miquelbeltran/6d771c94999271ffbb2f2b5a7a3bbbf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface BooksInteractor { | |
Call<BookSearchResult> search(String search); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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