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

from __future__ import annotations

from typing_extensions import Literal

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 rush_grant_rush_grants_params, rush_grant_retrieve_rush_grants_params
from .....types.api.v2.customers.rush_grant import RushGrant
from .....types.api.v2.customers.rush_grant_retrieve_rush_grants_response import RushGrantRetrieveRushGrantsResponse

__all__ = ["RushGrantsResource", "AsyncRushGrantsResource"]


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

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

    def retrieve_rush_grants(
        self,
        customer_id: str,
        *,
        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,
    ) -> RushGrantRetrieveRushGrantsResponse:
        """Get a list of shows I currently have authorization to access.

        If `show`
        parameter exist - then only one show.

        Args:
          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._get(
            f"/api/v2/customers/{customer_id}/rushGrants",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {"show": show}, rush_grant_retrieve_rush_grants_params.RushGrantRetrieveRushGrantsParams
                ),
            ),
            cast_to=RushGrantRetrieveRushGrantsResponse,
        )

    def rush_grants(
        self,
        customer_id: str,
        *,
        show_id: int,
        social: Literal["FACEBOOK", "TWITTER"] | 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,
    ) -> RushGrant:
        """
        Request a grant to access rush for a `show`.

        Args:
          show_id: Show id

          social: Social share platforms where social shares will affect logic.

              For example, lottery entry shares will grant an extra entry. Or rush shares will
              unlock rush availability.

              Caution! Email, Text Message and WhatsApp is not one of the option.

          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._post(
            f"/api/v2/customers/{customer_id}/rushGrants",
            body=maybe_transform(
                {
                    "show_id": show_id,
                    "social": social,
                },
                rush_grant_rush_grants_params.RushGrantRushGrantsParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RushGrant,
        )


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

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

    async def retrieve_rush_grants(
        self,
        customer_id: str,
        *,
        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,
    ) -> RushGrantRetrieveRushGrantsResponse:
        """Get a list of shows I currently have authorization to access.

        If `show`
        parameter exist - then only one show.

        Args:
          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._get(
            f"/api/v2/customers/{customer_id}/rushGrants",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {"show": show}, rush_grant_retrieve_rush_grants_params.RushGrantRetrieveRushGrantsParams
                ),
            ),
            cast_to=RushGrantRetrieveRushGrantsResponse,
        )

    async def rush_grants(
        self,
        customer_id: str,
        *,
        show_id: int,
        social: Literal["FACEBOOK", "TWITTER"] | 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,
    ) -> RushGrant:
        """
        Request a grant to access rush for a `show`.

        Args:
          show_id: Show id

          social: Social share platforms where social shares will affect logic.

              For example, lottery entry shares will grant an extra entry. Or rush shares will
              unlock rush availability.

              Caution! Email, Text Message and WhatsApp is not one of the option.

          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._post(
            f"/api/v2/customers/{customer_id}/rushGrants",
            body=await async_maybe_transform(
                {
                    "show_id": show_id,
                    "social": social,
                },
                rush_grant_rush_grants_params.RushGrantRushGrantsParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RushGrant,
        )


class RushGrantsResourceWithRawResponse:
    def __init__(self, rush_grants: RushGrantsResource) -> None:
        self._rush_grants = rush_grants

        self.retrieve_rush_grants = to_raw_response_wrapper(
            rush_grants.retrieve_rush_grants,
        )
        self.rush_grants = to_raw_response_wrapper(
            rush_grants.rush_grants,
        )


class AsyncRushGrantsResourceWithRawResponse:
    def __init__(self, rush_grants: AsyncRushGrantsResource) -> None:
        self._rush_grants = rush_grants

        self.retrieve_rush_grants = async_to_raw_response_wrapper(
            rush_grants.retrieve_rush_grants,
        )
        self.rush_grants = async_to_raw_response_wrapper(
            rush_grants.rush_grants,
        )


class RushGrantsResourceWithStreamingResponse:
    def __init__(self, rush_grants: RushGrantsResource) -> None:
        self._rush_grants = rush_grants

        self.retrieve_rush_grants = to_streamed_response_wrapper(
            rush_grants.retrieve_rush_grants,
        )
        self.rush_grants = to_streamed_response_wrapper(
            rush_grants.rush_grants,
        )


class AsyncRushGrantsResourceWithStreamingResponse:
    def __init__(self, rush_grants: AsyncRushGrantsResource) -> None:
        self._rush_grants = rush_grants

        self.retrieve_rush_grants = async_to_streamed_response_wrapper(
            rush_grants.retrieve_rush_grants,
        )
        self.rush_grants = async_to_streamed_response_wrapper(
            rush_grants.rush_grants,
        )
