package org.initialde.yakasave.Api;

import org.initialde.yakasave.Api.Responses.UserProfileResponse;
import org.initialde.yakasave.Application.RetrieveMe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
public class RetrieveMeController {
    private final RetrieveMe retrieveMe;

    @Autowired
    public RetrieveMeController(RetrieveMe retrieveMe) {
        this.retrieveMe = retrieveMe;
    }

    @GetMapping("/me")
    public UserProfileResponse retrieveMe() {
        var user = retrieveMe.retrieve();
        return new UserProfileResponse(user.getId(), user.getUsername());
    }
}
