# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.file_content_ftype import FileContentFtype
from .raw_client import AsyncRawOcrClient, RawOcrClient
from .types.payabli_api_response_ocr import PayabliApiResponseOcr
from .types.type_result import TypeResult

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class OcrClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawOcrClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawOcrClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawOcrClient
        """
        return self._raw_client

    def ocr_document_form(
        self,
        type_result: TypeResult,
        *,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        filename: typing.Optional[str] = OMIT,
        furl: typing.Optional[str] = OMIT,
        f_content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseOcr:
        """
        Use this endpoint to upload an image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more.

        Parameters
        ----------
        type_result : TypeResult

        ftype : typing.Optional[FileContentFtype]

        filename : typing.Optional[str]
            The name of the file to be uploaded

        furl : typing.Optional[str]
            Optional URL link to the file

        f_content : typing.Optional[str]
            Base64-encoded file content

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PayabliApiResponseOcr
            OCR document processing result

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.ocr.ocr_document_form(
            type_result="typeResult",
        )
        """
        _response = self._raw_client.ocr_document_form(
            type_result, ftype=ftype, filename=filename, furl=furl, f_content=f_content, request_options=request_options
        )
        return _response.data

    def ocr_document_json(
        self,
        type_result: TypeResult,
        *,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        filename: typing.Optional[str] = OMIT,
        furl: typing.Optional[str] = OMIT,
        f_content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseOcr:
        """
        Use this endpoint to submit a Base64-encoded image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more.

        Parameters
        ----------
        type_result : TypeResult

        ftype : typing.Optional[FileContentFtype]

        filename : typing.Optional[str]
            The name of the file to be uploaded

        furl : typing.Optional[str]
            Optional URL link to the file

        f_content : typing.Optional[str]
            Base64-encoded file content

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PayabliApiResponseOcr
            OCR document processing result

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.ocr.ocr_document_json(
            type_result="typeResult",
        )
        """
        _response = self._raw_client.ocr_document_json(
            type_result, ftype=ftype, filename=filename, furl=furl, f_content=f_content, request_options=request_options
        )
        return _response.data


class AsyncOcrClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawOcrClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawOcrClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawOcrClient
        """
        return self._raw_client

    async def ocr_document_form(
        self,
        type_result: TypeResult,
        *,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        filename: typing.Optional[str] = OMIT,
        furl: typing.Optional[str] = OMIT,
        f_content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseOcr:
        """
        Use this endpoint to upload an image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more.

        Parameters
        ----------
        type_result : TypeResult

        ftype : typing.Optional[FileContentFtype]

        filename : typing.Optional[str]
            The name of the file to be uploaded

        furl : typing.Optional[str]
            Optional URL link to the file

        f_content : typing.Optional[str]
            Base64-encoded file content

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PayabliApiResponseOcr
            OCR document processing result

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.ocr.ocr_document_form(
                type_result="typeResult",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.ocr_document_form(
            type_result, ftype=ftype, filename=filename, furl=furl, f_content=f_content, request_options=request_options
        )
        return _response.data

    async def ocr_document_json(
        self,
        type_result: TypeResult,
        *,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        filename: typing.Optional[str] = OMIT,
        furl: typing.Optional[str] = OMIT,
        f_content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseOcr:
        """
        Use this endpoint to submit a Base64-encoded image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more.

        Parameters
        ----------
        type_result : TypeResult

        ftype : typing.Optional[FileContentFtype]

        filename : typing.Optional[str]
            The name of the file to be uploaded

        furl : typing.Optional[str]
            Optional URL link to the file

        f_content : typing.Optional[str]
            Base64-encoded file content

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PayabliApiResponseOcr
            OCR document processing result

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.ocr.ocr_document_json(
                type_result="typeResult",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.ocr_document_json(
            type_result, ftype=ftype, filename=filename, furl=furl, f_content=f_content, request_options=request_options
        )
        return _response.data
