# 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 .raw_client import AsyncRawVendorsClient, RawVendorsClient
from .types.get_vendors_id_response import GetVendorsIdResponse
from .types.get_vendors_root_response import GetVendorsRootResponse
from .types.post_vendors_bulk_request_vendors_item import PostVendorsBulkRequestVendorsItem
from .types.post_vendors_bulk_response import PostVendorsBulkResponse
from .types.post_vendors_root_request_payment_method import PostVendorsRootRequestPaymentMethod
from .types.post_vendors_root_response import PostVendorsRootResponse

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


class VendorsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVendorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVendorsClient
        """
        return self._raw_client

    def get_vendors_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        detail: typing.Optional[typing.Literal["basic"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetVendorsRootResponse:
        """
        Returns a paginated list of accounting vendors, filterable by company. The `detail=basic` query parameter returns a simplified response.

        Parameters
        ----------
        ottimate_company_id : typing.Optional[int]
            Filter vendors by company ID

        detail : typing.Optional[typing.Literal["basic"]]
            Specify the level of detail in the response

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

        Returns
        -------
        GetVendorsRootResponse
            Successful response with paginated vendor list

        Examples
        --------
        from ottimate import Ottimate

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.vendors.get_vendors_root(
            ottimate_company_id=15196,
        )
        """
        _response = self._raw_client.get_vendors_root(
            ottimate_company_id=ottimate_company_id, detail=detail, request_options=request_options
        )
        return _response.data

    def post_vendors_root(
        self,
        *,
        ottimate_company_id: int,
        erp_vendor_name: str,
        erp_vendor_id: str,
        email: typing.Optional[str] = OMIT,
        phone: typing.Optional[str] = OMIT,
        net_terms: typing.Optional[str] = OMIT,
        payment_method: typing.Optional[PostVendorsRootRequestPaymentMethod] = OMIT,
        city: typing.Optional[str] = OMIT,
        state: typing.Optional[str] = OMIT,
        zipcode: typing.Optional[str] = OMIT,
        address_line1: typing.Optional[str] = OMIT,
        address_line2: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostVendorsRootResponse:
        """
        Creates a new vendor with the provided details. The `erp_vendor_id` is required and will be mapped to both `accounting_id` and `dd_unique_key`.

        Parameters
        ----------
        ottimate_company_id : int

        erp_vendor_name : str

        erp_vendor_id : str

        email : typing.Optional[str]

        phone : typing.Optional[str]

        net_terms : typing.Optional[str]

        payment_method : typing.Optional[PostVendorsRootRequestPaymentMethod]
            (Optional) Vendor payment method

        city : typing.Optional[str]
            (Optional) Vendor city

        state : typing.Optional[str]
            (Optional) Vendor state

        zipcode : typing.Optional[str]
            (Optional) Vendor zipcode

        address_line1 : typing.Optional[str]
            (Optional) Vendor address line 1

        address_line2 : typing.Optional[str]
            (Optional) Vendor address line 2

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

        Returns
        -------
        PostVendorsRootResponse
            Successfully created

        Examples
        --------
        from ottimate import Ottimate

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.vendors.post_vendors_root(
            ottimate_company_id=15196,
            erp_vendor_name="New Food Supplier Inc",
            erp_vendor_id="NFS-001",
            email="orders@newfoodsupplier.com",
            phone="+1-555-123-4567",
            net_terms="Net 30",
        )
        """
        _response = self._raw_client.post_vendors_root(
            ottimate_company_id=ottimate_company_id,
            erp_vendor_name=erp_vendor_name,
            erp_vendor_id=erp_vendor_id,
            email=email,
            phone=phone,
            net_terms=net_terms,
            payment_method=payment_method,
            city=city,
            state=state,
            zipcode=zipcode,
            address_line1=address_line1,
            address_line2=address_line2,
            request_options=request_options,
        )
        return _response.data

    def get_vendors_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetVendorsIdResponse:
        """
        Returns detailed information for a single accounting vendor using its unique ID.

        Parameters
        ----------
        id : str
            The unique ID of the vendor

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

        Returns
        -------
        GetVendorsIdResponse
            Successful response with vendor details

        Examples
        --------
        from ottimate import Ottimate

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.vendors.get_vendors_id(
            id="racc_90832490382904802384",
        )
        """
        _response = self._raw_client.get_vendors_id(id, request_options=request_options)
        return _response.data

    def post_vendors_bulk(
        self,
        *,
        ottimate_company_id: int,
        vendors: typing.Optional[typing.Sequence[PostVendorsBulkRequestVendorsItem]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostVendorsBulkResponse:
        """
        Allows for the creation or updating of multiple vendors in a single request. Maximum 100 vendors per request.

        Parameters
        ----------
        ottimate_company_id : int

        vendors : typing.Optional[typing.Sequence[PostVendorsBulkRequestVendorsItem]]

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

        Returns
        -------
        PostVendorsBulkResponse
            Successfully created or updated

        Examples
        --------
        from ottimate import Ottimate
        from ottimate.vendors import PostVendorsBulkRequestVendorsItem

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.vendors.post_vendors_bulk(
            ottimate_company_id=15196,
            vendors=[
                PostVendorsBulkRequestVendorsItem(
                    erp_vendor_name="Local Produce Co",
                    erp_vendor_id="LPC-001",
                    email="orders@localproduce.com",
                    phone="+1-555-111-2222",
                    net_terms="Net 15",
                    payment_method="ach",
                    address_line1="100 Farm Road",
                    city="Springfield",
                    state="IL",
                    zipcode="62701",
                ),
                PostVendorsBulkRequestVendorsItem(
                    erp_vendor_name="Premium Meats LLC",
                    erp_vendor_id="PML-001",
                    email="sales@premiummeats.com",
                    payment_method="check",
                ),
            ],
        )
        """
        _response = self._raw_client.post_vendors_bulk(
            ottimate_company_id=ottimate_company_id, vendors=vendors, request_options=request_options
        )
        return _response.data


class AsyncVendorsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVendorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVendorsClient
        """
        return self._raw_client

    async def get_vendors_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        detail: typing.Optional[typing.Literal["basic"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetVendorsRootResponse:
        """
        Returns a paginated list of accounting vendors, filterable by company. The `detail=basic` query parameter returns a simplified response.

        Parameters
        ----------
        ottimate_company_id : typing.Optional[int]
            Filter vendors by company ID

        detail : typing.Optional[typing.Literal["basic"]]
            Specify the level of detail in the response

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

        Returns
        -------
        GetVendorsRootResponse
            Successful response with paginated vendor list

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate

        client = AsyncOttimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vendors.get_vendors_root(
                ottimate_company_id=15196,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_vendors_root(
            ottimate_company_id=ottimate_company_id, detail=detail, request_options=request_options
        )
        return _response.data

    async def post_vendors_root(
        self,
        *,
        ottimate_company_id: int,
        erp_vendor_name: str,
        erp_vendor_id: str,
        email: typing.Optional[str] = OMIT,
        phone: typing.Optional[str] = OMIT,
        net_terms: typing.Optional[str] = OMIT,
        payment_method: typing.Optional[PostVendorsRootRequestPaymentMethod] = OMIT,
        city: typing.Optional[str] = OMIT,
        state: typing.Optional[str] = OMIT,
        zipcode: typing.Optional[str] = OMIT,
        address_line1: typing.Optional[str] = OMIT,
        address_line2: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostVendorsRootResponse:
        """
        Creates a new vendor with the provided details. The `erp_vendor_id` is required and will be mapped to both `accounting_id` and `dd_unique_key`.

        Parameters
        ----------
        ottimate_company_id : int

        erp_vendor_name : str

        erp_vendor_id : str

        email : typing.Optional[str]

        phone : typing.Optional[str]

        net_terms : typing.Optional[str]

        payment_method : typing.Optional[PostVendorsRootRequestPaymentMethod]
            (Optional) Vendor payment method

        city : typing.Optional[str]
            (Optional) Vendor city

        state : typing.Optional[str]
            (Optional) Vendor state

        zipcode : typing.Optional[str]
            (Optional) Vendor zipcode

        address_line1 : typing.Optional[str]
            (Optional) Vendor address line 1

        address_line2 : typing.Optional[str]
            (Optional) Vendor address line 2

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

        Returns
        -------
        PostVendorsRootResponse
            Successfully created

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate

        client = AsyncOttimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vendors.post_vendors_root(
                ottimate_company_id=15196,
                erp_vendor_name="New Food Supplier Inc",
                erp_vendor_id="NFS-001",
                email="orders@newfoodsupplier.com",
                phone="+1-555-123-4567",
                net_terms="Net 30",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_vendors_root(
            ottimate_company_id=ottimate_company_id,
            erp_vendor_name=erp_vendor_name,
            erp_vendor_id=erp_vendor_id,
            email=email,
            phone=phone,
            net_terms=net_terms,
            payment_method=payment_method,
            city=city,
            state=state,
            zipcode=zipcode,
            address_line1=address_line1,
            address_line2=address_line2,
            request_options=request_options,
        )
        return _response.data

    async def get_vendors_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetVendorsIdResponse:
        """
        Returns detailed information for a single accounting vendor using its unique ID.

        Parameters
        ----------
        id : str
            The unique ID of the vendor

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

        Returns
        -------
        GetVendorsIdResponse
            Successful response with vendor details

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate

        client = AsyncOttimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vendors.get_vendors_id(
                id="racc_90832490382904802384",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_vendors_id(id, request_options=request_options)
        return _response.data

    async def post_vendors_bulk(
        self,
        *,
        ottimate_company_id: int,
        vendors: typing.Optional[typing.Sequence[PostVendorsBulkRequestVendorsItem]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostVendorsBulkResponse:
        """
        Allows for the creation or updating of multiple vendors in a single request. Maximum 100 vendors per request.

        Parameters
        ----------
        ottimate_company_id : int

        vendors : typing.Optional[typing.Sequence[PostVendorsBulkRequestVendorsItem]]

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

        Returns
        -------
        PostVendorsBulkResponse
            Successfully created or updated

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate
        from ottimate.vendors import PostVendorsBulkRequestVendorsItem

        client = AsyncOttimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vendors.post_vendors_bulk(
                ottimate_company_id=15196,
                vendors=[
                    PostVendorsBulkRequestVendorsItem(
                        erp_vendor_name="Local Produce Co",
                        erp_vendor_id="LPC-001",
                        email="orders@localproduce.com",
                        phone="+1-555-111-2222",
                        net_terms="Net 15",
                        payment_method="ach",
                        address_line1="100 Farm Road",
                        city="Springfield",
                        state="IL",
                        zipcode="62701",
                    ),
                    PostVendorsBulkRequestVendorsItem(
                        erp_vendor_name="Premium Meats LLC",
                        erp_vendor_id="PML-001",
                        email="sales@premiummeats.com",
                        payment_method="check",
                    ),
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_vendors_bulk(
            ottimate_company_id=ottimate_company_id, vendors=vendors, request_options=request_options
        )
        return _response.data
