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

    // Summaries and Descriptions
    public static final String CREATE_FEES_SUMMARY = "Create a new fee record";
    public static final String CREATE_FEES_DESCRIPTION = "Create a new fee record with details such as practitioner ID, location, tax, and rate.";

    public static final String GET_ALL_FEES_SUMMARY = "Retrieve all fee records";
    public static final String GET_ALL_FEES_DESCRIPTION = "Fetch a paginated list of all fee records, optionally filtered by practitioner ID.";

    public static final String GET_FEES_BY_ID_SUMMARY = "Retrieve fee record by ID";
    public static final String GET_FEES_BY_ID_DESCRIPTION = "Fetch details of a specific fee record by its unique ID.";

    public static final String UPDATE_FEES_SUMMARY = "Update a fee record";
    public static final String UPDATE_FEES_DESCRIPTION = "Update an existing fee record with new details.";

    //Example Requests
    public static final String CREATE_FEES_REQUEST_EXAMPLE= """
            {
               "rate": 200,
               "measurement": "hourly",
               "tax_id": 13,
               "fees_type_id": "5d92db02-ac11-40a6-a9f7-9c46700d0780",
               "service_category": "Aged Care Information/Referral",
               "location_id": "9a314bbc-d226-4a52-9cea-7fb5c8894ce8",
               "speciality": "Heart Specialist",
               "practitioner_id": "e5de3e7c-ee7f-4dd2-bae7-d6200ceee38d",
               "description": "TESTS",
               "practitioner_name": "Mr Vignesh K",
               "location_name": "Room 103",
               "fees_type_name": "Massage"
            }
            
            """;

    public static final String UPDATE_FEES_REQUEST_EXAMPLE= """
            {
               "rate": 500,
               "measurement": "per_session",
               "tax_id": 13,
               "fees_type_id": "5d92db02-ac11-40a6-a9f7-9c46700d0780",
               "service_category": "Aged Care Information/Referral",
               "location_id": "9a314bbc-d226-4a52-9cea-7fb5c8894ce8",
               "speciality": "Heart Specialist",
               "practitioner_id": "f116cdb9-60d3-4c68-a2f7-346b3fd37f0e",
               "description": "test",
               "practitioner_name": "Mr Tamizh A",
               "location_name": "Room 103",
               "fees_type_name": "Massage",
               "id": 48
            }
            
            """;

    // Example Responses
    public static final String CREATE_FEES_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 201,
                        "details": "Fees created successfully",
                        "timestamp": "2025-01-22T19:04:36.5703718"
                    },
                    "data": {
                        "id": 46,
                        "practitioner_id": "e5de3e7c-ee7f-4dd2-bae7-d6200ceee38d",
                        "speciality": "Heart Specialist",
                        "location_id": "1dbbf090-d4af-4846-98eb-a7cfa76eeda1",
                        "fees_type": null,
                        "service_category": "Aged Care Assessment",
                        "measurement": "hourly",
                        "tax": {
                            "id": 13,
                            "type": "GST",
                            "rate": 18.00,
                            "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"
                        },
                        "rate": 200,
                        "description": "example",
                        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                        "tenant": "Arise_Tenant",
                        "created_at": "2025-01-22T19:04:36.5391429",
                        "updated_at": "2025-01-22T19:04:36.5391429",
                        "deleted_at": "2025-01-22T19:04:36.5391429"
                    }
                }
    """;

    public static final String GET_ALL_FEES_EXAMPLE = """
        {
                     "status": "success",
                     "meta": {
                         "code": 200,
                         "details": "Fees retrieved successfully",
                         "timestamp": "2025-01-22T18:59:33.9243384"
                     },
                     "data": {
                         "pagination": {
                             "current_page": 1,
                             "per_page": 10,
                             "total": 7,
                             "last_page": 1,
                             "next_page_url": null,
                             "prev_page_url": null
                         },
                         "items": [
                             {
                                 "id": 15,
                                 "practitioner_id": "3ea5b334-050d-47c2-8647-24380557243d",
                                 "practitioner_name": "Mr Nishanth K",
                                 "speciality": "Heart Specialist",
                                 "location_id": "89c39e4b-ca98-4359-aedf-e5a49e19c249",
                                 "location_name": "Room 101",
                                 "fees_type": "Emergency Care",
                                 "service_category": "Aged Care Assessment",
                                 "measurement": "hourly",
                                 "tax_id": 13,
                                 "tax_type": "GST",
                                 "tax_rate": 18.00,
                                 "rate": 200.00,
                                 "description": "For Consulting",
                                 "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                                 "created_at": "2025-01-02T11:16:31.522908",
                                 "updated_at": "2025-01-02T11:16:31.522908"
                             }
                         ],
                         "columns": {
                             "id": "ID",
                             "practitioner_id": "PRACTITIONER ID",
                             "practitioner_name": "PRACTITIONER NAME",
                             "speciality": "SPECIALITY",
                             "location_id": "LOCATION ID",
                             "location_name": "LOCATION NAME",
                             "fees_type": "FEES TYPE",
                             "service_category": "SERVICE CATEGORY",
                             "measurement": "MEASUREMENT",
                             "tax_id": "TAX ID",
                             "tax_type": "TAX TYPE",
                             "tax_rate": "TAX RATE",
                             "rate": "RATE",
                             "description": "DESCRIPTION",
                             "created_by": "CREATED BY",
                             "created_at": "CREATED AT",
                             "updated_at": "UPDATED AT"
                         }
                     }
                 }
    """;

    public static final String GET_FEES_BY_ID_EXAMPLE = """
       {
                     "status": "success",
                     "meta": {
                         "code": 200,
                         "details": "Fees retrieved successfully",
                         "timestamp": "2025-01-22T19:01:18.666556"
                     },
                     "data": {
                         "id": 43,
                         "practitioner_id": "e5de3e7c-ee7f-4dd2-bae7-d6200ceee38d",
                         "practitioner_name": "Mr Vignesh k",
                         "speciality": "Heart Specialist",
                         "location_id": "9a314bbc-d226-4a52-9cea-7fb5c8894ce8",
                         "location_name": "Room 103",
                         "fees_type": null,
                         "service_category": "Aged Care Information/Referral",
                         "measurement": "hourly",
                         "tax_id": 13,
                         "tax_type": "GST",
                         "tax_rate": 18.00,
                         "rate": 12.00,
                         "description": "test",
                         "created_by": "Aishwariya Arumugam",
                         "created_at": "2025-01-21T11:33:39.482839",
                         "updated_at": "2025-01-21T11:33:39.482839"
                     }
                 }
    """;

    public static final String UPDATE_FEES_EXAMPLE = """
        {
                    "status": "success",
                    "meta": {
                        "code": 200,
                        "details": "Fees updated successfully",
                        "timestamp": "2025-01-23T09:31:38.0524196"
                    },
                    "data": {
                        "id": 43,
                        "practitioner_id": "e5de3e7c-ee7f-4dd2-bae7-d6200ceee38d",
                        "speciality": "Heart Specialist",
                        "location_id": "9a314bbc-d226-4a52-9cea-7fb5c8894ce8",
                        "fees_type_id": "5d92db02-ac11-40a6-a9f7-9c46700d0780",
                        "fees_type_name": "Massage",
                        "service_category": "Aged Care Information/Referral",
                        "measurement": "hourly",
                        "tax": {
                            "id": 13,
                            "type": "GST",
                            "rate": 18.00,
                            "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"
                        },
                        "rate": 12,
                        "description": "test",
                        "created_by": "0d5d2ca9-87ac-4a06-afde-d6f665a23be8",
                        "tenant": "Arise_Tenant",
                        "created_at": "2025-01-21T11:33:39.482839",
                        "updated_at": "2025-01-21T11:33:39.482839",
                        "deleted_at": "2025-01-21T11:33:39.482839"
                    }
                }
    """;

    public static final String INTERNAL_SERVER_ERROR_EXAMPLE = """
        {
            "status": "error",
            "meta": {
                "code": 500,
                "details": "Internal Server Error",
                "timestamp": "2025-01-22T18:40:29.6563483"
            }
        }
    """;

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

    // Modular Annotations for Each API
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = CREATE_FEES_SUMMARY,
            description = CREATE_FEES_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.FeesRequest.class),
                            examples = @ExampleObject(value = CREATE_FEES_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "201",
                            description = "Fee record created successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = CREATE_FEES_EXAMPLE)
                            )
                    )
            }
    )
    public @interface CreateFeesOperation {}

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

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

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = UPDATE_FEES_SUMMARY,
            description = UPDATE_FEES_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.product.requestmodel.FeesRequest.class),
                            examples = @ExampleObject(value = UPDATE_FEES_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(

                            responseCode = "200",
                            description = "Fee record updated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = com.nebula.erp.product.utility.ApiResponse.class),
                                    examples = @ExampleObject(value = UPDATE_FEES_EXAMPLE)
                            )
                    )
            }
    )
    public @interface UpdateFeesOperation {}
}
