package com.example.petstoremobile.api;

import com.example.petstoremobile.dtos.MessageDTO;
import com.example.petstoremobile.dtos.SendMessageRequest;
import java.util.List;

import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Streaming;

//api calls to get and send messages
public interface MessageApi {

    @GET("api/v1/chat/conversations/{id}/messages")
    Call<List<MessageDTO>> getMessages(@Path("id") Long conversationId);

    @POST("api/v1/chat/conversations/{id}/messages")
    Call<MessageDTO> sendMessage(@Path("id") Long conversationId, @Body SendMessageRequest request);

    @Multipart
    @POST("api/v1/chat/conversations/{id}/attachments")
    Call<MessageDTO> sendMessageWithAttachment(
            @Path("id") Long conversationId,
            @Part MultipartBody.Part content,
            @Part MultipartBody.Part file
    );

    @GET("api/v1/chat/messages/{id}/attachment")
    @Streaming
    Call<ResponseBody> downloadAttachment(@Path("id") Long messageId);
}