# 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, 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 ...types.feeds import v2_list_shows_params, v2_retrieve_feed_params
from ..._base_client import make_request_options
from ...types.feeds.v2_list_shows_response import V2ListShowsResponse

__all__ = ["V2Resource", "AsyncV2Resource"]


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

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

    def list_shows(
        self,
        *,
        location: 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,
    ) -> V2ListShowsResponse:
        """
        A feed for show data, used for Iterable for supplemental data for email
        templating. Includes only active shows in the requested locations. Excludes URL
        shows.

        Args:
          location: A single location ID or comma-separated list of IDs. If none are provided, the
              feed will include data for all locations.

          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(
            "/feeds/v2/shows",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform({"location": location}, v2_list_shows_params.V2ListShowsParams),
            ),
            cast_to=V2ListShowsResponse,
        )

    def retrieve_feed(
        self,
        *,
        type: Literal["FACEBOOK", "ITERABLE"],
        include_shows_without_allocations: bool | NotGiven = NOT_GIVEN,
        location: str | NotGiven = NOT_GIVEN,
        sort_by: Literal["MAX_DISCOUNT_PERCENTAGE", "TOP_SELLING_RANK"] | NotGiven = NOT_GIVEN,
        sort_order: Literal["ASC", "DESC"] | 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,
    ) -> None:
        """
        Returns a product feed containing information about shows in the format required
        by a particular advertising platform (determined based on the provided `type`).

        Args:
          type: The type determines the fields included with each entry in the feed and the
              format in which the data is returned

          include_shows_without_allocations: Whether to include shows without any regular allocations. By default, shows that
              don't have active regular allocations at the time of the query will NOT be
              included.

          location: A single location ID or comma-separated list of IDs. If none are provided, the
              feed will include data for all locations.

          sort_by: Field by which to sort the results.

          sort_order: Order by which to sort the results, if a sortBy parameter is provided.

          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._get(
            "/feeds/v2/feed",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "type": type,
                        "include_shows_without_allocations": include_shows_without_allocations,
                        "location": location,
                        "sort_by": sort_by,
                        "sort_order": sort_order,
                    },
                    v2_retrieve_feed_params.V2RetrieveFeedParams,
                ),
            ),
            cast_to=NoneType,
        )


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

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

    async def list_shows(
        self,
        *,
        location: 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,
    ) -> V2ListShowsResponse:
        """
        A feed for show data, used for Iterable for supplemental data for email
        templating. Includes only active shows in the requested locations. Excludes URL
        shows.

        Args:
          location: A single location ID or comma-separated list of IDs. If none are provided, the
              feed will include data for all locations.

          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(
            "/feeds/v2/shows",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform({"location": location}, v2_list_shows_params.V2ListShowsParams),
            ),
            cast_to=V2ListShowsResponse,
        )

    async def retrieve_feed(
        self,
        *,
        type: Literal["FACEBOOK", "ITERABLE"],
        include_shows_without_allocations: bool | NotGiven = NOT_GIVEN,
        location: str | NotGiven = NOT_GIVEN,
        sort_by: Literal["MAX_DISCOUNT_PERCENTAGE", "TOP_SELLING_RANK"] | NotGiven = NOT_GIVEN,
        sort_order: Literal["ASC", "DESC"] | 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,
    ) -> None:
        """
        Returns a product feed containing information about shows in the format required
        by a particular advertising platform (determined based on the provided `type`).

        Args:
          type: The type determines the fields included with each entry in the feed and the
              format in which the data is returned

          include_shows_without_allocations: Whether to include shows without any regular allocations. By default, shows that
              don't have active regular allocations at the time of the query will NOT be
              included.

          location: A single location ID or comma-separated list of IDs. If none are provided, the
              feed will include data for all locations.

          sort_by: Field by which to sort the results.

          sort_order: Order by which to sort the results, if a sortBy parameter is provided.

          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._get(
            "/feeds/v2/feed",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {
                        "type": type,
                        "include_shows_without_allocations": include_shows_without_allocations,
                        "location": location,
                        "sort_by": sort_by,
                        "sort_order": sort_order,
                    },
                    v2_retrieve_feed_params.V2RetrieveFeedParams,
                ),
            ),
            cast_to=NoneType,
        )


class V2ResourceWithRawResponse:
    def __init__(self, v2: V2Resource) -> None:
        self._v2 = v2

        self.list_shows = to_raw_response_wrapper(
            v2.list_shows,
        )
        self.retrieve_feed = to_raw_response_wrapper(
            v2.retrieve_feed,
        )


class AsyncV2ResourceWithRawResponse:
    def __init__(self, v2: AsyncV2Resource) -> None:
        self._v2 = v2

        self.list_shows = async_to_raw_response_wrapper(
            v2.list_shows,
        )
        self.retrieve_feed = async_to_raw_response_wrapper(
            v2.retrieve_feed,
        )


class V2ResourceWithStreamingResponse:
    def __init__(self, v2: V2Resource) -> None:
        self._v2 = v2

        self.list_shows = to_streamed_response_wrapper(
            v2.list_shows,
        )
        self.retrieve_feed = to_streamed_response_wrapper(
            v2.retrieve_feed,
        )


class AsyncV2ResourceWithStreamingResponse:
    def __init__(self, v2: AsyncV2Resource) -> None:
        self._v2 = v2

        self.list_shows = async_to_streamed_response_wrapper(
            v2.list_shows,
        )
        self.retrieve_feed = async_to_streamed_response_wrapper(
            v2.retrieve_feed,
        )
