Skip to content

Instantly share code, notes, and snippets.

@florent37
Last active December 11, 2018 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florent37/a51ab9dc3c0011cc681b7691bcfae6dc to your computer and use it in GitHub Desktop.
Save florent37/a51ab9dc3c0011cc681b7691bcfae6dc to your computer and use it in GitHub Desktop.
interface OMDBApi {
@GET("/")
fun searchMovies(@Query("s") name: String, @Query("apiKey") apikey: String) : Deferred<SearchResponse>
companion object {
val apiKey = "YOUR_KEY"
val baseUrl = "http://www.omdbapi.com/"
}
}
class OmdbRepository(val omdbApi: OMDBApi) {
suspend fun searchMovies(byName: String): List<Movie> {
val response = omdbApi.searchMovies(byName, OMDBApi.apiKey).await()
return response.movies
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment