package com.nebula.erp.reports.documents;

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

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class AuditComplianceSwagger {

    // Summaries and Descriptions
    public static final String GET_AUDIT_COMPLIANCE_REPORT_SUMMARY = "Get Audit Compliance Report";
    public static final String GET_AUDIT_COMPLIANCE_REPORT_DESCRIPTION = "Generates an audit and compliance report based on the given sales request and report type.";

    // Request and Response Examples
    public static final String GET_AUDIT_COMPLIANCE_REQUEST_EXAMPLE = """
        {
                    "startDate": "2025-01-01",
                    "endDate": "2025-12-31",
                    "conditions": [],
                    "page": 0,
                    "size": 10
         }
    """;

    public static final String GET_AUDIT_COMPLIANCE_RESPONSE_EXAMPLE = """
        {
                     "status": "Success",
                     "meta": {
                         "code": 200,
                         "details": "Data retrieved.",
                         "timestamp": "2025-01-28T20:16:34.7493285"
                     },
                     "data": {
                         "module": "audit-compliance",
                         "reportType": "inventoryAudit",
                         "startDate": "2025-01-01",
                         "endDate": "2025-12-31",
                         "reportData": [
                             {
                                 "product_id": 17,
                                 "product_name": "Creatine",
                                 "category_id": 31,
                                 "category_name": "Tablet",
                                 "brand_id": 55,
                                 "brand_name": "ON ",
                                 "inventory_quantity": 135,
                                 "received_quantity": 691,
                                 "discrepancy": -556
                             }
                         ],
                         "column": {
                             "product_id": "PRODUCT ID",
                             "product_name": "PRODUCT NAME",
                             "category_id": "CATEGORY ID",
                             "category_name": "CATEGORY NAME",
                             "brand_id": "BRAND ID",
                             "brand_name": "BRAND NAME",
                             "inventory_quantity": "INVENTORY QUANTITY",
                             "received_quantity": "RECEIVED QUANTITY",
                             "discrepancy": "DISCREPANCY"
                         },
                         "pagination": {
                             "currentPage": 1,
                             "totalPages": 1,
                             "pageSize": 10,
                             "totalRecords": 2
                         }
                     }
                 }
    """;

    public static final String INTERNAL_SERVER_ERROR_RESPONSE = """
        {
            "status": "error",
            "meta": {
                "code": 500,
                "message": "Internal Server Error"
            }
        }
    """;

    // Global Error Response Annotation
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @ApiResponse(
            responseCode = "500",
            description = "Internal Server Error",
            content = @Content(
                    mediaType = "application/json",
                    examples = @ExampleObject(value = INTERNAL_SERVER_ERROR_RESPONSE)
            )
    )
    public @interface GlobalErrorResponse {}

    // Modular Annotations for APIs
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = GET_AUDIT_COMPLIANCE_REPORT_SUMMARY,
            description = GET_AUDIT_COMPLIANCE_REPORT_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.reports.requestmodel.SalesRequest.class),
                            examples = @ExampleObject(value = GET_AUDIT_COMPLIANCE_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Audit Compliance Report generated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    examples = @ExampleObject(value = GET_AUDIT_COMPLIANCE_RESPONSE_EXAMPLE)
                            )
                    )
            }
    )
    public @interface GetAuditComplianceReportOperation {}

}
