# coding: utf-8

"""
    BeeL Public API

    Public invoicing API for self-employed professionals in Spain with full VeriFactu support.  **Authentication:** This API uses **API Keys** for authentication. Endpoints are designed for external integrations, automation, and programmatic access.  For browser-based authentication, use the Private API (with Session Cookies).  **Key Features:** - VeriFactu regulatory compliance - Complete invoice management (standard, corrective, simplified) - Customer management - Tax and invoice series configuration - PDF generation - Email sending - Duplicate prevention (idempotency)  **Idempotency:** Creation endpoints (POST) support the `Idempotency-Key` header to prevent duplicates in case of retries.  **Identifiers:** - All resources use UUIDs for technical identification - Invoice numbers are human-readable and searchable 

    The version of the OpenAPI document: 1.0.0
    Contact: it@beel.es
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from datetime import date
from pydantic import Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Optional, Union
from typing_extensions import Annotated
from beel_generated.models.create_invoice201_response import CreateInvoice201Response
from beel_generated.models.create_invoice_request import CreateInvoiceRequest
from beel_generated.models.duplicate_invoice_request import DuplicateInvoiceRequest
from beel_generated.models.invoice_status import InvoiceStatus
from beel_generated.models.invoice_type import InvoiceType
from beel_generated.models.list_invoices200_response import ListInvoices200Response
from beel_generated.models.update_invoice_request import UpdateInvoiceRequest

from beel_generated.api_client import ApiClient, RequestSerialized
from beel_generated.api_response import ApiResponse
from beel_generated.rest import RESTResponseType


class InvoicesApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def create_invoice(
        self,
        create_invoice_request: CreateInvoiceRequest,
        idempotency_key: Annotated[Optional[StrictStr], Field(description="UUID to prevent duplicates (recommended)")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> CreateInvoice201Response:
        """Create invoice

        Creates a new invoice.  **Idempotency:** Supports `Idempotency-Key` header to prevent duplicates. 

        :param create_invoice_request: (required)
        :type create_invoice_request: CreateInvoiceRequest
        :param idempotency_key: UUID to prevent duplicates (recommended)
        :type idempotency_key: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_invoice_serialize(
            create_invoice_request=create_invoice_request,
            idempotency_key=idempotency_key,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '409': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def create_invoice_with_http_info(
        self,
        create_invoice_request: CreateInvoiceRequest,
        idempotency_key: Annotated[Optional[StrictStr], Field(description="UUID to prevent duplicates (recommended)")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[CreateInvoice201Response]:
        """Create invoice

        Creates a new invoice.  **Idempotency:** Supports `Idempotency-Key` header to prevent duplicates. 

        :param create_invoice_request: (required)
        :type create_invoice_request: CreateInvoiceRequest
        :param idempotency_key: UUID to prevent duplicates (recommended)
        :type idempotency_key: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_invoice_serialize(
            create_invoice_request=create_invoice_request,
            idempotency_key=idempotency_key,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '409': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def create_invoice_without_preload_content(
        self,
        create_invoice_request: CreateInvoiceRequest,
        idempotency_key: Annotated[Optional[StrictStr], Field(description="UUID to prevent duplicates (recommended)")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Create invoice

        Creates a new invoice.  **Idempotency:** Supports `Idempotency-Key` header to prevent duplicates. 

        :param create_invoice_request: (required)
        :type create_invoice_request: CreateInvoiceRequest
        :param idempotency_key: UUID to prevent duplicates (recommended)
        :type idempotency_key: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_invoice_serialize(
            create_invoice_request=create_invoice_request,
            idempotency_key=idempotency_key,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '409': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _create_invoice_serialize(
        self,
        create_invoice_request,
        idempotency_key,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        # process the header parameters
        if idempotency_key is not None:
            _header_params['Idempotency-Key'] = idempotency_key
        # process the form parameters
        # process the body parameter
        if create_invoice_request is not None:
            _body_params = create_invoice_request


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v1/invoices',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def delete_invoice(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> None:
        """Delete invoice

        Deletes (marks as deleted) an invoice.  **Soft delete:** The invoice is not physically deleted, only marked as deleted.  **Restriction:** Only invoices in `DRAFT` status can be deleted. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '204': None,
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_invoice_with_http_info(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[None]:
        """Delete invoice

        Deletes (marks as deleted) an invoice.  **Soft delete:** The invoice is not physically deleted, only marked as deleted.  **Restriction:** Only invoices in `DRAFT` status can be deleted. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '204': None,
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def delete_invoice_without_preload_content(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Delete invoice

        Deletes (marks as deleted) an invoice.  **Soft delete:** The invoice is not physically deleted, only marked as deleted.  **Restriction:** Only invoices in `DRAFT` status can be deleted. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '204': None,
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _delete_invoice_serialize(
        self,
        invoice_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if invoice_id is not None:
            _path_params['invoice_id'] = invoice_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/v1/invoices/{invoice_id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def duplicate_invoice(
        self,
        invoice_id: Annotated[StrictStr, Field(description="ID of the invoice to duplicate")],
        duplicate_invoice_request: Optional[DuplicateInvoiceRequest] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> CreateInvoice201Response:
        """Duplicate invoice as draft

        Creates a copy of an existing invoice as a new draft.  **Use case:** Quickly create a new invoice based on an existing one, useful for recurring invoices to the same client.  **What is copied:** - Client data (recipient) - Invoice lines (descriptions, quantities, prices, taxes) - Payment method - Series (if specified, otherwise uses default) - Observations  **What is NOT copied (reset to defaults):** - Invoice number (null - assigned when issued) - Status (always DRAFT) - Issue date (defaults to today, can be overridden) - Due date (recalculated based on new issue date) - VeriFactu data - PDF - Payment date - Sent date  **Result:** A new draft invoice ready for review and emission. 

        :param invoice_id: ID of the invoice to duplicate (required)
        :type invoice_id: str
        :param duplicate_invoice_request:
        :type duplicate_invoice_request: DuplicateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._duplicate_invoice_serialize(
            invoice_id=invoice_id,
            duplicate_invoice_request=duplicate_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def duplicate_invoice_with_http_info(
        self,
        invoice_id: Annotated[StrictStr, Field(description="ID of the invoice to duplicate")],
        duplicate_invoice_request: Optional[DuplicateInvoiceRequest] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[CreateInvoice201Response]:
        """Duplicate invoice as draft

        Creates a copy of an existing invoice as a new draft.  **Use case:** Quickly create a new invoice based on an existing one, useful for recurring invoices to the same client.  **What is copied:** - Client data (recipient) - Invoice lines (descriptions, quantities, prices, taxes) - Payment method - Series (if specified, otherwise uses default) - Observations  **What is NOT copied (reset to defaults):** - Invoice number (null - assigned when issued) - Status (always DRAFT) - Issue date (defaults to today, can be overridden) - Due date (recalculated based on new issue date) - VeriFactu data - PDF - Payment date - Sent date  **Result:** A new draft invoice ready for review and emission. 

        :param invoice_id: ID of the invoice to duplicate (required)
        :type invoice_id: str
        :param duplicate_invoice_request:
        :type duplicate_invoice_request: DuplicateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._duplicate_invoice_serialize(
            invoice_id=invoice_id,
            duplicate_invoice_request=duplicate_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def duplicate_invoice_without_preload_content(
        self,
        invoice_id: Annotated[StrictStr, Field(description="ID of the invoice to duplicate")],
        duplicate_invoice_request: Optional[DuplicateInvoiceRequest] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Duplicate invoice as draft

        Creates a copy of an existing invoice as a new draft.  **Use case:** Quickly create a new invoice based on an existing one, useful for recurring invoices to the same client.  **What is copied:** - Client data (recipient) - Invoice lines (descriptions, quantities, prices, taxes) - Payment method - Series (if specified, otherwise uses default) - Observations  **What is NOT copied (reset to defaults):** - Invoice number (null - assigned when issued) - Status (always DRAFT) - Issue date (defaults to today, can be overridden) - Due date (recalculated based on new issue date) - VeriFactu data - PDF - Payment date - Sent date  **Result:** A new draft invoice ready for review and emission. 

        :param invoice_id: ID of the invoice to duplicate (required)
        :type invoice_id: str
        :param duplicate_invoice_request:
        :type duplicate_invoice_request: DuplicateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._duplicate_invoice_serialize(
            invoice_id=invoice_id,
            duplicate_invoice_request=duplicate_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '201': "CreateInvoice201Response",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _duplicate_invoice_serialize(
        self,
        invoice_id,
        duplicate_invoice_request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if invoice_id is not None:
            _path_params['invoice_id'] = invoice_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if duplicate_invoice_request is not None:
            _body_params = duplicate_invoice_request


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v1/invoices/{invoice_id}/duplicate',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def get_invoice(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> CreateInvoice201Response:
        """Get invoice by ID

        Retrieves complete details of a specific invoice

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_invoice_with_http_info(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[CreateInvoice201Response]:
        """Get invoice by ID

        Retrieves complete details of a specific invoice

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_invoice_without_preload_content(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get invoice by ID

        Retrieves complete details of a specific invoice

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_invoice_serialize(
            invoice_id=invoice_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_invoice_serialize(
        self,
        invoice_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if invoice_id is not None:
            _path_params['invoice_id'] = invoice_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/invoices/{invoice_id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def list_invoices(
        self,
        page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="Page number (starts at 1)")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Number of items per page")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)")] = None,
        status: Annotated[Optional[InvoiceStatus], Field(description="Filter by invoice status")] = None,
        type: Annotated[Optional[InvoiceType], Field(description="Filter by invoice type")] = None,
        customer_id: Annotated[Optional[StrictStr], Field(description="Filter by client UUID")] = None,
        date_from: Annotated[Optional[date], Field(description="Issue date from (YYYY-MM-DD)")] = None,
        date_to: Annotated[Optional[date], Field(description="Issue date to (YYYY-MM-DD)")] = None,
        invoice_number: Annotated[Optional[StrictStr], Field(description="Search by invoice number (e.g., 2025/0001)")] = None,
        recipient_name: Annotated[Optional[StrictStr], Field(description="Filter by recipient's fiscal name (partial, case-insensitive search)")] = None,
        recipient_nif: Annotated[Optional[StrictStr], Field(description="Filter by recipient's NIF (partial search)")] = None,
        series_code: Annotated[Optional[StrictStr], Field(description="Filter by series code")] = None,
        taxable_base_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum taxable base")] = None,
        taxable_base_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum taxable base")] = None,
        total_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum invoice total")] = None,
        total_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum invoice total")] = None,
        verifactu_status: Annotated[Optional[StrictStr], Field(description="Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT ")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort by (e.g., issue_date, invoice_number, invoice_total)")] = None,
        sort_order: Annotated[Optional[StrictStr], Field(description="Sort direction")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ListInvoices200Response:
        """List invoices

        Returns a paginated list of invoices with optional filters

        :param page: Page number (starts at 1)
        :type page: int
        :param limit: Number of items per page
        :type limit: int
        :param search: Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)
        :type search: str
        :param status: Filter by invoice status
        :type status: InvoiceStatus
        :param type: Filter by invoice type
        :type type: InvoiceType
        :param customer_id: Filter by client UUID
        :type customer_id: str
        :param date_from: Issue date from (YYYY-MM-DD)
        :type date_from: date
        :param date_to: Issue date to (YYYY-MM-DD)
        :type date_to: date
        :param invoice_number: Search by invoice number (e.g., 2025/0001)
        :type invoice_number: str
        :param recipient_name: Filter by recipient's fiscal name (partial, case-insensitive search)
        :type recipient_name: str
        :param recipient_nif: Filter by recipient's NIF (partial search)
        :type recipient_nif: str
        :param series_code: Filter by series code
        :type series_code: str
        :param taxable_base_min: Minimum taxable base
        :type taxable_base_min: float
        :param taxable_base_max: Maximum taxable base
        :type taxable_base_max: float
        :param total_min: Minimum invoice total
        :type total_min: float
        :param total_max: Maximum invoice total
        :type total_max: float
        :param verifactu_status: Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT 
        :type verifactu_status: str
        :param sort_by: Field to sort by (e.g., issue_date, invoice_number, invoice_total)
        :type sort_by: str
        :param sort_order: Sort direction
        :type sort_order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_invoices_serialize(
            page=page,
            limit=limit,
            search=search,
            status=status,
            type=type,
            customer_id=customer_id,
            date_from=date_from,
            date_to=date_to,
            invoice_number=invoice_number,
            recipient_name=recipient_name,
            recipient_nif=recipient_nif,
            series_code=series_code,
            taxable_base_min=taxable_base_min,
            taxable_base_max=taxable_base_max,
            total_min=total_min,
            total_max=total_max,
            verifactu_status=verifactu_status,
            sort_by=sort_by,
            sort_order=sort_order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListInvoices200Response",
            '401': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def list_invoices_with_http_info(
        self,
        page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="Page number (starts at 1)")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Number of items per page")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)")] = None,
        status: Annotated[Optional[InvoiceStatus], Field(description="Filter by invoice status")] = None,
        type: Annotated[Optional[InvoiceType], Field(description="Filter by invoice type")] = None,
        customer_id: Annotated[Optional[StrictStr], Field(description="Filter by client UUID")] = None,
        date_from: Annotated[Optional[date], Field(description="Issue date from (YYYY-MM-DD)")] = None,
        date_to: Annotated[Optional[date], Field(description="Issue date to (YYYY-MM-DD)")] = None,
        invoice_number: Annotated[Optional[StrictStr], Field(description="Search by invoice number (e.g., 2025/0001)")] = None,
        recipient_name: Annotated[Optional[StrictStr], Field(description="Filter by recipient's fiscal name (partial, case-insensitive search)")] = None,
        recipient_nif: Annotated[Optional[StrictStr], Field(description="Filter by recipient's NIF (partial search)")] = None,
        series_code: Annotated[Optional[StrictStr], Field(description="Filter by series code")] = None,
        taxable_base_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum taxable base")] = None,
        taxable_base_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum taxable base")] = None,
        total_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum invoice total")] = None,
        total_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum invoice total")] = None,
        verifactu_status: Annotated[Optional[StrictStr], Field(description="Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT ")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort by (e.g., issue_date, invoice_number, invoice_total)")] = None,
        sort_order: Annotated[Optional[StrictStr], Field(description="Sort direction")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[ListInvoices200Response]:
        """List invoices

        Returns a paginated list of invoices with optional filters

        :param page: Page number (starts at 1)
        :type page: int
        :param limit: Number of items per page
        :type limit: int
        :param search: Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)
        :type search: str
        :param status: Filter by invoice status
        :type status: InvoiceStatus
        :param type: Filter by invoice type
        :type type: InvoiceType
        :param customer_id: Filter by client UUID
        :type customer_id: str
        :param date_from: Issue date from (YYYY-MM-DD)
        :type date_from: date
        :param date_to: Issue date to (YYYY-MM-DD)
        :type date_to: date
        :param invoice_number: Search by invoice number (e.g., 2025/0001)
        :type invoice_number: str
        :param recipient_name: Filter by recipient's fiscal name (partial, case-insensitive search)
        :type recipient_name: str
        :param recipient_nif: Filter by recipient's NIF (partial search)
        :type recipient_nif: str
        :param series_code: Filter by series code
        :type series_code: str
        :param taxable_base_min: Minimum taxable base
        :type taxable_base_min: float
        :param taxable_base_max: Maximum taxable base
        :type taxable_base_max: float
        :param total_min: Minimum invoice total
        :type total_min: float
        :param total_max: Maximum invoice total
        :type total_max: float
        :param verifactu_status: Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT 
        :type verifactu_status: str
        :param sort_by: Field to sort by (e.g., issue_date, invoice_number, invoice_total)
        :type sort_by: str
        :param sort_order: Sort direction
        :type sort_order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_invoices_serialize(
            page=page,
            limit=limit,
            search=search,
            status=status,
            type=type,
            customer_id=customer_id,
            date_from=date_from,
            date_to=date_to,
            invoice_number=invoice_number,
            recipient_name=recipient_name,
            recipient_nif=recipient_nif,
            series_code=series_code,
            taxable_base_min=taxable_base_min,
            taxable_base_max=taxable_base_max,
            total_min=total_min,
            total_max=total_max,
            verifactu_status=verifactu_status,
            sort_by=sort_by,
            sort_order=sort_order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListInvoices200Response",
            '401': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def list_invoices_without_preload_content(
        self,
        page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="Page number (starts at 1)")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Number of items per page")] = None,
        search: Annotated[Optional[StrictStr], Field(description="Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)")] = None,
        status: Annotated[Optional[InvoiceStatus], Field(description="Filter by invoice status")] = None,
        type: Annotated[Optional[InvoiceType], Field(description="Filter by invoice type")] = None,
        customer_id: Annotated[Optional[StrictStr], Field(description="Filter by client UUID")] = None,
        date_from: Annotated[Optional[date], Field(description="Issue date from (YYYY-MM-DD)")] = None,
        date_to: Annotated[Optional[date], Field(description="Issue date to (YYYY-MM-DD)")] = None,
        invoice_number: Annotated[Optional[StrictStr], Field(description="Search by invoice number (e.g., 2025/0001)")] = None,
        recipient_name: Annotated[Optional[StrictStr], Field(description="Filter by recipient's fiscal name (partial, case-insensitive search)")] = None,
        recipient_nif: Annotated[Optional[StrictStr], Field(description="Filter by recipient's NIF (partial search)")] = None,
        series_code: Annotated[Optional[StrictStr], Field(description="Filter by series code")] = None,
        taxable_base_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum taxable base")] = None,
        taxable_base_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum taxable base")] = None,
        total_min: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Minimum invoice total")] = None,
        total_max: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Maximum invoice total")] = None,
        verifactu_status: Annotated[Optional[StrictStr], Field(description="Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT ")] = None,
        sort_by: Annotated[Optional[StrictStr], Field(description="Field to sort by (e.g., issue_date, invoice_number, invoice_total)")] = None,
        sort_order: Annotated[Optional[StrictStr], Field(description="Sort direction")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """List invoices

        Returns a paginated list of invoices with optional filters

        :param page: Page number (starts at 1)
        :type page: int
        :param limit: Number of items per page
        :type limit: int
        :param search: Global search across invoice number, recipient name, recipient NIF, and series code (partial, case-insensitive)
        :type search: str
        :param status: Filter by invoice status
        :type status: InvoiceStatus
        :param type: Filter by invoice type
        :type type: InvoiceType
        :param customer_id: Filter by client UUID
        :type customer_id: str
        :param date_from: Issue date from (YYYY-MM-DD)
        :type date_from: date
        :param date_to: Issue date to (YYYY-MM-DD)
        :type date_to: date
        :param invoice_number: Search by invoice number (e.g., 2025/0001)
        :type invoice_number: str
        :param recipient_name: Filter by recipient's fiscal name (partial, case-insensitive search)
        :type recipient_name: str
        :param recipient_nif: Filter by recipient's NIF (partial search)
        :type recipient_nif: str
        :param series_code: Filter by series code
        :type series_code: str
        :param taxable_base_min: Minimum taxable base
        :type taxable_base_min: float
        :param taxable_base_max: Maximum taxable base
        :type taxable_base_max: float
        :param total_min: Minimum invoice total
        :type total_min: float
        :param total_max: Maximum invoice total
        :type total_max: float
        :param verifactu_status: Filter by VeriFactu status. Special values: - \"NO_VERIFACTU\": Invoices where VeriFactu is not enabled - \"PENDING\": Invoices with VeriFactu enabled pending submission - \"ACCEPTED\": Invoices submitted and accepted by AEAT - \"REJECTED\": Invoices submitted and rejected by AEAT 
        :type verifactu_status: str
        :param sort_by: Field to sort by (e.g., issue_date, invoice_number, invoice_total)
        :type sort_by: str
        :param sort_order: Sort direction
        :type sort_order: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._list_invoices_serialize(
            page=page,
            limit=limit,
            search=search,
            status=status,
            type=type,
            customer_id=customer_id,
            date_from=date_from,
            date_to=date_to,
            invoice_number=invoice_number,
            recipient_name=recipient_name,
            recipient_nif=recipient_nif,
            series_code=series_code,
            taxable_base_min=taxable_base_min,
            taxable_base_max=taxable_base_max,
            total_min=total_min,
            total_max=total_max,
            verifactu_status=verifactu_status,
            sort_by=sort_by,
            sort_order=sort_order,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ListInvoices200Response",
            '401': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _list_invoices_serialize(
        self,
        page,
        limit,
        search,
        status,
        type,
        customer_id,
        date_from,
        date_to,
        invoice_number,
        recipient_name,
        recipient_nif,
        series_code,
        taxable_base_min,
        taxable_base_max,
        total_min,
        total_max,
        verifactu_status,
        sort_by,
        sort_order,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if page is not None:
            
            _query_params.append(('page', page))
            
        if limit is not None:
            
            _query_params.append(('limit', limit))
            
        if search is not None:
            
            _query_params.append(('search', search))
            
        if status is not None:
            
            _query_params.append(('status', status.value))
            
        if type is not None:
            
            _query_params.append(('type', type.value))
            
        if customer_id is not None:
            
            _query_params.append(('customer_id', customer_id))
            
        if date_from is not None:
            if isinstance(date_from, date):
                _query_params.append(
                    (
                        'date_from',
                        date_from.strftime(
                            self.api_client.configuration.date_format
                        )
                    )
                )
            else:
                _query_params.append(('date_from', date_from))
            
        if date_to is not None:
            if isinstance(date_to, date):
                _query_params.append(
                    (
                        'date_to',
                        date_to.strftime(
                            self.api_client.configuration.date_format
                        )
                    )
                )
            else:
                _query_params.append(('date_to', date_to))
            
        if invoice_number is not None:
            
            _query_params.append(('invoice_number', invoice_number))
            
        if recipient_name is not None:
            
            _query_params.append(('recipient_name', recipient_name))
            
        if recipient_nif is not None:
            
            _query_params.append(('recipient_nif', recipient_nif))
            
        if series_code is not None:
            
            _query_params.append(('series_code', series_code))
            
        if taxable_base_min is not None:
            
            _query_params.append(('taxable_base_min', taxable_base_min))
            
        if taxable_base_max is not None:
            
            _query_params.append(('taxable_base_max', taxable_base_max))
            
        if total_min is not None:
            
            _query_params.append(('total_min', total_min))
            
        if total_max is not None:
            
            _query_params.append(('total_max', total_max))
            
        if verifactu_status is not None:
            
            _query_params.append(('verifactu_status', verifactu_status))
            
        if sort_by is not None:
            
            _query_params.append(('sort_by', sort_by))
            
        if sort_order is not None:
            
            _query_params.append(('sort_order', sort_order))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/invoices',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def update_invoice(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        update_invoice_request: UpdateInvoiceRequest,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> CreateInvoice201Response:
        """Update invoice

        Updates an existing draft invoice.  **Restriction:** Only invoices in `DRAFT` status can be modified. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param update_invoice_request: (required)
        :type update_invoice_request: UpdateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_invoice_serialize(
            invoice_id=invoice_id,
            update_invoice_request=update_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def update_invoice_with_http_info(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        update_invoice_request: UpdateInvoiceRequest,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[CreateInvoice201Response]:
        """Update invoice

        Updates an existing draft invoice.  **Restriction:** Only invoices in `DRAFT` status can be modified. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param update_invoice_request: (required)
        :type update_invoice_request: UpdateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_invoice_serialize(
            invoice_id=invoice_id,
            update_invoice_request=update_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def update_invoice_without_preload_content(
        self,
        invoice_id: Annotated[StrictStr, Field(description="Invoice ID")],
        update_invoice_request: UpdateInvoiceRequest,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Update invoice

        Updates an existing draft invoice.  **Restriction:** Only invoices in `DRAFT` status can be modified. 

        :param invoice_id: Invoice ID (required)
        :type invoice_id: str
        :param update_invoice_request: (required)
        :type update_invoice_request: UpdateInvoiceRequest
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_invoice_serialize(
            invoice_id=invoice_id,
            update_invoice_request=update_invoice_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "CreateInvoice201Response",
            '400': "CreateInvoice400Response",
            '401': "ErrorResponse",
            '404': "ErrorResponse",
            '422': "ErrorResponse",
            '500': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _update_invoice_serialize(
        self,
        invoice_id,
        update_invoice_request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if invoice_id is not None:
            _path_params['invoice_id'] = invoice_id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if update_invoice_request is not None:
            _body_params = update_invoice_request


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'ApiKeyAuth'
        ]

        return self.api_client.param_serialize(
            method='PUT',
            resource_path='/v1/invoices/{invoice_id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )


