package com.ikon.projectmanagement.api;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.util.List;
import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ikon.projectmanagement.dto.request.ProjectRequestDto;
import com.ikon.projectmanagement.dto.response.ProjectResponseDto;
import com.ikon.projectmanagement.dto.response.ProjectTimelineResponseDto;

@Tag(name = "Project APIs", description = "Project Management related APIs")
@RequestMapping("/api/v1/projects")
public interface ProjectApi {

        @Operation(summary = "Create a new project", description = "Creates a new project and returns the created project details.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Project details", required = true, content = @Content(schema = @Schema(implementation = ProjectRequestDto.class))), responses = {
                        @ApiResponse(responseCode = "201", description = "Project created successfully"),
                        @ApiResponse(responseCode = "400", description = "Invalid project data"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @PostMapping
        ResponseEntity<ProjectResponseDto> createProject(
                        @RequestHeader("Authorization") String accessToken,
                        @RequestBody ProjectRequestDto projectDto);

        @Operation(summary = "Get all projects", description = "Retrieves a list of all existing projects.", responses = {
                        @ApiResponse(responseCode = "200", description = "Projects retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping
        public ResponseEntity<List<ProjectResponseDto>> getAllProjects(
                        @RequestHeader("Authorization") String accessToken);

        @Operation(summary = "Get project by Id", description = "Retrieves a project by its unique project ID.", responses = {
                        @ApiResponse(responseCode = "200", description = "Project retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "404", description = "Project not found"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping("/{projectIdentifier}")
        public ResponseEntity<ProjectResponseDto> getProjectByProjectIdentifier(
                        @RequestHeader("Authorization") String accessToken,
                        @PathVariable("projectIdentifier") UUID projectIdentifier);

        @Operation(summary = "Update an existing project", description = "Updates the details of an existing project identified by its ID.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated project details", required = true, content = @Content(schema = @Schema(implementation = ProjectRequestDto.class))), responses = {
                        @ApiResponse(responseCode = "200", description = "Project updated successfully"),
                        @ApiResponse(responseCode = "400", description = "Invalid project data or ID provided"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "404", description = "Project not found"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @PutMapping("/{projectIdentifier}")
        ResponseEntity<ProjectResponseDto> updateProject(
                        @RequestHeader("Authorization") String accessToken,
                        @PathVariable("projectIdentifier") UUID projectIdentifier,
                        @RequestBody ProjectRequestDto projectDto);

        @Operation(summary = "Get all active projects start and end dates", description = "Retrieves a list of all active projects with their start and end dates.", responses = {
                        @ApiResponse(responseCode = "200", description = "Projects retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping("/active-projects-timeline")
        public ResponseEntity<List<ProjectTimelineResponseDto>> getAllActiveProjectsTimeline(
                        @RequestHeader("Authorization") String accessToken);

}
