package com.nebula.erp.product.document;

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

    // Summaries and Descriptions
    public static final String CREATE_COUPON_SUMMARY = "Create a new coupon";
    public static final String CREATE_COUPON_DESCRIPTION = "Create a new coupon.";

    public static final String GET_ALL_COUPONS_SUMMARY = "Retrieve all coupons";
    public static final String GET_ALL_COUPONS_DESCRIPTION = "Fetch a paginated list of coupons.";

    public static final String GET_COUPON_BY_ID_SUMMARY = "Retrieve coupon by ID";
    public static final String GET_COUPON_BY_ID_DESCRIPTION = "Fetch coupon details by its unique ID.";

    public static final String UPDATE_COUPON_SUMMARY = "Update a coupon";
    public static final String UPDATE_COUPON_DESCRIPTION = "Update a coupon's details.";

    public static final String DELETE_COUPON_SUMMARY = "Delete a coupon";
    public static final String DELETE_COUPON_DESCRIPTION = "Delete a coupon by its unique ID.";

    //Example Requests
    public static final String UPDATE_COUPON_REQUEST_EXAMPLE = """
    {
        "id": 1,
        "name": "New year",
        "code": "NEW",
        "start_date": "2025-01-22",
        "end_date": "2025-01-22",
        "percentage": 10,
        "created_at": "2025-01-23T19:23:44.398128"
    }
    """;

    public static final String CREATE_COUPON_REQUEST_EXAMPLE = """
    {
        "id": 1,
        "name": "New year",
        "code": "NEW",
        "start_date": "2025-01-22",
        "end_date": "2025-01-22",
        "percentage": 10,
        "created_at": "2025-01-23T19:23:44.398128"
    }
    """;

    // Example Responses
    public static final String CREATE_COUPON_EXAMPLE = """
    {
         "status": "success",
         "meta": {
             "code": 201,
             "details": "Coupon created successfully",
             "timestamp": "2025-01-22T18:31:34.3281165"
         },
         "data": {
            "id": 1,
            "name": "New year",
            "code": "NEW",
            "start_date": "2025-01-22",
            "end_date": "2025-01-22",
            "percentage": 10,
            "created_at": "2025-01-23T19:23:44.398128"
         }
    }
    """;

    public static final String GET_ALL_COUPONS_EXAMPLE = """
    {
        "status": "success",
        "meta": {
            "code": 200,
            "details": "Coupons retrieved successfully",
            "timestamp": "2025-01-22T18:22:36.9726915"
        },
        "data": {
            "pagination": {
                "current_page": 1,
                "per_page": 10,
                "total": 2,
                "last_page": 1,
                "next_page_url": null,
                "prev_page_url": null
            },
            "items": [
                {
                    "id": 1,
                    "name": "New year",
                    "code": "NEW",
                    "start_date": "2025-01-22",
                    "end_date": "2025-01-22",
                    "percentage": 10,
                    "created_at": "2025-01-23T19:23:44.398128"
                }
            ],
            "columns": {
                "id": "ID",
                "name": "NAME",
                "code": "code",
                "start_date": "START DATE",
                "end_date": "END DATE",
                "percentage": "PERCENTAGE",
                "created_at": "CREATED AT"
            }
        }
    }
    """;

    public static final String GET_COUPON_BY_ID_EXAMPLE = """
    {
        "status": "success",
        "meta": {
            "code": 200,
            "details": "Coupon retrieved successfully",
            "timestamp": "2025-01-22T18:25:12.1773776"
        },
        "data": {
            "id": 1,
            "name": "New year",
            "code": "NEW",
            "start_date": "2025-01-22",
            "end_date": "2025-01-22",
            "percentage": 10,
            "created_at": "2025-01-23T19:23:44.398128"
        }
    }
    """;

    public static final String UPDATE_COUPON_EXAMPLE = """
    {
        "status": "success",
        "meta": {
            "code": 200,
            "details": "Coupon updated successfully",
            "timestamp": "2025-01-22T18:27:34.5697017"
        },
        "data": {
            "id": 1,
            "name": "New year",
            "code": "NEW",
            "start_date": "2025-01-22",
            "end_date": "2025-01-22",
            "percentage": 10,
            "created_at": "2025-01-23T19:23:44.398128"
        }
    }
    """;

    public static final String DELETE_COUPON_EXAMPLE = """
    {
        "status": "success",
        "meta": {
            "code": 200,
            "details": "Coupon deleted successfully",
            "timestamp": "2025-01-22T18:29:03.640753"
        },
        "data": null
    }
    """;

    public static final String INTERNAL_SERVER_ERROR_EXAMPLE = """
    {
        "status": "error",
        "meta": {
            "code": 500,
            "message": "An internal server error occurred"
        }
    }
    """;

    // Custom Annotations for Each Operation
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = CREATE_COUPON_SUMMARY,
            description = CREATE_COUPON_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.CouponRequest.class),
                            examples = @ExampleObject(value = CREATE_COUPON_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "201",
                            description = "Coupon created successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = CREATE_COUPON_EXAMPLE)
                            )
                    )
            }
    )

    public @interface CreateCouponOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = GET_ALL_COUPONS_SUMMARY,
            description = GET_ALL_COUPONS_DESCRIPTION,
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Coupons retrieved successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = GET_ALL_COUPONS_EXAMPLE)
                            )
                    )
            }
    )

    public @interface GetAllCouponsOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = GET_COUPON_BY_ID_SUMMARY,
            description = GET_COUPON_BY_ID_DESCRIPTION,
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Coupon retrieved successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = GET_COUPON_BY_ID_EXAMPLE)
                            )
                    )
            }
    )
    public @interface GetCouponByIdOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = UPDATE_COUPON_SUMMARY,
            description = UPDATE_COUPON_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.CouponRequest.class),
                            examples = @ExampleObject(value = UPDATE_COUPON_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Coupon updated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = UPDATE_COUPON_EXAMPLE)
                            )
                    )
            }
    )

    public @interface UpdateCouponOperation {}

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = DELETE_COUPON_SUMMARY,
            description = DELETE_COUPON_DESCRIPTION,
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Coupon deleted successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    examples = @ExampleObject(value = DELETE_COUPON_EXAMPLE)

                            )
                    )
            }
    )

    public @interface DeleteCouponOperation {}

    // Annotation for Global Error Response (500 Internal Server Error)
    @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 {}
}