package com.example.petstoremobile.api.auth;

import com.example.petstoremobile.dtos.AuthDTO;
import com.example.petstoremobile.dtos.AvatarUploadResponse;
import com.example.petstoremobile.dtos.UserDTO;

import java.util.Map;

import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;

//Api for logging in and getting current user
public interface AuthApi {

    // endpoint for downloading the current user's avatar file
    String AVATAR_FILE_PATH = "api/v1/auth/me/avatar/file";

    //login endpoint
    @POST("api/v1/auth/login")
    Call<AuthDTO.LoginResponse> login(@Body AuthDTO.LoginRequest loginRequest);

    //get current user endpoint
    @GET("api/v1/auth/me")
    Call<UserDTO> getMe();

    //update current user endpoint
    @PUT("api/v1/auth/me")
    Call<UserDTO> updateMe(@Body Map<String, String> updates);

    //upload avatar endpoint
    @Multipart
    @POST("api/v1/auth/me/avatar")
    Call<AvatarUploadResponse> uploadAvatar(@Part MultipartBody.Part avatar);

    //delete avatar endpoint
    @DELETE("api/v1/auth/me/avatar")
    Call<Void> deleteAvatar();

    //forgot password endpoint
    @POST("api/v1/auth/forgot-password")
    Call<Void> forgotPassword(@Body Map<String, String> body);

}
