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

from __future__ import annotations

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.customers import shows_review_update_shows_reviews_params
from .....types.api.v2.customers.customer_show_review import CustomerShowReview
from .....types.api.v2.customers.shows_review_retrieve_shows_reviews_response import (
    ShowsReviewRetrieveShowsReviewsResponse,
)

__all__ = ["ShowsReviewsResource", "AsyncShowsReviewsResource"]


class ShowsReviewsResource(SyncAPIResource):
    @cached_property
    def with_raw_response(self) -> ShowsReviewsResourceWithRawResponse:
        """
        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 ShowsReviewsResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> ShowsReviewsResourceWithStreamingResponse:
        """
        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 ShowsReviewsResourceWithStreamingResponse(self)

    def retrieve_shows_reviews(
        self,
        customer_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,
    ) -> ShowsReviewRetrieveShowsReviewsResponse:
        """
        Get all show ratings for current customer.

        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 customer_id:
            raise ValueError(f"Expected a non-empty value for `customer_id` but received {customer_id!r}")
        return self._get(
            f"/api/v2/customers/{customer_id}/showsReviews",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=ShowsReviewRetrieveShowsReviewsResponse,
        )

    def update_shows_reviews(
        self,
        customer_id: str,
        *,
        rating: int,
        show: int | NotGiven = NOT_GIVEN,
        # 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,
    ) -> CustomerShowReview:
        """
        Post a rating Implicit `customerId = me`.

        Args:
          rating: rating for this show.

          show: Show id

          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 customer_id:
            raise ValueError(f"Expected a non-empty value for `customer_id` but received {customer_id!r}")
        return self._put(
            f"/api/v2/customers/{customer_id}/showsReviews",
            body=maybe_transform(
                {
                    "rating": rating,
                    "show": show,
                },
                shows_review_update_shows_reviews_params.ShowsReviewUpdateShowsReviewsParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=CustomerShowReview,
        )


class AsyncShowsReviewsResource(AsyncAPIResource):
    @cached_property
    def with_raw_response(self) -> AsyncShowsReviewsResourceWithRawResponse:
        """
        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 AsyncShowsReviewsResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncShowsReviewsResourceWithStreamingResponse:
        """
        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 AsyncShowsReviewsResourceWithStreamingResponse(self)

    async def retrieve_shows_reviews(
        self,
        customer_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,
    ) -> ShowsReviewRetrieveShowsReviewsResponse:
        """
        Get all show ratings for current customer.

        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 customer_id:
            raise ValueError(f"Expected a non-empty value for `customer_id` but received {customer_id!r}")
        return await self._get(
            f"/api/v2/customers/{customer_id}/showsReviews",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=ShowsReviewRetrieveShowsReviewsResponse,
        )

    async def update_shows_reviews(
        self,
        customer_id: str,
        *,
        rating: int,
        show: int | NotGiven = NOT_GIVEN,
        # 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,
    ) -> CustomerShowReview:
        """
        Post a rating Implicit `customerId = me`.

        Args:
          rating: rating for this show.

          show: Show id

          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 customer_id:
            raise ValueError(f"Expected a non-empty value for `customer_id` but received {customer_id!r}")
        return await self._put(
            f"/api/v2/customers/{customer_id}/showsReviews",
            body=await async_maybe_transform(
                {
                    "rating": rating,
                    "show": show,
                },
                shows_review_update_shows_reviews_params.ShowsReviewUpdateShowsReviewsParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=CustomerShowReview,
        )


class ShowsReviewsResourceWithRawResponse:
    def __init__(self, shows_reviews: ShowsReviewsResource) -> None:
        self._shows_reviews = shows_reviews

        self.retrieve_shows_reviews = to_raw_response_wrapper(
            shows_reviews.retrieve_shows_reviews,
        )
        self.update_shows_reviews = to_raw_response_wrapper(
            shows_reviews.update_shows_reviews,
        )


class AsyncShowsReviewsResourceWithRawResponse:
    def __init__(self, shows_reviews: AsyncShowsReviewsResource) -> None:
        self._shows_reviews = shows_reviews

        self.retrieve_shows_reviews = async_to_raw_response_wrapper(
            shows_reviews.retrieve_shows_reviews,
        )
        self.update_shows_reviews = async_to_raw_response_wrapper(
            shows_reviews.update_shows_reviews,
        )


class ShowsReviewsResourceWithStreamingResponse:
    def __init__(self, shows_reviews: ShowsReviewsResource) -> None:
        self._shows_reviews = shows_reviews

        self.retrieve_shows_reviews = to_streamed_response_wrapper(
            shows_reviews.retrieve_shows_reviews,
        )
        self.update_shows_reviews = to_streamed_response_wrapper(
            shows_reviews.update_shows_reviews,
        )


class AsyncShowsReviewsResourceWithStreamingResponse:
    def __init__(self, shows_reviews: AsyncShowsReviewsResource) -> None:
        self._shows_reviews = shows_reviews

        self.retrieve_shows_reviews = async_to_streamed_response_wrapper(
            shows_reviews.retrieve_shows_reviews,
        )
        self.update_shows_reviews = async_to_streamed_response_wrapper(
            shows_reviews.update_shows_reviews,
        )
