Created
July 27, 2019 11:16
-
-
Save kinisoftware/c92dfb19955734e232ae57b0d7e1e27a 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
| class TheMovieDBService(private val gson: Gson) { | |
| fun getNowPlayingMovies(locale: String): List<Movie> { | |
| val retrofit = Retrofit.Builder() | |
| .addConverterFactory(GsonConverterFactory.create(gson)) | |
| .baseUrl("https://api.themoviedb.org/3/") | |
| .build() | |
| val theMovieDBAPI = retrofit.create(TheMovieDBAPI::class.java) | |
| val upcomings = theMovieDBAPI.getNowPlaying( | |
| System.getenv("TheMovieDBApiKey"), | |
| locale, | |
| 1, | |
| getRegion(locale) | |
| ) | |
| return upcomings.execute().body().results | |
| } | |
| fun getUpcomings(locale: String): List<Movie> { | |
| val retrofit = Retrofit.Builder() | |
| .addConverterFactory(GsonConverterFactory.create(gson)) | |
| .baseUrl("https://api.themoviedb.org/3/") | |
| .build() | |
| val theMovieDBAPI = retrofit.create(TheMovieDBAPI::class.java) | |
| val upcomings = theMovieDBAPI.getUpcomings( | |
| System.getenv("TheMovieDBApiKey"), | |
| locale, | |
| 1, | |
| getRegion(locale) | |
| ) | |
| return upcomings.execute().body().results | |
| } | |
| private fun getRegion(locale: String) = locale.substringAfter('-') | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment