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

import typing
from ...core.client_wrapper import SyncClientWrapper
from .raw_client import RawImagesClient
from ...requests.create_catalog_image_request import CreateCatalogImageRequestParams
from ... import core
from ...core.request_options import RequestOptions
from ...types.create_catalog_image_response import CreateCatalogImageResponse
from ...requests.update_catalog_image_request import UpdateCatalogImageRequestParams
from ...types.update_catalog_image_response import UpdateCatalogImageResponse
from ...core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawImagesClient

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


class ImagesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawImagesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawImagesClient
        """
        return self._raw_client

    def create(
        self,
        *,
        request: typing.Optional[CreateCatalogImageRequestParams] = OMIT,
        image_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCatalogImageResponse:
        """
        Uploads an image file to be represented by a [CatalogImage](entity:CatalogImage) object that can be linked to an existing
        [CatalogObject](entity:CatalogObject) instance. The resulting `CatalogImage` is unattached to any `CatalogObject` if the `object_id`
        is not specified.

        This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in
        JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

        Parameters
        ----------
        request : typing.Optional[CreateCatalogImageRequestParams]

        image_file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        CreateCatalogImageResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.catalog.images.create()
        """
        response = self._raw_client.create(request=request, image_file=image_file, request_options=request_options)
        return response.data

    def update(
        self,
        image_id: str,
        *,
        request: typing.Optional[UpdateCatalogImageRequestParams] = OMIT,
        image_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateCatalogImageResponse:
        """
        Uploads a new image file to replace the existing one in the specified [CatalogImage](entity:CatalogImage) object.

        This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in
        JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

        Parameters
        ----------
        image_id : str
            The ID of the `CatalogImage` object to update the encapsulated image file.

        request : typing.Optional[UpdateCatalogImageRequestParams]

        image_file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        UpdateCatalogImageResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.catalog.images.update(
            image_id="image_id",
        )
        """
        response = self._raw_client.update(
            image_id, request=request, image_file=image_file, request_options=request_options
        )
        return response.data


class AsyncImagesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawImagesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawImagesClient
        """
        return self._raw_client

    async def create(
        self,
        *,
        request: typing.Optional[CreateCatalogImageRequestParams] = OMIT,
        image_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCatalogImageResponse:
        """
        Uploads an image file to be represented by a [CatalogImage](entity:CatalogImage) object that can be linked to an existing
        [CatalogObject](entity:CatalogObject) instance. The resulting `CatalogImage` is unattached to any `CatalogObject` if the `object_id`
        is not specified.

        This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in
        JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

        Parameters
        ----------
        request : typing.Optional[CreateCatalogImageRequestParams]

        image_file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        CreateCatalogImageResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.catalog.images.create()


        asyncio.run(main())
        """
        response = await self._raw_client.create(
            request=request, image_file=image_file, request_options=request_options
        )
        return response.data

    async def update(
        self,
        image_id: str,
        *,
        request: typing.Optional[UpdateCatalogImageRequestParams] = OMIT,
        image_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateCatalogImageResponse:
        """
        Uploads a new image file to replace the existing one in the specified [CatalogImage](entity:CatalogImage) object.

        This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in
        JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

        Parameters
        ----------
        image_id : str
            The ID of the `CatalogImage` object to update the encapsulated image file.

        request : typing.Optional[UpdateCatalogImageRequestParams]

        image_file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        UpdateCatalogImageResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.catalog.images.update(
                image_id="image_id",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.update(
            image_id, request=request, image_file=image_file, request_options=request_options
        )
        return response.data
