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

from __future__ import annotations

from typing import Iterable

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NoneType, 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 hold_list_params, hold_create_params, hold_update_params
from ....types.api.v2.hold import Hold
from ....types.api.v2.customers import TicketType
from ....types.api.v2.hold_list_response import HoldListResponse
from ....types.api.v2.pyos_hold_seat_param import PyosHoldSeatParam
from ....types.api.v2.customers.ticket_type import TicketType
from ....types.api.v2.hold_update_clear_response import HoldUpdateClearResponse
from ....types.api.v2.price_type_selection_param import PriceTypeSelectionParam
from ....types.api.v2.hold_retrieve_apple_pay_session_response import HoldRetrieveApplePaySessionResponse

__all__ = ["HoldsResource", "AsyncHoldsResource"]


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

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

    def create(
        self,
        *,
        hold_type: TicketType,
        agent_payment_reference: str | NotGiven = NOT_GIVEN,
        apply_rewards_credit: bool | NotGiven = NOT_GIVEN,
        customer: str | NotGiven = NOT_GIVEN,
        hold_body_id: str | NotGiven = NOT_GIVEN,
        lottery_entry: int | NotGiven = NOT_GIVEN,
        num_tickets: int | NotGiven = NOT_GIVEN,
        offer: int | NotGiven = NOT_GIVEN,
        provider: int | NotGiven = NOT_GIVEN,
        provider_params: str | NotGiven = NOT_GIVEN,
        seats: Iterable[PyosHoldSeatParam] | NotGiven = NOT_GIVEN,
        section: int | NotGiven = NOT_GIVEN,
        should_override_ticket_protection_plan: bool | NotGiven = NOT_GIVEN,
        showtime: int | NotGiven = NOT_GIVEN,
        tickets_by_price_type: Iterable[PriceTypeSelectionParam] | NotGiven = NOT_GIVEN,
        use_unified_checkout: bool | NotGiven = NOT_GIVEN,
        voucher_code: str | 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,
    ) -> Hold:
        """Hold a group of tickets.

        `holdType` define what type of tickets to hold.

        `holdType = REGULAR` and (seatSelectionType == BEST_AVAILABLE ||
        seatSelectionType = null), required params are:

        - `showtime`
        - `provider`
        - `providerParams`
        - `numTickets`

        `holdType = REGULAR` and seatSelectionType == PYOS, required params are:

        - `seatSelectionType`
        - `showtime`
        - `seats`

        `holdType = RUSH`, required params are:

        - `showtime`
        - `numTickets`
        - `customer`

        `holdType = LOTTERY`, required params are:

        - `lotteryEntry`
        - `customer`

        `holdType = OFFER`, required params are:

        - `offer`
        - `customer`

        `holdType = null`, the only param allowed is:

        - `holdBodyId`

        Args:
          hold_type: Type of the tickets (Lottery, Rush and Regular tickets)

          agent_payment_reference: A unique string to identify the booking within a payment on-account retailer's
              internal system

          apply_rewards_credit: Automatically applies rewards credit upon hold creation, if the customer has any

          customer: A customer public facing Id (String). "me" or a hashed string. ?customer=me and
              /customers/me/ are both magical customer identifiers, but they are customer
              identifiers nonetheless. They make the API easier to use than
              ?customer=c.dkd3kl238es or /customers/c.23i8fjdksdfs3.

          hold_body_id: The redisId for finding a saved body of PostHoldInputBody. holdBodyId can link
              us to another PostHoldInputBody in redis and a hold can be made from this
              fetched PostHoldInputBody.

          lottery_entry: Numeric identifier for a resource

          num_tickets: number of tickets to hold, required for REGULAR and RUSH

          offer: Numeric identifier for a resource

          provider: Numeric identifier for a resource

          provider_params: Some server information necessary to hold seats. From `inventoryItem` object.
              required for REGULAR

          seats: The list of seats to be held for the customer.

          section: Numeric identifier for a resource

          should_override_ticket_protection_plan: If true, the hold will not be linked to the show's/rules ticketProtectionPlan
              but the configured alternative

          showtime: Numeric identifier for a resource

          voucher_code: voucher code

          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
        """
        return self._post(
            "/api/v2/holds",
            body=maybe_transform(
                {
                    "hold_type": hold_type,
                    "agent_payment_reference": agent_payment_reference,
                    "apply_rewards_credit": apply_rewards_credit,
                    "customer": customer,
                    "hold_body_id": hold_body_id,
                    "lottery_entry": lottery_entry,
                    "num_tickets": num_tickets,
                    "offer": offer,
                    "provider": provider,
                    "provider_params": provider_params,
                    "seats": seats,
                    "section": section,
                    "should_override_ticket_protection_plan": should_override_ticket_protection_plan,
                    "showtime": showtime,
                    "tickets_by_price_type": tickets_by_price_type,
                    "use_unified_checkout": use_unified_checkout,
                    "voucher_code": voucher_code,
                },
                hold_create_params.HoldCreateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=Hold,
        )

    def retrieve(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Get a Hold by ID.

        Non-TodayTix retailers get a `HoldSummary`, TodayTix returns
        `Hold`.

        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
        """
        return self._get(
            f"/api/v2/holds/{hold_id}",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    def update(
        self,
        hold_id: int,
        *,
        add_ons: Iterable[hold_update_params.AddOn] | NotGiven = NOT_GIVEN,
        agent_payment_reference: str | NotGiven = NOT_GIVEN,
        apply_rewards_credit: bool | NotGiven = NOT_GIVEN,
        apply_ticket_protection: bool | NotGiven = NOT_GIVEN,
        email: str | NotGiven = NOT_GIVEN,
        hold_type: TicketType | NotGiven = NOT_GIVEN,
        is_rewards_benefit: bool | NotGiven = NOT_GIVEN,
        num_tickets: int | NotGiven = NOT_GIVEN,
        phone_country_code: str | NotGiven = NOT_GIVEN,
        provider: int | NotGiven = NOT_GIVEN,
        provider_params: str | NotGiven = NOT_GIVEN,
        seats: Iterable[PyosHoldSeatParam] | NotGiven = NOT_GIVEN,
        secret: str | NotGiven = NOT_GIVEN,
        section: int | NotGiven = NOT_GIVEN,
        should_override_ticket_protection_plan: bool | NotGiven = NOT_GIVEN,
        showtime: int | NotGiven = NOT_GIVEN,
        tickets_by_price_type: Iterable[PriceTypeSelectionParam] | NotGiven = NOT_GIVEN,
        use_unified_checkout: bool | NotGiven = NOT_GIVEN,
        voucher: str | 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,
    ) -> object:
        """Updates the specified Hold.

        This can be for a few actions:

        1. Add new seats to a previously cleared hold. Not supported on TodayTix
           retailer.
        2. Apply a voucher to a non-empty hold.
        3. Apply a ticket protection plan to the hold.

        The server will verify that the access token is able to manipulate the requested
        holdId.

        Args:
          agent_payment_reference: A unique string to identify the booking within a payment on-account retailer's
              internal system

          apply_rewards_credit: Apply customer rewards credit (TixCash).

          apply_ticket_protection: Link the hold with the show.ticketProtectionPlan if exist

          email: Email of the customer, used to validate the voucher in case of guest checkout.

          hold_type: Type of the tickets (Lottery, Rush and Regular tickets)

          is_rewards_benefit: A flag indicating whether the hold should use the Ticket Protection Rewards
              Benefit (if available for this customer) instead of the Standard Ticket
              Protection.

          phone_country_code: Phone country code to validate if we should apply PILC (Pay In Local Currency)
              or not.

          provider: Numeric identifier for a resource

          provider_params: Some server information necessary to hold seats. This is generally a stringified
              json blob.

          seats: The list of seats to be held for the customer.

          secret: Secret key used to authorize hold permissions.

          section: Numeric identifier for a resource

          should_override_ticket_protection_plan: If true, the hold will not be linked to the show's/rules ticketProtectionPlan
              but the configured alternative

          showtime: Numeric identifier for a resource

          voucher: Optional voucher code when initiating a hold with a voucher (e.g. Link to Hold).

          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
        """
        return self._patch(
            f"/api/v2/holds/{hold_id}",
            body=maybe_transform(
                {
                    "add_ons": add_ons,
                    "agent_payment_reference": agent_payment_reference,
                    "apply_rewards_credit": apply_rewards_credit,
                    "apply_ticket_protection": apply_ticket_protection,
                    "email": email,
                    "hold_type": hold_type,
                    "is_rewards_benefit": is_rewards_benefit,
                    "num_tickets": num_tickets,
                    "phone_country_code": phone_country_code,
                    "provider": provider,
                    "provider_params": provider_params,
                    "seats": seats,
                    "secret": secret,
                    "section": section,
                    "should_override_ticket_protection_plan": should_override_ticket_protection_plan,
                    "showtime": showtime,
                    "tickets_by_price_type": tickets_by_price_type,
                    "use_unified_checkout": use_unified_checkout,
                    "voucher": voucher,
                },
                hold_update_params.HoldUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    def list(
        self,
        *,
        customer_id: str | 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,
    ) -> HoldListResponse:
        """Get an array of all holds the present access token is authorized to have.

        For
        now, this is always a list of length one.

        Args:
          customer_id: Customer PubId. Required when credits are specified to verify the user's
              homeLocation

          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
        """
        return self._get(
            "/api/v2/holds",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform({"customer_id": customer_id}, hold_list_params.HoldListParams),
            ),
            cast_to=HoldListResponse,
        )

    def delete(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> None:
        """Releases the specified hold.

        The server will verify that the access token is
        able to manipulate (and delete) the requested holdId.

        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
        """
        extra_headers = {"Accept": "*/*", **(extra_headers or {})}
        return self._delete(
            f"/api/v2/holds/{hold_id}",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=NoneType,
        )

    def delete_ticket_protection(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Removes applied ticket protection plan to the specified hold.

        The server will
        verify that the access token is able to manipulate the requested holdId.

        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
        """
        return self._delete(
            f"/api/v2/holds/{hold_id}/ticketProtection",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    def delete_voucher(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Removes applied voucher to the specified hold.

        The server will verify that the
        access token is able to manipulate the requested holdId.

        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
        """
        return self._delete(
            f"/api/v2/holds/{hold_id}/voucher",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    def retrieve_apple_pay_session(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> HoldRetrieveApplePaySessionResponse:
        """
        Gets Apple Pay Session data to be used to purchase hold with Apple Pay.

        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
        """
        return self._get(
            f"/api/v2/holds/{hold_id}/applePaySession",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=HoldRetrieveApplePaySessionResponse,
        )

    def update_clear(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> HoldUpdateClearResponse:
        """Clear the existing "basket" of its seats.

        This means we release the seats on the
        provider side, but the hold remains live with the same "booking reference
        number" (hold ID). New seats can subsequently be added to the empty hold via
        `PATCH /api/v2/holds/{holdId}`. This is not currently supported for TodayTix
        retailer.

        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
        """
        return self._patch(
            f"/api/v2/holds/{hold_id}/clear",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=HoldUpdateClearResponse,
        )


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

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

    async def create(
        self,
        *,
        hold_type: TicketType,
        agent_payment_reference: str | NotGiven = NOT_GIVEN,
        apply_rewards_credit: bool | NotGiven = NOT_GIVEN,
        customer: str | NotGiven = NOT_GIVEN,
        hold_body_id: str | NotGiven = NOT_GIVEN,
        lottery_entry: int | NotGiven = NOT_GIVEN,
        num_tickets: int | NotGiven = NOT_GIVEN,
        offer: int | NotGiven = NOT_GIVEN,
        provider: int | NotGiven = NOT_GIVEN,
        provider_params: str | NotGiven = NOT_GIVEN,
        seats: Iterable[PyosHoldSeatParam] | NotGiven = NOT_GIVEN,
        section: int | NotGiven = NOT_GIVEN,
        should_override_ticket_protection_plan: bool | NotGiven = NOT_GIVEN,
        showtime: int | NotGiven = NOT_GIVEN,
        tickets_by_price_type: Iterable[PriceTypeSelectionParam] | NotGiven = NOT_GIVEN,
        use_unified_checkout: bool | NotGiven = NOT_GIVEN,
        voucher_code: str | 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,
    ) -> Hold:
        """Hold a group of tickets.

        `holdType` define what type of tickets to hold.

        `holdType = REGULAR` and (seatSelectionType == BEST_AVAILABLE ||
        seatSelectionType = null), required params are:

        - `showtime`
        - `provider`
        - `providerParams`
        - `numTickets`

        `holdType = REGULAR` and seatSelectionType == PYOS, required params are:

        - `seatSelectionType`
        - `showtime`
        - `seats`

        `holdType = RUSH`, required params are:

        - `showtime`
        - `numTickets`
        - `customer`

        `holdType = LOTTERY`, required params are:

        - `lotteryEntry`
        - `customer`

        `holdType = OFFER`, required params are:

        - `offer`
        - `customer`

        `holdType = null`, the only param allowed is:

        - `holdBodyId`

        Args:
          hold_type: Type of the tickets (Lottery, Rush and Regular tickets)

          agent_payment_reference: A unique string to identify the booking within a payment on-account retailer's
              internal system

          apply_rewards_credit: Automatically applies rewards credit upon hold creation, if the customer has any

          customer: A customer public facing Id (String). "me" or a hashed string. ?customer=me and
              /customers/me/ are both magical customer identifiers, but they are customer
              identifiers nonetheless. They make the API easier to use than
              ?customer=c.dkd3kl238es or /customers/c.23i8fjdksdfs3.

          hold_body_id: The redisId for finding a saved body of PostHoldInputBody. holdBodyId can link
              us to another PostHoldInputBody in redis and a hold can be made from this
              fetched PostHoldInputBody.

          lottery_entry: Numeric identifier for a resource

          num_tickets: number of tickets to hold, required for REGULAR and RUSH

          offer: Numeric identifier for a resource

          provider: Numeric identifier for a resource

          provider_params: Some server information necessary to hold seats. From `inventoryItem` object.
              required for REGULAR

          seats: The list of seats to be held for the customer.

          section: Numeric identifier for a resource

          should_override_ticket_protection_plan: If true, the hold will not be linked to the show's/rules ticketProtectionPlan
              but the configured alternative

          showtime: Numeric identifier for a resource

          voucher_code: voucher code

          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
        """
        return await self._post(
            "/api/v2/holds",
            body=await async_maybe_transform(
                {
                    "hold_type": hold_type,
                    "agent_payment_reference": agent_payment_reference,
                    "apply_rewards_credit": apply_rewards_credit,
                    "customer": customer,
                    "hold_body_id": hold_body_id,
                    "lottery_entry": lottery_entry,
                    "num_tickets": num_tickets,
                    "offer": offer,
                    "provider": provider,
                    "provider_params": provider_params,
                    "seats": seats,
                    "section": section,
                    "should_override_ticket_protection_plan": should_override_ticket_protection_plan,
                    "showtime": showtime,
                    "tickets_by_price_type": tickets_by_price_type,
                    "use_unified_checkout": use_unified_checkout,
                    "voucher_code": voucher_code,
                },
                hold_create_params.HoldCreateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=Hold,
        )

    async def retrieve(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Get a Hold by ID.

        Non-TodayTix retailers get a `HoldSummary`, TodayTix returns
        `Hold`.

        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
        """
        return await self._get(
            f"/api/v2/holds/{hold_id}",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    async def update(
        self,
        hold_id: int,
        *,
        add_ons: Iterable[hold_update_params.AddOn] | NotGiven = NOT_GIVEN,
        agent_payment_reference: str | NotGiven = NOT_GIVEN,
        apply_rewards_credit: bool | NotGiven = NOT_GIVEN,
        apply_ticket_protection: bool | NotGiven = NOT_GIVEN,
        email: str | NotGiven = NOT_GIVEN,
        hold_type: TicketType | NotGiven = NOT_GIVEN,
        is_rewards_benefit: bool | NotGiven = NOT_GIVEN,
        num_tickets: int | NotGiven = NOT_GIVEN,
        phone_country_code: str | NotGiven = NOT_GIVEN,
        provider: int | NotGiven = NOT_GIVEN,
        provider_params: str | NotGiven = NOT_GIVEN,
        seats: Iterable[PyosHoldSeatParam] | NotGiven = NOT_GIVEN,
        secret: str | NotGiven = NOT_GIVEN,
        section: int | NotGiven = NOT_GIVEN,
        should_override_ticket_protection_plan: bool | NotGiven = NOT_GIVEN,
        showtime: int | NotGiven = NOT_GIVEN,
        tickets_by_price_type: Iterable[PriceTypeSelectionParam] | NotGiven = NOT_GIVEN,
        use_unified_checkout: bool | NotGiven = NOT_GIVEN,
        voucher: str | 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,
    ) -> object:
        """Updates the specified Hold.

        This can be for a few actions:

        1. Add new seats to a previously cleared hold. Not supported on TodayTix
           retailer.
        2. Apply a voucher to a non-empty hold.
        3. Apply a ticket protection plan to the hold.

        The server will verify that the access token is able to manipulate the requested
        holdId.

        Args:
          agent_payment_reference: A unique string to identify the booking within a payment on-account retailer's
              internal system

          apply_rewards_credit: Apply customer rewards credit (TixCash).

          apply_ticket_protection: Link the hold with the show.ticketProtectionPlan if exist

          email: Email of the customer, used to validate the voucher in case of guest checkout.

          hold_type: Type of the tickets (Lottery, Rush and Regular tickets)

          is_rewards_benefit: A flag indicating whether the hold should use the Ticket Protection Rewards
              Benefit (if available for this customer) instead of the Standard Ticket
              Protection.

          phone_country_code: Phone country code to validate if we should apply PILC (Pay In Local Currency)
              or not.

          provider: Numeric identifier for a resource

          provider_params: Some server information necessary to hold seats. This is generally a stringified
              json blob.

          seats: The list of seats to be held for the customer.

          secret: Secret key used to authorize hold permissions.

          section: Numeric identifier for a resource

          should_override_ticket_protection_plan: If true, the hold will not be linked to the show's/rules ticketProtectionPlan
              but the configured alternative

          showtime: Numeric identifier for a resource

          voucher: Optional voucher code when initiating a hold with a voucher (e.g. Link to Hold).

          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
        """
        return await self._patch(
            f"/api/v2/holds/{hold_id}",
            body=await async_maybe_transform(
                {
                    "add_ons": add_ons,
                    "agent_payment_reference": agent_payment_reference,
                    "apply_rewards_credit": apply_rewards_credit,
                    "apply_ticket_protection": apply_ticket_protection,
                    "email": email,
                    "hold_type": hold_type,
                    "is_rewards_benefit": is_rewards_benefit,
                    "num_tickets": num_tickets,
                    "phone_country_code": phone_country_code,
                    "provider": provider,
                    "provider_params": provider_params,
                    "seats": seats,
                    "secret": secret,
                    "section": section,
                    "should_override_ticket_protection_plan": should_override_ticket_protection_plan,
                    "showtime": showtime,
                    "tickets_by_price_type": tickets_by_price_type,
                    "use_unified_checkout": use_unified_checkout,
                    "voucher": voucher,
                },
                hold_update_params.HoldUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    async def list(
        self,
        *,
        customer_id: str | 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,
    ) -> HoldListResponse:
        """Get an array of all holds the present access token is authorized to have.

        For
        now, this is always a list of length one.

        Args:
          customer_id: Customer PubId. Required when credits are specified to verify the user's
              homeLocation

          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
        """
        return await self._get(
            "/api/v2/holds",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform({"customer_id": customer_id}, hold_list_params.HoldListParams),
            ),
            cast_to=HoldListResponse,
        )

    async def delete(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> None:
        """Releases the specified hold.

        The server will verify that the access token is
        able to manipulate (and delete) the requested holdId.

        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
        """
        extra_headers = {"Accept": "*/*", **(extra_headers or {})}
        return await self._delete(
            f"/api/v2/holds/{hold_id}",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=NoneType,
        )

    async def delete_ticket_protection(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Removes applied ticket protection plan to the specified hold.

        The server will
        verify that the access token is able to manipulate the requested holdId.

        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
        """
        return await self._delete(
            f"/api/v2/holds/{hold_id}/ticketProtection",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    async def delete_voucher(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> object:
        """Removes applied voucher to the specified hold.

        The server will verify that the
        access token is able to manipulate the requested holdId.

        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
        """
        return await self._delete(
            f"/api/v2/holds/{hold_id}/voucher",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=object,
        )

    async def retrieve_apple_pay_session(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> HoldRetrieveApplePaySessionResponse:
        """
        Gets Apple Pay Session data to be used to purchase hold with Apple Pay.

        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
        """
        return await self._get(
            f"/api/v2/holds/{hold_id}/applePaySession",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=HoldRetrieveApplePaySessionResponse,
        )

    async def update_clear(
        self,
        hold_id: int,
        *,
        # 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,
    ) -> HoldUpdateClearResponse:
        """Clear the existing "basket" of its seats.

        This means we release the seats on the
        provider side, but the hold remains live with the same "booking reference
        number" (hold ID). New seats can subsequently be added to the empty hold via
        `PATCH /api/v2/holds/{holdId}`. This is not currently supported for TodayTix
        retailer.

        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
        """
        return await self._patch(
            f"/api/v2/holds/{hold_id}/clear",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=HoldUpdateClearResponse,
        )


class HoldsResourceWithRawResponse:
    def __init__(self, holds: HoldsResource) -> None:
        self._holds = holds

        self.create = to_raw_response_wrapper(
            holds.create,
        )
        self.retrieve = to_raw_response_wrapper(
            holds.retrieve,
        )
        self.update = to_raw_response_wrapper(
            holds.update,
        )
        self.list = to_raw_response_wrapper(
            holds.list,
        )
        self.delete = to_raw_response_wrapper(
            holds.delete,
        )
        self.delete_ticket_protection = to_raw_response_wrapper(
            holds.delete_ticket_protection,
        )
        self.delete_voucher = to_raw_response_wrapper(
            holds.delete_voucher,
        )
        self.retrieve_apple_pay_session = to_raw_response_wrapper(
            holds.retrieve_apple_pay_session,
        )
        self.update_clear = to_raw_response_wrapper(
            holds.update_clear,
        )


class AsyncHoldsResourceWithRawResponse:
    def __init__(self, holds: AsyncHoldsResource) -> None:
        self._holds = holds

        self.create = async_to_raw_response_wrapper(
            holds.create,
        )
        self.retrieve = async_to_raw_response_wrapper(
            holds.retrieve,
        )
        self.update = async_to_raw_response_wrapper(
            holds.update,
        )
        self.list = async_to_raw_response_wrapper(
            holds.list,
        )
        self.delete = async_to_raw_response_wrapper(
            holds.delete,
        )
        self.delete_ticket_protection = async_to_raw_response_wrapper(
            holds.delete_ticket_protection,
        )
        self.delete_voucher = async_to_raw_response_wrapper(
            holds.delete_voucher,
        )
        self.retrieve_apple_pay_session = async_to_raw_response_wrapper(
            holds.retrieve_apple_pay_session,
        )
        self.update_clear = async_to_raw_response_wrapper(
            holds.update_clear,
        )


class HoldsResourceWithStreamingResponse:
    def __init__(self, holds: HoldsResource) -> None:
        self._holds = holds

        self.create = to_streamed_response_wrapper(
            holds.create,
        )
        self.retrieve = to_streamed_response_wrapper(
            holds.retrieve,
        )
        self.update = to_streamed_response_wrapper(
            holds.update,
        )
        self.list = to_streamed_response_wrapper(
            holds.list,
        )
        self.delete = to_streamed_response_wrapper(
            holds.delete,
        )
        self.delete_ticket_protection = to_streamed_response_wrapper(
            holds.delete_ticket_protection,
        )
        self.delete_voucher = to_streamed_response_wrapper(
            holds.delete_voucher,
        )
        self.retrieve_apple_pay_session = to_streamed_response_wrapper(
            holds.retrieve_apple_pay_session,
        )
        self.update_clear = to_streamed_response_wrapper(
            holds.update_clear,
        )


class AsyncHoldsResourceWithStreamingResponse:
    def __init__(self, holds: AsyncHoldsResource) -> None:
        self._holds = holds

        self.create = async_to_streamed_response_wrapper(
            holds.create,
        )
        self.retrieve = async_to_streamed_response_wrapper(
            holds.retrieve,
        )
        self.update = async_to_streamed_response_wrapper(
            holds.update,
        )
        self.list = async_to_streamed_response_wrapper(
            holds.list,
        )
        self.delete = async_to_streamed_response_wrapper(
            holds.delete,
        )
        self.delete_ticket_protection = async_to_streamed_response_wrapper(
            holds.delete_ticket_protection,
        )
        self.delete_voucher = async_to_streamed_response_wrapper(
            holds.delete_voucher,
        )
        self.retrieve_apple_pay_session = async_to_streamed_response_wrapper(
            holds.retrieve_apple_pay_session,
        )
        self.update_clear = async_to_streamed_response_wrapper(
            holds.update_clear,
        )
