package com.example.gallery.api;

import com.example.gallery.UserResponse;
import com.example.gallery.models.LoginRequest;
import com.example.gallery.models.LoginResponse;
import com.example.gallery.models.Publication;
import com.example.gallery.models.PublicationListResponse;
import com.example.gallery.models.RegisterRequest;
import com.example.gallery.models.RegisterResponse;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;

public interface ApiService {

    /* ===================== AUTH ===================== */

    @POST("api/auth/register/")
    Call<RegisterResponse> register(@Body RegisterRequest request);

    @POST("api/auth/login/")
    Call<LoginResponse> login(@Body LoginRequest request);

    @GET("api/auth/me/")
    Call<UserResponse> getMe(@Header("Authorization") String token);

    /* ================== PUBLICATIONS ================= */

    @GET("api/publications/")
    Call<PublicationListResponse> getPublications(
            @Header("Authorization") String token
    );

    @Multipart
    @POST("api/publications/")
    Call<Publication> createPublication(
            @Header("Authorization") String authHeader,
            @Part("description") RequestBody description,
            @Part("content_type") RequestBody contentType,
            @Part("status") RequestBody status,
            @Part("category") RequestBody category,
            @Part MultipartBody.Part file
    );
}
