# 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.bulk_upsert_async_response import BulkUpsertAsyncResponse
from ..types.purchase_order_create_response import PurchaseOrderCreateResponse
from ..types.purchase_order_detail import PurchaseOrderDetail
from ..types.purchase_order_update_response import PurchaseOrderUpdateResponse
from .raw_client import AsyncRawPurchaseOrdersClient, RawPurchaseOrdersClient
from .types.get_purchase_orders_root_request_status import GetPurchaseOrdersRootRequestStatus
from .types.get_purchase_orders_root_response import GetPurchaseOrdersRootResponse
from .types.patch_purchase_orders_id_request_items_item import PatchPurchaseOrdersIdRequestItemsItem
from .types.purchase_order_bulk_upsert_request_purchase_orders_item import (
    PurchaseOrderBulkUpsertRequestPurchaseOrdersItem,
)
from .types.purchase_order_create_request_items_item import PurchaseOrderCreateRequestItemsItem

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


class PurchaseOrdersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPurchaseOrdersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPurchaseOrdersClient
        """
        return self._raw_client

    def get_purchase_orders_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        ottimate_location_id: typing.Optional[int] = None,
        erp_vendor_id: typing.Optional[str] = None,
        status: typing.Optional[GetPurchaseOrdersRootRequestStatus] = None,
        date_from: typing.Optional[str] = None,
        date_to: typing.Optional[str] = None,
        expand: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetPurchaseOrdersRootResponse:
        """
        Returns a paginated list of purchase orders, filterable by company, location, vendor, status, and date range.

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

        ottimate_location_id : typing.Optional[int]
            Filter by location ID

        erp_vendor_id : typing.Optional[str]
            Filter by ERP vendor ID (external vendor identifier)

        status : typing.Optional[GetPurchaseOrdersRootRequestStatus]
            Filter by PO status

        date_from : typing.Optional[str]
            Filter by start date (YYYY-MM-DD)

        date_to : typing.Optional[str]
            Filter by end date (YYYY-MM-DD)

        expand : typing.Optional[str]
            Comma-separated list of fields to expand. Supported values: items. When expand=items is used, date_from and date_to must both be provided and within a 30-day window.

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

        Returns
        -------
        GetPurchaseOrdersRootResponse
            Successful response with paginated purchase order list

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.purchase_orders.get_purchase_orders_root(
            ottimate_company_id=15196,
            ottimate_location_id=12345,
            erp_vendor_id="VENDOR-123",
            expand="items",
        )
        """
        _response = self._raw_client.get_purchase_orders_root(
            ottimate_company_id=ottimate_company_id,
            ottimate_location_id=ottimate_location_id,
            erp_vendor_id=erp_vendor_id,
            status=status,
            date_from=date_from,
            date_to=date_to,
            expand=expand,
            request_options=request_options,
        )
        return _response.data

    def post_purchase_orders_root(
        self,
        *,
        ottimate_location_id: int,
        po_number: str,
        erp_vendor_id: str,
        date: str,
        total_amount: float,
        items: typing.Sequence[PurchaseOrderCreateRequestItemsItem],
        external_id: typing.Optional[str] = OMIT,
        erp_vendor_name: typing.Optional[str] = OMIT,
        tax: typing.Optional[float] = OMIT,
        freight: typing.Optional[float] = OMIT,
        miscellaneous_charges: typing.Optional[float] = OMIT,
        invoice_number_ref: typing.Optional[str] = OMIT,
        is2way: typing.Optional[bool] = OMIT,
        custom_fields: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PurchaseOrderCreateResponse:
        """
        Creates a new purchase order with the provided details. The `po_number` field is required and must be provided by the client (no auto-generation).

        Parameters
        ----------
        ottimate_location_id : int

        po_number : str

        erp_vendor_id : str
            External vendor identifier from ERP system

        date : str

        total_amount : float

        items : typing.Sequence[PurchaseOrderCreateRequestItemsItem]

        external_id : typing.Optional[str]

        erp_vendor_name : typing.Optional[str]
            Vendor name from ERP system

        tax : typing.Optional[float]

        freight : typing.Optional[float]

        miscellaneous_charges : typing.Optional[float]

        invoice_number_ref : typing.Optional[str]
            Invoice reference number

        is2way : typing.Optional[bool]
            Whether this is a 2-way match PO

        custom_fields : typing.Optional[typing.Dict[str, typing.Any]]
            Optional custom fields configured for this company's purchase orders

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

        Returns
        -------
        PurchaseOrderCreateResponse
            Successfully created

        Examples
        --------
        from ottimate import Ottimate
        from ottimate.purchase_orders import PurchaseOrderCreateRequestItemsItem

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.purchase_orders.post_purchase_orders_root(
            ottimate_location_id=12345,
            external_id="ERP-PO-001",
            po_number="PO-2024-001",
            erp_vendor_id="VENDOR-123",
            erp_vendor_name="Sysco Foods",
            date="2024-01-15",
            total_amount=1500.0,
            items=[
                PurchaseOrderCreateRequestItemsItem(
                    external_id="ERP-ITEM-001",
                    name="Tomatoes",
                    sku="TOM-001",
                    quantity=100.0,
                    price=2.5,
                )
            ],
            custom_fields={"TransactionId": "EXT-123456", "CustomField2": "value2"},
        )
        """
        _response = self._raw_client.post_purchase_orders_root(
            ottimate_location_id=ottimate_location_id,
            po_number=po_number,
            erp_vendor_id=erp_vendor_id,
            date=date,
            total_amount=total_amount,
            items=items,
            external_id=external_id,
            erp_vendor_name=erp_vendor_name,
            tax=tax,
            freight=freight,
            miscellaneous_charges=miscellaneous_charges,
            invoice_number_ref=invoice_number_ref,
            is2way=is2way,
            custom_fields=custom_fields,
            request_options=request_options,
        )
        return _response.data

    def get_purchase_orders_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PurchaseOrderDetail:
        """
        Returns detailed information for a single purchase order including all line items.

        Parameters
        ----------
        id : str
            The unique ID of the purchase order

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

        Returns
        -------
        PurchaseOrderDetail
            Successful response with purchase order details

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

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

    def patch_purchase_orders_id(
        self,
        id: str,
        *,
        erp_vendor_name: typing.Optional[str] = OMIT,
        date: typing.Optional[str] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        tax: typing.Optional[float] = OMIT,
        freight: typing.Optional[float] = OMIT,
        miscellaneous_charges: typing.Optional[float] = OMIT,
        invoice_number_ref: typing.Optional[str] = OMIT,
        is2way: typing.Optional[bool] = OMIT,
        items: typing.Optional[typing.Sequence[PatchPurchaseOrdersIdRequestItemsItem]] = OMIT,
        custom_fields: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PurchaseOrderUpdateResponse:
        """
        Updates a purchase order. Note: `status`, `po_number`, `external_id`, `erp_vendor_id`, and `ottimate_location_id` cannot be changed.

        Parameters
        ----------
        id : str
            The unique ID of the purchase order

        erp_vendor_name : typing.Optional[str]
            Vendor name from ERP system

        date : typing.Optional[str]

        total_amount : typing.Optional[float]

        tax : typing.Optional[float]

        freight : typing.Optional[float]

        miscellaneous_charges : typing.Optional[float]

        invoice_number_ref : typing.Optional[str]

        is2way : typing.Optional[bool]

        items : typing.Optional[typing.Sequence[PatchPurchaseOrdersIdRequestItemsItem]]
            Items with `id` update the existing item. Items without `id` create a new item. When creating, `name`, `quantity`, and `price` are required.

        custom_fields : typing.Optional[typing.Dict[str, typing.Any]]
            Optional custom fields configured for this company's purchase orders

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

        Returns
        -------
        PurchaseOrderUpdateResponse
            Successfully updated

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.purchase_orders.patch_purchase_orders_id(
            id="racc_90832490382904802384",
            total_amount=1600.0,
        )
        """
        _response = self._raw_client.patch_purchase_orders_id(
            id,
            erp_vendor_name=erp_vendor_name,
            date=date,
            total_amount=total_amount,
            tax=tax,
            freight=freight,
            miscellaneous_charges=miscellaneous_charges,
            invoice_number_ref=invoice_number_ref,
            is2way=is2way,
            items=items,
            custom_fields=custom_fields,
            request_options=request_options,
        )
        return _response.data

    def post_purchase_orders_bulk(
        self,
        *,
        ottimate_company_id: int,
        ottimate_location_id: int,
        purchase_orders: typing.Sequence[PurchaseOrderBulkUpsertRequestPurchaseOrdersItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkUpsertAsyncResponse:
        """
        Creates or updates multiple purchase orders in a single request. Maximum 100 purchase orders and 1000 total line items per request. Processing is always asynchronous via Celery and returns a batch tracking ID for polling progress.

        Parameters
        ----------
        ottimate_company_id : int
            Company ID for all purchase orders in this batch

        ottimate_location_id : int
            Default location ID for all purchase orders in this batch

        purchase_orders : typing.Sequence[PurchaseOrderBulkUpsertRequestPurchaseOrdersItem]
            Max 100 POs with max 1000 total items

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

        Returns
        -------
        BulkUpsertAsyncResponse
            Asynchronous processing started. Poll batch_url for progress.

        Examples
        --------
        from ottimate import Ottimate
        from ottimate.purchase_orders import (
            PurchaseOrderBulkUpsertRequestPurchaseOrdersItem,
            PurchaseOrderBulkUpsertRequestPurchaseOrdersItemItemsItem,
        )

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.purchase_orders.post_purchase_orders_bulk(
            ottimate_company_id=15196,
            ottimate_location_id=12345,
            purchase_orders=[
                PurchaseOrderBulkUpsertRequestPurchaseOrdersItem(
                    external_id="ERP-PO-001",
                    po_number="PO-2024-001",
                    erp_vendor_id="VENDOR-123",
                    erp_vendor_name="Sysco Foods",
                    date="2024-01-15",
                    total_amount=1500.0,
                    items=[
                        PurchaseOrderBulkUpsertRequestPurchaseOrdersItemItemsItem(
                            external_id="ERP-ITEM-001",
                            name="Tomatoes",
                            quantity=100.0,
                            price=2.5,
                        )
                    ],
                )
            ],
        )
        """
        _response = self._raw_client.post_purchase_orders_bulk(
            ottimate_company_id=ottimate_company_id,
            ottimate_location_id=ottimate_location_id,
            purchase_orders=purchase_orders,
            request_options=request_options,
        )
        return _response.data


class AsyncPurchaseOrdersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPurchaseOrdersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPurchaseOrdersClient
        """
        return self._raw_client

    async def get_purchase_orders_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        ottimate_location_id: typing.Optional[int] = None,
        erp_vendor_id: typing.Optional[str] = None,
        status: typing.Optional[GetPurchaseOrdersRootRequestStatus] = None,
        date_from: typing.Optional[str] = None,
        date_to: typing.Optional[str] = None,
        expand: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetPurchaseOrdersRootResponse:
        """
        Returns a paginated list of purchase orders, filterable by company, location, vendor, status, and date range.

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

        ottimate_location_id : typing.Optional[int]
            Filter by location ID

        erp_vendor_id : typing.Optional[str]
            Filter by ERP vendor ID (external vendor identifier)

        status : typing.Optional[GetPurchaseOrdersRootRequestStatus]
            Filter by PO status

        date_from : typing.Optional[str]
            Filter by start date (YYYY-MM-DD)

        date_to : typing.Optional[str]
            Filter by end date (YYYY-MM-DD)

        expand : typing.Optional[str]
            Comma-separated list of fields to expand. Supported values: items. When expand=items is used, date_from and date_to must both be provided and within a 30-day window.

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

        Returns
        -------
        GetPurchaseOrdersRootResponse
            Successful response with paginated purchase order 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.purchase_orders.get_purchase_orders_root(
                ottimate_company_id=15196,
                ottimate_location_id=12345,
                erp_vendor_id="VENDOR-123",
                expand="items",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_purchase_orders_root(
            ottimate_company_id=ottimate_company_id,
            ottimate_location_id=ottimate_location_id,
            erp_vendor_id=erp_vendor_id,
            status=status,
            date_from=date_from,
            date_to=date_to,
            expand=expand,
            request_options=request_options,
        )
        return _response.data

    async def post_purchase_orders_root(
        self,
        *,
        ottimate_location_id: int,
        po_number: str,
        erp_vendor_id: str,
        date: str,
        total_amount: float,
        items: typing.Sequence[PurchaseOrderCreateRequestItemsItem],
        external_id: typing.Optional[str] = OMIT,
        erp_vendor_name: typing.Optional[str] = OMIT,
        tax: typing.Optional[float] = OMIT,
        freight: typing.Optional[float] = OMIT,
        miscellaneous_charges: typing.Optional[float] = OMIT,
        invoice_number_ref: typing.Optional[str] = OMIT,
        is2way: typing.Optional[bool] = OMIT,
        custom_fields: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PurchaseOrderCreateResponse:
        """
        Creates a new purchase order with the provided details. The `po_number` field is required and must be provided by the client (no auto-generation).

        Parameters
        ----------
        ottimate_location_id : int

        po_number : str

        erp_vendor_id : str
            External vendor identifier from ERP system

        date : str

        total_amount : float

        items : typing.Sequence[PurchaseOrderCreateRequestItemsItem]

        external_id : typing.Optional[str]

        erp_vendor_name : typing.Optional[str]
            Vendor name from ERP system

        tax : typing.Optional[float]

        freight : typing.Optional[float]

        miscellaneous_charges : typing.Optional[float]

        invoice_number_ref : typing.Optional[str]
            Invoice reference number

        is2way : typing.Optional[bool]
            Whether this is a 2-way match PO

        custom_fields : typing.Optional[typing.Dict[str, typing.Any]]
            Optional custom fields configured for this company's purchase orders

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

        Returns
        -------
        PurchaseOrderCreateResponse
            Successfully created

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate
        from ottimate.purchase_orders import PurchaseOrderCreateRequestItemsItem

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


        async def main() -> None:
            await client.purchase_orders.post_purchase_orders_root(
                ottimate_location_id=12345,
                external_id="ERP-PO-001",
                po_number="PO-2024-001",
                erp_vendor_id="VENDOR-123",
                erp_vendor_name="Sysco Foods",
                date="2024-01-15",
                total_amount=1500.0,
                items=[
                    PurchaseOrderCreateRequestItemsItem(
                        external_id="ERP-ITEM-001",
                        name="Tomatoes",
                        sku="TOM-001",
                        quantity=100.0,
                        price=2.5,
                    )
                ],
                custom_fields={"TransactionId": "EXT-123456", "CustomField2": "value2"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_purchase_orders_root(
            ottimate_location_id=ottimate_location_id,
            po_number=po_number,
            erp_vendor_id=erp_vendor_id,
            date=date,
            total_amount=total_amount,
            items=items,
            external_id=external_id,
            erp_vendor_name=erp_vendor_name,
            tax=tax,
            freight=freight,
            miscellaneous_charges=miscellaneous_charges,
            invoice_number_ref=invoice_number_ref,
            is2way=is2way,
            custom_fields=custom_fields,
            request_options=request_options,
        )
        return _response.data

    async def get_purchase_orders_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PurchaseOrderDetail:
        """
        Returns detailed information for a single purchase order including all line items.

        Parameters
        ----------
        id : str
            The unique ID of the purchase order

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

        Returns
        -------
        PurchaseOrderDetail
            Successful response with purchase order 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.purchase_orders.get_purchase_orders_id(
                id="racc_90832490382904802384",
            )


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

    async def patch_purchase_orders_id(
        self,
        id: str,
        *,
        erp_vendor_name: typing.Optional[str] = OMIT,
        date: typing.Optional[str] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        tax: typing.Optional[float] = OMIT,
        freight: typing.Optional[float] = OMIT,
        miscellaneous_charges: typing.Optional[float] = OMIT,
        invoice_number_ref: typing.Optional[str] = OMIT,
        is2way: typing.Optional[bool] = OMIT,
        items: typing.Optional[typing.Sequence[PatchPurchaseOrdersIdRequestItemsItem]] = OMIT,
        custom_fields: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PurchaseOrderUpdateResponse:
        """
        Updates a purchase order. Note: `status`, `po_number`, `external_id`, `erp_vendor_id`, and `ottimate_location_id` cannot be changed.

        Parameters
        ----------
        id : str
            The unique ID of the purchase order

        erp_vendor_name : typing.Optional[str]
            Vendor name from ERP system

        date : typing.Optional[str]

        total_amount : typing.Optional[float]

        tax : typing.Optional[float]

        freight : typing.Optional[float]

        miscellaneous_charges : typing.Optional[float]

        invoice_number_ref : typing.Optional[str]

        is2way : typing.Optional[bool]

        items : typing.Optional[typing.Sequence[PatchPurchaseOrdersIdRequestItemsItem]]
            Items with `id` update the existing item. Items without `id` create a new item. When creating, `name`, `quantity`, and `price` are required.

        custom_fields : typing.Optional[typing.Dict[str, typing.Any]]
            Optional custom fields configured for this company's purchase orders

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

        Returns
        -------
        PurchaseOrderUpdateResponse
            Successfully updated

        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.purchase_orders.patch_purchase_orders_id(
                id="racc_90832490382904802384",
                total_amount=1600.0,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.patch_purchase_orders_id(
            id,
            erp_vendor_name=erp_vendor_name,
            date=date,
            total_amount=total_amount,
            tax=tax,
            freight=freight,
            miscellaneous_charges=miscellaneous_charges,
            invoice_number_ref=invoice_number_ref,
            is2way=is2way,
            items=items,
            custom_fields=custom_fields,
            request_options=request_options,
        )
        return _response.data

    async def post_purchase_orders_bulk(
        self,
        *,
        ottimate_company_id: int,
        ottimate_location_id: int,
        purchase_orders: typing.Sequence[PurchaseOrderBulkUpsertRequestPurchaseOrdersItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkUpsertAsyncResponse:
        """
        Creates or updates multiple purchase orders in a single request. Maximum 100 purchase orders and 1000 total line items per request. Processing is always asynchronous via Celery and returns a batch tracking ID for polling progress.

        Parameters
        ----------
        ottimate_company_id : int
            Company ID for all purchase orders in this batch

        ottimate_location_id : int
            Default location ID for all purchase orders in this batch

        purchase_orders : typing.Sequence[PurchaseOrderBulkUpsertRequestPurchaseOrdersItem]
            Max 100 POs with max 1000 total items

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

        Returns
        -------
        BulkUpsertAsyncResponse
            Asynchronous processing started. Poll batch_url for progress.

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate
        from ottimate.purchase_orders import (
            PurchaseOrderBulkUpsertRequestPurchaseOrdersItem,
            PurchaseOrderBulkUpsertRequestPurchaseOrdersItemItemsItem,
        )

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


        async def main() -> None:
            await client.purchase_orders.post_purchase_orders_bulk(
                ottimate_company_id=15196,
                ottimate_location_id=12345,
                purchase_orders=[
                    PurchaseOrderBulkUpsertRequestPurchaseOrdersItem(
                        external_id="ERP-PO-001",
                        po_number="PO-2024-001",
                        erp_vendor_id="VENDOR-123",
                        erp_vendor_name="Sysco Foods",
                        date="2024-01-15",
                        total_amount=1500.0,
                        items=[
                            PurchaseOrderBulkUpsertRequestPurchaseOrdersItemItemsItem(
                                external_id="ERP-ITEM-001",
                                name="Tomatoes",
                                quantity=100.0,
                                price=2.5,
                            )
                        ],
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_purchase_orders_bulk(
            ottimate_company_id=ottimate_company_id,
            ottimate_location_id=ottimate_location_id,
            purchase_orders=purchase_orders,
            request_options=request_options,
        )
        return _response.data
