package de.beyondsoft.ownchat.data.api.services;

import de.beyondsoft.ownchat.data.api.responses.GroupResponse;
import de.beyondsoft.ownchat.data.api.responses.MessageResponse;
import de.beyondsoft.ownchat.data.api.responses.MessagesResponse;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by imarneanu on 3/1/17.
 */
public interface ChatService {
    @GET("api/chat/groups")
    Observable<GroupResponse> getGroups();

    @GET("api/chat/messages")
    Observable<MessagesResponse> getMessages(@Query("groupid") long groupId,
                                             @Query("page") int page);

    @GET("api/chat/message/{oid}")
    Observable<MessageResponse> getMessage(@Path("oid") String messageId);

    @Multipart
    @POST("api/chat/messages/send")
    Observable<MessageResponse> sendFile(
            @Part("groupid") RequestBody groupid,
            @Part MultipartBody.Part file,
			@Part("text") RequestBody text
    );

    @FormUrlEncoded
    @POST("api/chat/messages/send")
    Observable<MessageResponse> sendMessage(
            @Field("groupid") long groupId,
            @Field("text") String text);
}
