package com.nebula.erp.product.document;

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 TaxSwagger {

    // Summaries and Descriptions
    public static final String CREATE_TAX_SUMMARY = "Create a new tax";
    public static final String CREATE_TAX_DESCRIPTION = "Create a new tax with its type and rate.";

    public static final String GET_ALL_TAX_SUMMARY = "Retrieve all taxes";
    public static final String GET_ALL_TAX_DESCRIPTION = "Fetch a paginated list of all tax records.";

    public static final String GET_TAX_BY_ID_SUMMARY = "Retrieve tax by ID";
    public static final String GET_TAX_BY_ID_DESCRIPTION = "Fetch the details of a specific tax record by its unique ID.";

    public static final String UPDATE_TAX_SUMMARY = "Update a tax";
    public static final String UPDATE_TAX_DESCRIPTION = "Update the details of an existing tax record, including its type and rate.";

    public static final String DELETE_TAX_SUMMARY = "Delete a tax";
    public static final String DELETE_TAX_DESCRIPTION = "Delete a specific tax record by its unique ID.";

    //Example Requests
    public static final String CREATE_TAX_REQUEST_EXAMPLE = """
            {
               "id": null,
               "type": "CGT",
               "rate": 10,
               "tenant": "Arise_Tenant",
               "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8"
            }
            """;

    public static final String UPDATE_TAX_REQUEST_EXAMPLE = """
            {
               "id": 13,
               "type": "CGT",
               "rate": 10,
               "tenant": "Arise_Tenant",
               "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8"
            }
            
            """;

    // Example Responses
    public static final String CREATE_TAX_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 201,
                        "details": "Tax created successfully",
                        "timestamp": "2025-01-22T18:58:14.1796583"
                    },
                    "data": {
                        "id": 35,
                        "type": "CGT",
                        "rate": 10,
                        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                        "tenant": "Arise_Tenant",
                        "created_at": "2025-01-22T18:58:14.1638799",
                        "updated_at": "2025-01-22T18:58:14.1638799",
                        "deleted_at": "2025-01-22T18:58:14.1638799"
                    }
                }
    """;

    public static final String GET_ALL_TAX_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Tax retrieved successfully",
                        "timestamp": "2025-01-22T18:56:34.7536651"
                    },
                    "data": {
                        "pagination": {
                            "current_page": 1,
                            "per_page": 10,
                            "total": 1,
                            "last_page": 1,
                            "next_page_url": null,
                            "prev_page_url": null
                        },
                        "items": [
                            {
                                "id": 13,
                                "type": "GST",
                                "rate": 18.00,
                                "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                                "created_at": "2025-01-02T11:14:48.636206",
                                "updated_at": "2025-01-02T11:14:48.636206"
                            }
                        ],
                        "columns": {
                            "id": "ID",
                            "type": "TYPE",
                            "rate": "RATE",
                            "created_by": "CREATED BY",
                            "created_at": "CREATED AT",
                            "updated_at": "UPDATED AT"
                        }
                    }
                }
    """;

    public static final String GET_TAX_BY_ID_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Tax retrieved successfully",
                        "timestamp": "2025-01-22T18:57:16.003723"
                    },
                    "data": {
                        "id": 13,
                        "type": "GST",
                        "rate": 18.00,
                        "created_by": "Aishwariya Arumugam",
                        "created_at": "2025-01-02T11:14:48.636206",
                        "updated_at": "2025-01-02T11:14:48.636206"
                    }
                }
    """;

    public static final String UPDATE_TAX_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Tax updated successfully",
                        "timestamp": "2025-01-22T18:57:38.8342642"
                    },
                    "data": {
                        "id": 13,
                        "type": "GST",
                        "rate": 18,
                        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                        "tenant": "Arise_Tenant",
                        "created_at": "2025-01-02T11:14:48.636206",
                        "updated_at": "2025-01-02T11:14:48.636206",
                        "deleted_at": "2025-01-02T11:14:48.636206"
                    }
                }
    """;

    public static final String DELETE_TAX_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Tax deleted successfully",
                        "timestamp": "2025-01-22T18:58:59.7107236"
                    },
                    "data": null
                }
    """;

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

    // Reusable 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_EXAMPLE)
            )
    )
    public @interface GlobalErrorResponse {}

    // Modular Annotations for Each API
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = CREATE_TAX_SUMMARY,
            description = CREATE_TAX_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.TaxRequest.class),
                            examples = @ExampleObject(value = CREATE_TAX_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "201",
                            description = "Tax created successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = CREATE_TAX_EXAMPLE)
                            )
                    )
            }
    )
    public @interface CreateTaxOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = GET_ALL_TAX_SUMMARY,
            description = GET_ALL_TAX_DESCRIPTION,
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Taxes retrieved successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = GET_ALL_TAX_EXAMPLE)
                            )
                    )
            }
    )
    public @interface GetAllTaxesOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = GET_TAX_BY_ID_SUMMARY,
            description = GET_TAX_BY_ID_DESCRIPTION,
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Tax retrieved successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = GET_TAX_BY_ID_EXAMPLE)
                            )
                    )
            }
    )
    public @interface GetTaxByIdOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = UPDATE_TAX_SUMMARY,
            description = UPDATE_TAX_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.TaxRequest.class),
                            examples = @ExampleObject(value = UPDATE_TAX_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Tax updated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = UPDATE_TAX_EXAMPLE)
                            )
                    )
            }
    )
    public @interface UpdateTaxOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = DELETE_TAX_SUMMARY,
            description = DELETE_TAX_DESCRIPTION,
            responses = {
                    @ApiResponse(

                            responseCode = "200",
                            description = "Tax deleted successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    examples = @ExampleObject(value = DELETE_TAX_EXAMPLE)
                            )
                    )
            }
    )
    public @interface DeleteTaxOperation {}
}
