Created
June 9, 2018 02:50
-
-
Save eltonjhony/2608c8c300f43047af3e70c9d93651ae to your computer and use it in GitHub Desktop.
This file contains 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
package com.example.dodo.popularmoviesfinal.Network; | |
import com.example.dodo.popularmoviesfinal.Models.MovieResponse; | |
import com.example.dodo.popularmoviesfinal.Models.ReviewResponse; | |
import retrofit2.Call; | |
import retrofit2.http.GET; | |
import retrofit2.http.Path; | |
import retrofit2.http.Query; | |
public interface ApiInterface { | |
// Request method and URL specified in the annotation | |
// Callback for the parsed response is the last parameter | |
@GET("./top_rated") | |
Call<MovieResponse> getTop_rated(@Query("api_key") String API_KEY); | |
@GET("./popular") | |
Call<MovieResponse> getPopular(@Query("api_key") String API_KEY); | |
@GET("./{id}/reviews") | |
Call<ReviewResponse> getResults(@Path("id") Integer id, @Query("api_key") String API_KEY); | |
} | |
/* | |
I have also noticed there are these 2 endpoints: | |
https://api.themoviedb.org/3/movie/popular?api_key= | |
and | |
https://api.themoviedb.org/3/movie/top_rated?api_key= | |
https://android.jlelse.eu/consuming-rest-api-using-retrofit-library-in-android-ed47aef01ecb | |
on endpoint from the forum; | |
https://discussions.udacity.com/t/confusion-with-api-endpoint-for-sorting-by-popular-or-top-rated/222344/2 | |
https://discussions.udacity.com/t/using-retrofit-firsttime/366768/9 | |
https://discussions.udacity.com/t/retrofit-help-building-movie-id-reviews-endpoint/385052/3 | |
http://square.github.io/retrofit/ | |
https://stackoverflow.com/questions/27816507/retrofit-multiple-endpoints-with-same-restadapter/27981993#27981993 | |
Path – variable substitution for the API endpoint. For example movie id will be swapped for{id} in the URL endpoint. | |
@Query – specifies the query key name with the value of the annotated parameter. | |
@Body – payload for the POST call | |
@Header – specifies the header with the value of the annotated parameter | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment