# 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 AsyncRawDimensionsClient, RawDimensionsClient
from .types.get_dimensions_id_response import GetDimensionsIdResponse
from .types.get_dimensions_root_response import GetDimensionsRootResponse
from .types.post_dimensions_bulk_request_dimensions_item import PostDimensionsBulkRequestDimensionsItem
from .types.post_dimensions_bulk_response import PostDimensionsBulkResponse
from .types.post_dimensions_root_request_ottimate_type import PostDimensionsRootRequestOttimateType
from .types.post_dimensions_root_response import PostDimensionsRootResponse

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


class DimensionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDimensionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDimensionsClient
        """
        return self._raw_client

    def get_dimensions_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        erp_type: typing.Optional[str] = None,
        detail: typing.Optional[typing.Literal["basic"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetDimensionsRootResponse:
        """
        Returns a paginated list of dimensions, filterable by company and type. The `detail=basic` query parameter returns a simplified response.

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

        erp_type : typing.Optional[str]
            Filter dimensions by ERP type

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

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

        Returns
        -------
        GetDimensionsRootResponse
            Successful response with paginated dimension list

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.dimensions.get_dimensions_root(
            ottimate_company_id=15196,
            erp_type="Account",
        )
        """
        _response = self._raw_client.get_dimensions_root(
            ottimate_company_id=ottimate_company_id, erp_type=erp_type, detail=detail, request_options=request_options
        )
        return _response.data

    def post_dimensions_root(
        self,
        *,
        ottimate_company_id: int,
        erp_type: str,
        ottimate_type: PostDimensionsRootRequestOttimateType,
        name: str,
        code: str,
        reference_id: str,
        erp_dimension_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostDimensionsRootResponse:
        """
        Creates a new dimension with the provided details. The `reference_id` and `erp_dimension_id` are required for a successful creation.

        Parameters
        ----------
        ottimate_company_id : int
            The Ottimate company ID this dimension belongs to

        erp_type : str
            The dimension category label as displayed in the client's ERP system (e.g., 'Account', 'GLACCOUNT', 'Department'). This is client-specific.

        ottimate_type : PostDimensionsRootRequestOttimateType
            Ottimate's standardized dimension type code for consistent categorization.

        name : str
            Display name of the dimension

        code : str
            The GL code or short identifier for this dimension in the client's ERP system

        reference_id : str
            A unique reference identifier that tracks this dimension across all client systems (ERP, inventory management, Ottimate)

        erp_dimension_id : str
            The identifier assigned to this dimension by the client's ERP software

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

        Returns
        -------
        PostDimensionsRootResponse
            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.dimensions.post_dimensions_root(
            ottimate_company_id=15196,
            erp_type="Department",
            ottimate_type="department",
            name="Marketing Department",
            code="MKT",
            reference_id="dept-mkt-001",
            erp_dimension_id="DEPT-MKT-001",
        )
        """
        _response = self._raw_client.post_dimensions_root(
            ottimate_company_id=ottimate_company_id,
            erp_type=erp_type,
            ottimate_type=ottimate_type,
            name=name,
            code=code,
            reference_id=reference_id,
            erp_dimension_id=erp_dimension_id,
            request_options=request_options,
        )
        return _response.data

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

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

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

        Returns
        -------
        GetDimensionsIdResponse
            Successful response with dimension details

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

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

    def post_dimensions_bulk(
        self,
        *,
        ottimate_company_id: int,
        dimensions: typing.Sequence[PostDimensionsBulkRequestDimensionsItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostDimensionsBulkResponse:
        """
        Allows for the creation or updating of multiple dimensions in a single request. The request body should contain a `ottimate_company_id` and an array of `dimensions`. Maximum 100 dimensions per request.

        Parameters
        ----------
        ottimate_company_id : int
            The Ottimate company ID these dimensions belong to

        dimensions : typing.Sequence[PostDimensionsBulkRequestDimensionsItem]

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

        Returns
        -------
        PostDimensionsBulkResponse
            Successfully created or updated

        Examples
        --------
        from ottimate import Ottimate
        from ottimate.dimensions import PostDimensionsBulkRequestDimensionsItem

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.dimensions.post_dimensions_bulk(
            ottimate_company_id=15196,
            dimensions=[
                PostDimensionsBulkRequestDimensionsItem(
                    erp_type="Department",
                    ottimate_type="department",
                    name="Operations Department",
                    code="OPS",
                    reference_id="dept-ops-001",
                    erp_dimension_id="DEPT-OPS-001",
                ),
                PostDimensionsBulkRequestDimensionsItem(
                    erp_type="Department",
                    ottimate_type="department",
                    name="Finance Department",
                    code="FIN",
                    reference_id="dept-fin-001",
                    erp_dimension_id="DEPT-FIN-001",
                ),
            ],
        )
        """
        _response = self._raw_client.post_dimensions_bulk(
            ottimate_company_id=ottimate_company_id, dimensions=dimensions, request_options=request_options
        )
        return _response.data


class AsyncDimensionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDimensionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDimensionsClient
        """
        return self._raw_client

    async def get_dimensions_root(
        self,
        *,
        ottimate_company_id: typing.Optional[int] = None,
        erp_type: typing.Optional[str] = None,
        detail: typing.Optional[typing.Literal["basic"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetDimensionsRootResponse:
        """
        Returns a paginated list of dimensions, filterable by company and type. The `detail=basic` query parameter returns a simplified response.

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

        erp_type : typing.Optional[str]
            Filter dimensions by ERP type

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

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

        Returns
        -------
        GetDimensionsRootResponse
            Successful response with paginated dimension 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.dimensions.get_dimensions_root(
                ottimate_company_id=15196,
                erp_type="Account",
            )


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

    async def post_dimensions_root(
        self,
        *,
        ottimate_company_id: int,
        erp_type: str,
        ottimate_type: PostDimensionsRootRequestOttimateType,
        name: str,
        code: str,
        reference_id: str,
        erp_dimension_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostDimensionsRootResponse:
        """
        Creates a new dimension with the provided details. The `reference_id` and `erp_dimension_id` are required for a successful creation.

        Parameters
        ----------
        ottimate_company_id : int
            The Ottimate company ID this dimension belongs to

        erp_type : str
            The dimension category label as displayed in the client's ERP system (e.g., 'Account', 'GLACCOUNT', 'Department'). This is client-specific.

        ottimate_type : PostDimensionsRootRequestOttimateType
            Ottimate's standardized dimension type code for consistent categorization.

        name : str
            Display name of the dimension

        code : str
            The GL code or short identifier for this dimension in the client's ERP system

        reference_id : str
            A unique reference identifier that tracks this dimension across all client systems (ERP, inventory management, Ottimate)

        erp_dimension_id : str
            The identifier assigned to this dimension by the client's ERP software

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

        Returns
        -------
        PostDimensionsRootResponse
            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.dimensions.post_dimensions_root(
                ottimate_company_id=15196,
                erp_type="Department",
                ottimate_type="department",
                name="Marketing Department",
                code="MKT",
                reference_id="dept-mkt-001",
                erp_dimension_id="DEPT-MKT-001",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_dimensions_root(
            ottimate_company_id=ottimate_company_id,
            erp_type=erp_type,
            ottimate_type=ottimate_type,
            name=name,
            code=code,
            reference_id=reference_id,
            erp_dimension_id=erp_dimension_id,
            request_options=request_options,
        )
        return _response.data

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

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

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

        Returns
        -------
        GetDimensionsIdResponse
            Successful response with dimension 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.dimensions.get_dimensions_id(
                id="racc_90832490382904802384",
            )


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

    async def post_dimensions_bulk(
        self,
        *,
        ottimate_company_id: int,
        dimensions: typing.Sequence[PostDimensionsBulkRequestDimensionsItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostDimensionsBulkResponse:
        """
        Allows for the creation or updating of multiple dimensions in a single request. The request body should contain a `ottimate_company_id` and an array of `dimensions`. Maximum 100 dimensions per request.

        Parameters
        ----------
        ottimate_company_id : int
            The Ottimate company ID these dimensions belong to

        dimensions : typing.Sequence[PostDimensionsBulkRequestDimensionsItem]

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

        Returns
        -------
        PostDimensionsBulkResponse
            Successfully created or updated

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate
        from ottimate.dimensions import PostDimensionsBulkRequestDimensionsItem

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


        async def main() -> None:
            await client.dimensions.post_dimensions_bulk(
                ottimate_company_id=15196,
                dimensions=[
                    PostDimensionsBulkRequestDimensionsItem(
                        erp_type="Department",
                        ottimate_type="department",
                        name="Operations Department",
                        code="OPS",
                        reference_id="dept-ops-001",
                        erp_dimension_id="DEPT-OPS-001",
                    ),
                    PostDimensionsBulkRequestDimensionsItem(
                        erp_type="Department",
                        ottimate_type="department",
                        name="Finance Department",
                        code="FIN",
                        reference_id="dept-fin-001",
                        erp_dimension_id="DEPT-FIN-001",
                    ),
                ],
            )


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