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 jdk.dynalink.Operation;

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

public class BrandSwagger {

    // Summaries and Descriptions
    public static final String CREATE_BRAND_SUMMARY = "Create a new brand";
    public static final String CREATE_BRAND_DESCRIPTION = "Create a new brand with optional image.";

    public static final String GET_ALL_BRANDS_SUMMARY = "Retrieve all brands";
    public static final String GET_ALL_BRANDS_DESCRIPTION = "Fetch a paginated list of brands.";

    public static final String GET_BRAND_BY_ID_SUMMARY = "Retrieve brand by ID";
    public static final String GET_BRAND_BY_ID_DESCRIPTION = "Fetch brand details by its unique ID.";

    public static final String UPDATE_BRAND_SUMMARY = "Update a brand";
    public static final String UPDATE_BRAND_DESCRIPTION = "Update a brand's details, including its image.";

    public static final String DELETE_BRAND_SUMMARY = "Delete a brand";
    public static final String DELETE_BRAND_DESCRIPTION = "Delete a brand by its unique ID.";


    //Example Requests
    public static final String UPDATE_BRAND_REQUEST_EXAMPLE = """
    {
        "id": 73,
        "name": "PharmL",
        "description": "test",
        "image": "http://122.165.217.145:8005/billing/products/uploads/3190b85b-486b-4b01-9366-129960d3872a_Screenshot_13-1-2025_105230_122.165.217.145.jpeg",
        "tenant": "Arise_Tenant",
        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8"
    }
""";

    public static final String CREATE_BRAND_REQUEST_EXAMPLE = """
    {
        "id": 1,
        "name": "CoCubes",
        "description": "test",
        "image": "http://122.165.217.145:8005/billing/products/uploads/3190b85b-486b-4b01-9366-129960d3872a_Screenshot_13-1-2025_105230_122.165.217.145.jpeg",
        "tenant": "Arise_Tenant",
        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8"
    }
""";



    // Example Responses
    public static final String CREATE_BRAND_EXAMPLE = """
        {
                     "status": "success",
                     "meta": {
                         "code": 201,
                         "details": "Brand created successfully",
                         "timestamp": "2025-01-22T18:31:34.3281165"
                     },
                     "data": {
                         "id": 72,
                         "name": "Delite",
                         "description": "medical company",
                         "image":"http://122.165.217.145:8005/billing/products/uploads/3190b85b-486b-4b01-9366-129960d3872a_Screenshot_13-1-2025_105230_122.165.217.145.jpeg",
                         "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                         "tenant": "Arise_Tenant",
                         "created_at": "2025-01-22T18:31:34.3123422",
                         "updated_at": "2025-01-22T18:31:34.3123422",
                         "deleted_at": "2025-01-22T18:31:34.3123422"
                     }
                 }
    """;

    public static final String GET_ALL_BRANDS_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Brands 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": 55,
                                "name": "ON ",
                                "description": "",
                                "image": null,
                                "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                                "created_at": "2025-01-11T16:06:49.925928",
                                "updated_at": "2025-01-11T16:06:49.925928"
                            }
                        ],
                        "columns": {
                            "id": "ID",
                            "name": "NAME",
                            "description": "DESCRIPTION",
                            "image": "IMAGE",
                            "created_by": "CREATED BY",
                            "created_at": "CREATED AT",
                            "updated_at": "UPDATED AT"
                        }
                    }
                }
    """;

    public static final String GET_BRAND_BY_ID_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Brand retrieved successfully",
                        "timestamp": "2025-01-22T18:25:12.1773776"
                    },
                    "data": {
                        "id": 70,
                        "name": "PharmC",
                        "description": "PharmaC is a medical products company",
                        "image": "http://122.165.217.145:8005/billing/products/uploads\\\\3df7ce2f-a094-4b55-b4f7-3f2a68c34c6f_Screenshot_13-1-2025_105944_122.165.217.145.jpeg",
                        "created_by": "Aishwariya Arumugam",
                        "created_at": "2025-01-22T15:58:36.734098",
                        "updated_at": "2025-01-22T15:58:36.734098"
                    }
                }
    """;

    public static final String UPDATE_BRAND_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Brand updated successfully",
                        "timestamp": "2025-01-22T18:27:34.5697017"
                    },
                    "data": {
                        "id": 70,
                        "name": "PharmC",
                        "description": "PharmaC is a medical products company",
                        "image": "uploads\\\\3df7ce2f-a094-4b55-b4f7-3f2a68c34c6f_Screenshot_13-1-2025_105944_122.165.217.145.jpeg",
                        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                        "tenant": "Arise_Tenant",
                        "created_at": "2025-01-22T15:58:36.734098",
                        "updated_at": "2025-01-22T15:58:36.734098",
                        "deleted_at": "2025-01-22T15:58:36.734098"
                    }
                }
    """;

    public static final String DELETE_BRAND_EXAMPLE = """
        {
           "status": "success",
           "meta": {
                "code": 200,
                "details": "Brand 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_BRAND_SUMMARY,
            description = CREATE_BRAND_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(

                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.BrandRequest.class),
                            examples = @ExampleObject(value = CREATE_BRAND_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "201",
                            description = "Brand created successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = CREATE_BRAND_EXAMPLE)
                            )
                    )
            }
    )
    public @interface CreateBrandOperation {}

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

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

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @io.swagger.v3.oas.annotations.Operation(
            summary = UPDATE_BRAND_SUMMARY,
            description = UPDATE_BRAND_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.BrandRequest.class),
                            examples = @ExampleObject(value = UPDATE_BRAND_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Brand updated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = UPDATE_BRAND_EXAMPLE)
                            )
                    )
            }
    )
    public @interface UpdateBrandOperation {}

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

                            )
                    )
            }
    )
    public @interface DeleteBrandOperation {}

    // 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 {}
}