# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Any, cast

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import (
    to_raw_response_wrapper,
    to_streamed_response_wrapper,
    async_to_raw_response_wrapper,
    async_to_streamed_response_wrapper,
)
from ...._base_client import make_request_options
from ....types.api.v2 import retailer_retrieve_psp_options_params
from ....types.api.v2.psp_option import PspOption
from ....types.api.v2.retailer_retrieve_response import RetailerRetrieveResponse

__all__ = ["RetailersResource", "AsyncRetailersResource"]


class RetailersResource(SyncAPIResource):
    @cached_property
    def with_raw_response(self) -> RetailersResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/alisytsma/ali-test-mcp#accessing-raw-response-data-eg-headers
        """
        return RetailersResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> RetailersResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/alisytsma/ali-test-mcp#with_streaming_response
        """
        return RetailersResourceWithStreamingResponse(self)

    def retrieve(
        self,
        retailer_id: str,
        *,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
    ) -> RetailerRetrieveResponse:
        """Get `Retailer` with `retailerId`.

        Also possible to use `me` instead of
        `retailerId`, but in this case Basic Auth is required. In case Basic Auth
        exists, then `RetailerDetails` will be returned.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not retailer_id:
            raise ValueError(f"Expected a non-empty value for `retailer_id` but received {retailer_id!r}")
        return cast(
            RetailerRetrieveResponse,
            self._get(
                f"/api/v2/retailers/{retailer_id}",
                options=make_request_options(
                    extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
                ),
                cast_to=cast(
                    Any, RetailerRetrieveResponse
                ),  # Union types cannot be passed in as arguments in the type system
            ),
        )

    def retrieve_psp_options(
        self,
        retailer_id: str,
        *,
        currency_code: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
    ) -> PspOption:
        """
        Get list of `pspOptions` for `retailerId` and 'currencyCode.

        Args:
          currency_code: CurrencyCode enum

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not retailer_id:
            raise ValueError(f"Expected a non-empty value for `retailer_id` but received {retailer_id!r}")
        return self._get(
            f"/api/v2/retailers/{retailer_id}/pspOptions",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {"currency_code": currency_code},
                    retailer_retrieve_psp_options_params.RetailerRetrievePspOptionsParams,
                ),
            ),
            cast_to=PspOption,
        )


class AsyncRetailersResource(AsyncAPIResource):
    @cached_property
    def with_raw_response(self) -> AsyncRetailersResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/alisytsma/ali-test-mcp#accessing-raw-response-data-eg-headers
        """
        return AsyncRetailersResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncRetailersResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/alisytsma/ali-test-mcp#with_streaming_response
        """
        return AsyncRetailersResourceWithStreamingResponse(self)

    async def retrieve(
        self,
        retailer_id: str,
        *,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
    ) -> RetailerRetrieveResponse:
        """Get `Retailer` with `retailerId`.

        Also possible to use `me` instead of
        `retailerId`, but in this case Basic Auth is required. In case Basic Auth
        exists, then `RetailerDetails` will be returned.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not retailer_id:
            raise ValueError(f"Expected a non-empty value for `retailer_id` but received {retailer_id!r}")
        return cast(
            RetailerRetrieveResponse,
            await self._get(
                f"/api/v2/retailers/{retailer_id}",
                options=make_request_options(
                    extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
                ),
                cast_to=cast(
                    Any, RetailerRetrieveResponse
                ),  # Union types cannot be passed in as arguments in the type system
            ),
        )

    async def retrieve_psp_options(
        self,
        retailer_id: str,
        *,
        currency_code: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
    ) -> PspOption:
        """
        Get list of `pspOptions` for `retailerId` and 'currencyCode.

        Args:
          currency_code: CurrencyCode enum

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not retailer_id:
            raise ValueError(f"Expected a non-empty value for `retailer_id` but received {retailer_id!r}")
        return await self._get(
            f"/api/v2/retailers/{retailer_id}/pspOptions",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {"currency_code": currency_code},
                    retailer_retrieve_psp_options_params.RetailerRetrievePspOptionsParams,
                ),
            ),
            cast_to=PspOption,
        )


class RetailersResourceWithRawResponse:
    def __init__(self, retailers: RetailersResource) -> None:
        self._retailers = retailers

        self.retrieve = to_raw_response_wrapper(
            retailers.retrieve,
        )
        self.retrieve_psp_options = to_raw_response_wrapper(
            retailers.retrieve_psp_options,
        )


class AsyncRetailersResourceWithRawResponse:
    def __init__(self, retailers: AsyncRetailersResource) -> None:
        self._retailers = retailers

        self.retrieve = async_to_raw_response_wrapper(
            retailers.retrieve,
        )
        self.retrieve_psp_options = async_to_raw_response_wrapper(
            retailers.retrieve_psp_options,
        )


class RetailersResourceWithStreamingResponse:
    def __init__(self, retailers: RetailersResource) -> None:
        self._retailers = retailers

        self.retrieve = to_streamed_response_wrapper(
            retailers.retrieve,
        )
        self.retrieve_psp_options = to_streamed_response_wrapper(
            retailers.retrieve_psp_options,
        )


class AsyncRetailersResourceWithStreamingResponse:
    def __init__(self, retailers: AsyncRetailersResource) -> None:
        self._retailers = retailers

        self.retrieve = async_to_streamed_response_wrapper(
            retailers.retrieve,
        )
        self.retrieve_psp_options = async_to_streamed_response_wrapper(
            retailers.retrieve_psp_options,
        )
