Newer
Older
CosmosClient / app / src / main / java / com / example / cosmosclient / resources / GroupsRest.java
package com.example.cosmosclient.resources;

import com.example.cosmosclient.entities.AddRequestsResponse;
import com.example.cosmosclient.entities.GroupListResponse;
import com.example.cosmosclient.entities.CreateGroupResponse;
import com.example.cosmosclient.entities.MemberListResponse;
import com.example.cosmosclient.entities.RequestList;

import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;


public interface GroupsRest {
    @GET("groups")
    Call<GroupListResponse> getGroups(@Query("uId") String uId, @Query("token") String token);

    @POST("groups")
    @FormUrlEncoded
    Call<CreateGroupResponse> createGroup(@Field("name") String name, @Field("uId") String uId, @Field("token") String token);

    @POST("groups/{gId}/requests")
    @FormUrlEncoded
    Call<AddRequestsResponse> addRequests(@Path("gId") String gId, @Field("uId") String uId, @Field("product") String product, @Field("deadline") String deadline, @Field("location") int location, @Field("token") String token);

    @GET("groups/{gId}/requests")
    Call<RequestList> getRequestsListByGid(@Path("gId") String gId, @Query("token") String token, @Query("detail") boolean detail, @Query("quantity") int quantity);

    @PUT("groups/{gId}/requests/{rId}")
    @FormUrlEncoded
    Call<AddRequestsResponse> updateRequest(@Path("gId") String gId, @Path("rId") String rId, @Field("uId") String uId, @Field("product") String product, @Field("deadline") String deadline, @Field("location") int location, @Field("done") boolean done, @Field("token") String token);

    @DELETE("groups/{gId}/requests/{rId}")
    Call<String> deleteRequest(@Path("gId") String gId, @Path("rId") String rId, @Query("token") String token);

//    @GET("{gId}/requests/{rId}")
//    Call<RequestList> getRequestsDetailByGidAndRid(@Path("gid") String gid, @Path("rid") String rid, @Query("token") String token);

    @GET("groups/{gId}/members")
    Call<MemberListResponse> getMemberListByGid(@Path("gId") String gId, @Query("token") String token);

}