Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SergeyKharuk/c3661ece9ec5bef7c88b09b83619e0c4 to your computer and use it in GitHub Desktop.
Save SergeyKharuk/c3661ece9ec5bef7c88b09b83619e0c4 to your computer and use it in GitHub Desktop.
Some manager
package walltreesoft.petpals.api.managers;
import java.util.Map;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;
import walltreesoft.petpals.api.APIConstants;
import walltreesoft.petpals.api.models.AddComment;
import walltreesoft.petpals.api.models.Post;
import walltreesoft.petpals.api.models.PostComment;
import walltreesoft.petpals.api.models.PostPreview;
import walltreesoft.petpals.api.models.ReportRequest;
public interface IPostManager {
//ONLY WITH VIDEO
@Multipart
@POST(APIConstants.CREATE_POST)
Observable<Post> createPost(@Header("Authorization") String token, @PartMap() Map<String, RequestBody> post, @Part MultipartBody.Part video, @Part MultipartBody.Part thumbnail);
//ONLY WITH IMAGE
@Multipart
@POST(APIConstants.CREATE_POST)
Observable<Post> createPost(@Header("Authorization") String token, @PartMap() Map<String, RequestBody> post, @Part MultipartBody.Part file);
//WITHOUT CONTENT
@Multipart
@POST(APIConstants.CREATE_POST)
Observable<Post> createPost(@Header("Authorization") String token, @PartMap() Map<String, RequestBody> post);
@DELETE(APIConstants.DELETE_POST)
Observable<Object> deletePost(@Header("Authorization") String token, @Path("id") String id);
@PUT(APIConstants.DISLIKE_POST)
Observable<Object> dislikePost(@Header("Authorization") String token, @Path("id") String id);
@PUT(APIConstants.LIKE_POST)
Observable<Object> likePost(@Header("Authorization") String token, @Path("id") String id);
@GET(APIConstants.GET_POST_PREVIEW)
Observable<PostPreview> getPostListPreviews(@Header("Authorization") String token, @Query("page") String page, @Query("limit") String limit);
//Comments
@GET(APIConstants.GET_COMMENTS)
Observable<PostComment> getComments(@Header("Authorization") String token, @Path("id") String id, @Query("page") String page, @Query("limit") String limit);
@POST(APIConstants.ADD_COMMENT_POST)
Observable<Object> addComment(@Header("Authorization") String token, @Body AddComment comment);
@DELETE(APIConstants.DELETE_COMMENT_POST)
Observable<Object> deleteComment(@Header("Authorization") String token, @Path("id") String id);
@PUT(APIConstants.DISLIKE_COMMENT_POST)
Observable<Object> dislikeComment(@Header("Authorization") String token, @Path("id") String id);
@PUT(APIConstants.LIKE_COMMENT_POST)
Observable<Object> likeComment(@Header("Authorization") String token, @Path("id") String id);
@GET(APIConstants.GET_POST_PREVIEW)
Observable<PostPreview> getUserPostList(@Header("Authorization") String token, @Query("page") String page, @Query("limit") String limit, @Query("profile") String profileId);
@GET(APIConstants.GET_POST_PREVIEW)
Observable<PostPreview> getMyPostList(@Header("Authorization") String token, @Query("page") String page, @Query("limit") String limit, @Query("me") boolean me);
@GET(APIConstants.GET_POST_PREVIEW)
Observable<PostPreview> getPetPostList(@Header("Authorization") String token, @Query("page") String page, @Query("limit") String limit, @Query("pet") String petId);
@POST(APIConstants.REPORT)
Observable<Object> reportPost(@Header("Authorization") String token, @Body() ReportRequest reportRequest);
@GET(APIConstants.GET_POST_BY_ID)
Observable<Post> getPostByID(@Header("Authorization") String token, @Path("id") String id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment