Skip to content

Instantly share code, notes, and snippets.

@Foso
Created August 27, 2016 08:42
Show Gist options
  • Save Foso/a98a7c11e795808fa8ca6471464f068e to your computer and use it in GitHub Desktop.
Save Foso/a98a7c11e795808fa8ca6471464f068e to your computer and use it in GitHub Desktop.
public interface SampleRetrofitInterface {
@GET("/posts")
Call<List<Post>> getPostList();
@GET("/posts/{id}")
Call<Post> getSinglePost(@Path("id") int postId);
@GET("/posts/")
Call<Post> getSinglePostQuery(@Query("userId") int userId);
@PUT("/posts/{id}")
Call<Post> putSinglePost(@Path("id") int postId);
@DELETE("/posts/{id}")
Call<String> deletePost(@Path("id") int postId);
@POST("users/new")
Call<Post> createPost(@Body Post post);
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl("https://jsonplaceholder.typicode.com")
.build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment