package pl.polskalokalnie.report;

import jakarta.validation.Valid;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/reports")
public class ListingReportController {

    private final ListingReportService listingReportService;

    public ListingReportController(ListingReportService listingReportService) {
        this.listingReportService = listingReportService;
    }

    @PostMapping("/listings")
    public ListingReportResponse createListingReport(
            @Valid @RequestBody CreateListingReportRequest request,
            Authentication authentication
    ) {
        return listingReportService.create(request, authentication.getName());
    }
}
