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

import typing

from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.entrypointfield import Entrypointfield
from ..types.payabli_api_response_import import PayabliApiResponseImport
from .raw_client import AsyncRawImportClient, RawImportClient

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


class ImportClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawImportClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawImportClient
        """
        return self._raw_client

    def import_bills(
        self, entry: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseImport:
        """
        Import a list of bills from a CSV file. See the [Import Guide](/developers/developer-guides/bills-add#import-bills) for more help and an example file.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        PayabliApiResponseImport
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.import_.import_bills(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.import_bills(entry, file=file, request_options=request_options)
        return _response.data

    def import_customer(
        self,
        entry: Entrypointfield,
        *,
        file: core.File,
        replace_existing: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseImport:
        """
        Import a list of customers from a CSV file. See the [Import Guide](/developers/developer-guides/entities-customers#import-customers) for more help and example files.

        Parameters
        ----------
        entry : Entrypointfield

        file : core.File
            See core.File for more documentation

        replace_existing : typing.Optional[int]
            Flag indicating to replace existing customer with a new record. Possible values: 0 (do not replace), 1 (replace). Default is 0

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

        Returns
        -------
        PayabliApiResponseImport
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.import_.import_customer(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.import_customer(
            entry, file=file, replace_existing=replace_existing, request_options=request_options
        )
        return _response.data

    def import_vendor(
        self, entry: Entrypointfield, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseImport:
        """
        Import a list of vendors from a CSV file. See the [Import Guide](/developers/developer-guides/entities-vendors#import-vendors) for more help and example files.

        Parameters
        ----------
        entry : Entrypointfield

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        PayabliApiResponseImport
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.import_.import_vendor(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.import_vendor(entry, file=file, request_options=request_options)
        return _response.data


class AsyncImportClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawImportClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawImportClient
        """
        return self._raw_client

    async def import_bills(
        self, entry: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseImport:
        """
        Import a list of bills from a CSV file. See the [Import Guide](/developers/developer-guides/bills-add#import-bills) for more help and an example file.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        PayabliApiResponseImport
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_.import_bills(
                entry="8cfec329267",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.import_bills(entry, file=file, request_options=request_options)
        return _response.data

    async def import_customer(
        self,
        entry: Entrypointfield,
        *,
        file: core.File,
        replace_existing: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponseImport:
        """
        Import a list of customers from a CSV file. See the [Import Guide](/developers/developer-guides/entities-customers#import-customers) for more help and example files.

        Parameters
        ----------
        entry : Entrypointfield

        file : core.File
            See core.File for more documentation

        replace_existing : typing.Optional[int]
            Flag indicating to replace existing customer with a new record. Possible values: 0 (do not replace), 1 (replace). Default is 0

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

        Returns
        -------
        PayabliApiResponseImport
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_.import_customer(
                entry="8cfec329267",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.import_customer(
            entry, file=file, replace_existing=replace_existing, request_options=request_options
        )
        return _response.data

    async def import_vendor(
        self, entry: Entrypointfield, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseImport:
        """
        Import a list of vendors from a CSV file. See the [Import Guide](/developers/developer-guides/entities-vendors#import-vendors) for more help and example files.

        Parameters
        ----------
        entry : Entrypointfield

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        PayabliApiResponseImport
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_.import_vendor(
                entry="8cfec329267",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.import_vendor(entry, file=file, request_options=request_options)
        return _response.data
