# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._createable_api_resource import CreateableAPIResource
from stripe._expandable_field import ExpandableField
from stripe._list_object import ListObject
from stripe._stripe_object import StripeObject, UntypedStripeObject
from stripe._updateable_api_resource import UpdateableAPIResource
from stripe._util import class_method_variant, sanitize_id
from typing import ClassVar, List, Optional, cast, overload
from typing_extensions import Literal, Unpack, TYPE_CHECKING

if TYPE_CHECKING:
    from stripe._profile import Profile
    from stripe.delegated_checkout._order import Order
    from stripe.params.delegated_checkout._requested_session_confirm_params import (
        RequestedSessionConfirmParams,
    )
    from stripe.params.delegated_checkout._requested_session_create_params import (
        RequestedSessionCreateParams,
    )
    from stripe.params.delegated_checkout._requested_session_expire_params import (
        RequestedSessionExpireParams,
    )
    from stripe.params.delegated_checkout._requested_session_list_orders_params import (
        RequestedSessionListOrdersParams,
    )
    from stripe.params.delegated_checkout._requested_session_modify_params import (
        RequestedSessionModifyParams,
    )
    from stripe.params.delegated_checkout._requested_session_retrieve_params import (
        RequestedSessionRetrieveParams,
    )
    from stripe.shared_payment._issued_token import IssuedToken


class RequestedSession(
    CreateableAPIResource["RequestedSession"],
    UpdateableAPIResource["RequestedSession"],
):
    """
    A requested session is a session that has been requested by a customer.
    """

    OBJECT_NAME: ClassVar[Literal["delegated_checkout.requested_session"]] = (
        "delegated_checkout.requested_session"
    )

    class AffiliateAttribution(StripeObject):
        class Source(StripeObject):
            platform: Optional[str]
            """
            The platform of the attribution source.
            """
            type: Literal["platform", "url"]
            """
            The type of the attribution source.
            """
            url: Optional[str]
            """
            The URL of the attribution source.
            """

        campaign_id: Optional[str]
        """
        Agent-scoped campaign identifier.
        """
        creative_id: Optional[str]
        """
        Agent-scoped creative identifier.
        """
        expires_at: int
        """
        Timestamp when the attribution token expires.
        """
        identification_token: str
        """
        Agent-issued secret to validate the legitimacy of the source of this data.
        """
        issued_at: int
        """
        Timestamp for when the attribution token was issued.
        """
        provider: str
        """
        Identifier for the attribution agent / affiliate network namespace.
        """
        publisher_id: Optional[str]
        """
        Agent-scoped affiliate/publisher identifier.
        """
        shared_metadata: Optional[UntypedStripeObject[str]]
        """
        Freeform key/value pairs for additional non-sensitive per-agent data.
        """
        source: Optional[Source]
        """
        Context about where the attribution originated.
        """
        sub_id: Optional[str]
        """
        Agent-scoped sub-tracking identifier.
        """
        touchpoint: Literal["first", "last"]
        """
        Whether this is the first or last touchpoint.
        """
        _inner_class_types = {"source": Source}

    class BuyerConsents(StripeObject):
        class Marketing(StripeObject):
            class Consent(StripeObject):
                channel: Literal["email", "sms"]
                """
                The marketing consent channel.
                """
                status: Literal["granted", "none"]
                """
                The consent status. 'granted' means the buyer opted in, 'none' means they did not.
                """

            class Option(StripeObject):
                channel: Literal["email", "sms"]
                """
                The marketing channel type.
                """
                description: str
                """
                The description of the marketing consent option.
                """
                privacy_policy_url: str
                """
                The privacy policy URL for this marketing channel.
                """

            consents: Optional[List[Consent]]
            """
            The buyer's marketing consent choices.
            """
            options: Optional[List[Option]]
            """
            The available marketing consent options.
            """
            _inner_class_types = {"consents": Consent, "options": Option}

        marketing: Optional[Marketing]
        """
        The marketing consent options.
        """
        _inner_class_types = {"marketing": Marketing}

    class Discounts(StripeObject):
        class Applied(StripeObject):
            amount_off: Optional[int]
            """
            The amount off provided by this discount.
            """
            code: str
            """
            The discount code.
            """
            currency: Optional[str]
            """
            The currency of the discount amount.
            """
            key: str
            """
            The unique key of the applied discount.
            """
            name: str
            """
            The display name of the discount.
            """
            percent_off: Optional[float]
            """
            The percentage off provided by this discount.
            """
            type: Literal["cart", "fulfillment"]
            """
            The type of discount.
            """

        class Invalid(StripeObject):
            code: str
            """
            The discount code that was invalid.
            """
            reason: str
            """
            The reason the discount code is invalid.
            """

        applied: Optional[List[Applied]]
        """
        The list of successfully applied discounts.
        """
        invalid: Optional[List[Invalid]]
        """
        The list of discount codes that could not be applied.
        """
        _inner_class_types = {"applied": Applied, "invalid": Invalid}

    class FulfillmentDetails(StripeObject):
        class Address(StripeObject):
            city: Optional[str]
            """
            City, district, suburb, town, or village.
            """
            country: Optional[str]
            """
            Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
            """
            line1: Optional[str]
            """
            Address line 1, such as the street, PO Box, or company name.
            """
            line2: Optional[str]
            """
            Address line 2, such as the apartment, suite, unit, or building.
            """
            postal_code: Optional[str]
            """
            ZIP or postal code.
            """
            state: Optional[str]
            """
            State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
            """

        class FulfillmentOption(StripeObject):
            class Digital(StripeObject):
                class DigitalOption(StripeObject):
                    description: Optional[str]
                    """
                    The description of the digital fulfillment option.
                    """
                    digital_amount: int
                    """
                    The digital amount of the digital fulfillment option.
                    """
                    display_name: str
                    """
                    The display name of the digital fulfillment option.
                    """
                    key: str
                    """
                    The key of the digital fulfillment option.
                    """
                    line_item_keys: Optional[List[str]]
                    """
                    The line item keys associated with this digital fulfillment option.
                    """

                digital_options: Optional[List[DigitalOption]]
                """
                The digital options.
                """
                _inner_class_types = {"digital_options": DigitalOption}

            class Shipping(StripeObject):
                class ShippingOption(StripeObject):
                    description: Optional[str]
                    """
                    The description of the shipping option.
                    """
                    display_name: str
                    """
                    The display name of the shipping option.
                    """
                    earliest_delivery_time: Optional[int]
                    """
                    The earliest delivery time of the shipping option.
                    """
                    key: str
                    """
                    The key of the shipping option.
                    """
                    latest_delivery_time: Optional[int]
                    """
                    The latest delivery time of the shipping option.
                    """
                    line_item_keys: Optional[List[str]]
                    """
                    The line item keys associated with this shipping option.
                    """
                    shipping_amount: int
                    """
                    The shipping amount of the shipping option.
                    """

                shipping_options: Optional[List[ShippingOption]]
                """
                The shipping options.
                """
                _inner_class_types = {"shipping_options": ShippingOption}

            digital: Optional[Digital]
            """
            The digital fulfillment option.
            """
            shipping: Optional[Shipping]
            """
            The shipping option.
            """
            type: Literal["digital", "shipping"]
            """
            The type of the fulfillment option.
            """
            _inner_class_types = {"digital": Digital, "shipping": Shipping}

        class SelectedFulfillmentOption(StripeObject):
            class Digital(StripeObject):
                digital_option: Optional[str]
                """
                The digital option.
                """

            class Shipping(StripeObject):
                shipping_option: Optional[str]
                """
                The shipping option.
                """

            digital: Optional[Digital]
            """
            The digital fulfillment option.
            """
            shipping: Optional[Shipping]
            """
            The shipping option.
            """
            type: Literal["digital", "shipping"]
            """
            The type of the selected fulfillment option.
            """
            _inner_class_types = {"digital": Digital, "shipping": Shipping}

        class SelectedFulfillmentOptionOverride(StripeObject):
            class Digital(StripeObject):
                digital_option: Optional[str]
                """
                The digital option.
                """

            class Shipping(StripeObject):
                shipping_option: Optional[str]
                """
                The shipping option.
                """

            digital: Optional[Digital]
            """
            The digital fulfillment option.
            """
            line_item_keys: Optional[List[str]]
            """
            The line items this fulfillment option applies to.
            """
            shipping: Optional[Shipping]
            """
            The shipping option.
            """
            type: Literal["digital", "shipping"]
            """
            The type of the selected fulfillment option.
            """
            _inner_class_types = {"digital": Digital, "shipping": Shipping}

        address: Optional[Address]
        """
        The fulfillment address.
        """
        email: Optional[str]
        """
        The email address for the fulfillment details.
        """
        fulfillment_options: Optional[List[FulfillmentOption]]
        """
        The fulfillment options.
        """
        name: Optional[str]
        """
        The name for the fulfillment details.
        """
        phone: Optional[str]
        """
        The phone number for the fulfillment details.
        """
        selected_fulfillment_option: Optional[SelectedFulfillmentOption]
        """
        The selected fulfillment option.
        """
        selected_fulfillment_option_overrides: Optional[
            List[SelectedFulfillmentOptionOverride]
        ]
        """
        Per-item fulfillment option overrides.
        """
        _inner_class_types = {
            "address": Address,
            "fulfillment_options": FulfillmentOption,
            "selected_fulfillment_option": SelectedFulfillmentOption,
            "selected_fulfillment_option_overrides": SelectedFulfillmentOptionOverride,
        }

    class LineItemDetail(StripeObject):
        class ProductDetails(StripeObject):
            class CustomAttribute(StripeObject):
                display_name: str
                """
                The display name of the custom attribute.
                """
                value: str
                """
                The value of the custom attribute.
                """

            class Disclosure(StripeObject):
                content: str
                """
                The content of the disclosure.
                """
                content_type: Literal["link", "markdown", "plain"]
                """
                The content type of the disclosure.
                """
                type: Literal["disclaimer"]
                """
                The type of disclosure.
                """

            custom_attributes: Optional[List[CustomAttribute]]
            """
            Custom attributes for the product.
            """
            description: Optional[str]
            """
            The description of the product.
            """
            disclosures: Optional[List[Disclosure]]
            """
            Disclosures for the product.
            """
            images: Optional[List[str]]
            """
            The images of the product.
            """
            title: str
            """
            The title of the product.
            """
            _inner_class_types = {
                "custom_attributes": CustomAttribute,
                "disclosures": Disclosure,
            }

        amount_discount: int
        """
        The total discount for this line item. If no discount were applied, defaults to 0.
        """
        amount_sale: Optional[int]
        """
        The sale amount for this line item.
        """
        amount_subtotal: int
        """
        The total before any discounts or taxes are applied.
        """
        fulfillment_type: str
        """
        The fulfillment type of the line item.
        """
        key: str
        """
        The key of the line item.
        """
        product_details: Optional[ProductDetails]
        quantity: int
        """
        The quantity of the line item.
        """
        sku_id: str
        """
        The SKU ID of the line item.
        """
        unit_amount: int
        """
        The per-unit amount of the item before any discounts or taxes are applied.
        """
        _inner_class_types = {"product_details": ProductDetails}

    class OrderDetails(StripeObject):
        order_id: Optional[str]
        """
        The seller's order identifier.
        """
        order_status_url: Optional[str]
        """
        The URL to the order status.
        """

    class PaymentMethodOptions(StripeObject):
        class Card(StripeObject):
            brands_blocked: Optional[
                List[Literal["american_express", "mastercard", "visa"]]
            ]
            """
            The card brands blocked by the agent.
            """

        card: Optional[Card]
        """
        Card-specific payment method options.
        """
        displayable_card_brands: Optional[
            List[Literal["american_express", "mastercard", "visa"]]
        ]
        """
        The computed displayable card brands.
        """
        displayable_payment_method_types: Optional[
            List[Literal["affirm", "card", "klarna"]]
        ]
        """
        The computed displayable payment method types.
        """
        excluded_payment_method_types: Optional[
            List[Literal["affirm", "card", "klarna"]]
        ]
        """
        The payment method types excluded by the agent.
        """
        _inner_class_types = {"card": Card}

    class PaymentMethodPreview(StripeObject):
        class BillingDetails(StripeObject):
            class Address(StripeObject):
                city: str
                """
                City, district, suburb, town, or village.
                """
                country: str
                """
                Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
                """
                line1: str
                """
                Address line 1, such as the street, PO Box, or company name.
                """
                line2: Optional[str]
                """
                Address line 2, such as the apartment, suite, unit, or building.
                """
                postal_code: str
                """
                ZIP or postal code.
                """
                state: str
                """
                State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
                """

            address: Optional[Address]
            """
            The billing address.
            """
            email: Optional[str]
            """
            The email address for the billing details.
            """
            name: Optional[str]
            """
            The name for the billing details.
            """
            phone: Optional[str]
            """
            The phone number for the billing details.
            """
            _inner_class_types = {"address": Address}

        class Card(StripeObject):
            exp_month: int
            """
            The expiry month of the card.
            """
            exp_year: int
            """
            The expiry year of the card.
            """
            last4: str
            """
            The last 4 digits of the card number.
            """

        billing_details: Optional[BillingDetails]
        """
        The billing details of the payment method.
        """
        card: Optional[Card]
        """
        The card details of the payment method.
        """
        type: str
        """
        The type of the payment method.
        """
        _inner_class_types = {"billing_details": BillingDetails, "card": Card}

    class RiskDetails(StripeObject):
        class ClientDeviceMetadataDetails(StripeObject):
            radar_session: Optional[str]
            """
            The radar session for the client device.
            """
            referrer: Optional[str]
            """
            The referrer of the client device.
            """
            remote_ip: Optional[str]
            """
            The remote IP address of the client device.
            """
            time_on_page_ms: Optional[int]
            """
            The time spent on the page by the client device.
            """
            user_agent: Optional[str]
            """
            The user agent of the client device.
            """

        client_device_metadata_details: Optional[ClientDeviceMetadataDetails]
        """
        The risk metadata for the client device.
        """
        _inner_class_types = {
            "client_device_metadata_details": ClientDeviceMetadataDetails,
        }

    class SellerDetails(StripeObject):
        class MarketplaceSellerDetails(StripeObject):
            pass

        card_brands: Optional[
            List[Literal["american_express", "mastercard", "visa"]]
        ]
        """
        The card brands supported by the seller.
        """
        marketplace_seller_details: Optional[MarketplaceSellerDetails]
        """
        The marketplace seller details.
        """
        network_profile: ExpandableField["Profile"]
        """
        The network profile of the seller.
        """
        payment_method_types: Optional[
            List[Literal["affirm", "card", "klarna"]]
        ]
        """
        The payment method types supported by the seller.
        """
        privacy_notice_url: Optional[str]
        """
        The URL to the seller's privacy notice.
        """
        return_policy_url: Optional[str]
        """
        The URL to the seller's return policy.
        """
        store_policy_url: Optional[str]
        """
        The URL to the seller's store policy.
        """
        terms_of_service_url: Optional[str]
        """
        The URL to the seller's terms of service.
        """
        _inner_class_types = {
            "marketplace_seller_details": MarketplaceSellerDetails,
        }

    class TotalDetails(StripeObject):
        class ApplicableFee(StripeObject):
            amount: int
            """
            The amount of the applicable fee.
            """
            description: Optional[str]
            """
            The description of the applicable fee.
            """
            display_name: str
            """
            The display name of the applicable fee.
            """

        class Breakdown(StripeObject):
            class Discount(StripeObject):
                amount: int
                """
                The amount this discount contributed to the total discount.
                """
                key: str
                """
                The key of the applied discount.
                """

            discounts: Optional[List[Discount]]
            """
            The breakdown of discounts applied to the session.
            """
            _inner_class_types = {"discounts": Discount}

        amount_cart_discount: Optional[int]
        """
        The amount of order-level discounts applied to the cart. The total discount amount for this session can be computed by summing the cart discount and the item discounts.
        """
        amount_discount: Optional[int]
        """
        The total discount amount from discount codes across the session.
        """
        amount_fulfillment: Optional[int]
        """
        The amount fulfillment of the total details.
        """
        amount_items_discount: Optional[int]
        """
        The amount of item-level discounts applied to the cart. The total discount amount for this session can be computed by summing the cart discount and the item discounts.
        """
        amount_sale: Optional[int]
        """
        The total sale amount across the session.
        """
        amount_tax: Optional[int]
        """
        The amount tax of the total details.
        """
        applicable_fees: Optional[List[ApplicableFee]]
        """
        The applicable fees of the total details.
        """
        breakdown: Optional[Breakdown]
        """
        The breakdown of discounts applied to the session.
        """
        _inner_class_types = {
            "applicable_fees": ApplicableFee,
            "breakdown": Breakdown,
        }

    affiliate_attributions: Optional[List[AffiliateAttribution]]
    """
    Affiliate attribution data associated with this requested session.
    """
    amount_subtotal: Optional[int]
    """
    The subtotal amount of the requested session.
    """
    amount_total: Optional[int]
    """
    The total amount of the requested session.
    """
    buyer_consents: Optional[BuyerConsents]
    """
    The buyer consent options for this requested session, including marketing preferences.
    """
    created_at: int
    """
    Time at which the object was created. Measured in seconds since the Unix epoch.
    """
    currency: str
    """
    Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
    """
    customer: Optional[str]
    """
    The customer for this requested session.
    """
    discounts: Optional[Discounts]
    """
    The discounts applied to and rejected from this requested session.
    """
    expires_at: int
    """
    Time at which the requested session expires. Measured in seconds since the Unix epoch.
    """
    fulfillment_details: Optional[FulfillmentDetails]
    """
    The details of the fulfillment.
    """
    id: str
    """
    Unique identifier for the object.
    """
    line_item_details: List[LineItemDetail]
    """
    The line items to be purchased.
    """
    livemode: bool
    """
    If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
    """
    metadata: Optional[UntypedStripeObject[str]]
    """
    Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    """
    object: Literal["delegated_checkout.requested_session"]
    """
    String representing the object's type. Objects of the same type share the same value.
    """
    order_details: Optional[OrderDetails]
    """
    The details of the order.
    """
    payment_method: Optional[str]
    """
    The payment method used for the requested session.
    """
    payment_method_options: Optional[PaymentMethodOptions]
    """
    The payment method options for this requested session.
    """
    payment_method_preview: Optional[PaymentMethodPreview]
    """
    The preview of the payment method to be created when the requested session is confirmed.
    """
    risk_details: Optional[RiskDetails]
    """
    The risk details of the requested session.
    """
    seller_details: SellerDetails
    setup_future_usage: Optional[Literal["on_session"]]
    """
    Whether or not the payment method should be saved for future use.
    """
    shared_metadata: Optional[UntypedStripeObject[str]]
    """
    The metadata shared with the seller.
    """
    shared_payment_issued_token: Optional[ExpandableField["IssuedToken"]]
    """
    The SPT used for payment.
    """
    status: Literal["completed", "expired", "open", "requires_action"]
    """
    The status of the requested session.
    """
    total_details: TotalDetails
    updated_at: int
    """
    Time at which the object was last updated. Measured in seconds since the Unix epoch.
    """

    @classmethod
    def _cls_confirm(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionConfirmParams"],
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        return cast(
            "RequestedSession",
            cls._static_request(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/confirm".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    def confirm(
        requested_session: str,
        **params: Unpack["RequestedSessionConfirmParams"],
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        ...

    @overload
    def confirm(
        self, **params: Unpack["RequestedSessionConfirmParams"]
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        ...

    @class_method_variant("_cls_confirm")
    def confirm(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionConfirmParams"]
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        return cast(
            "RequestedSession",
            self._request(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/confirm".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    async def _cls_confirm_async(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionConfirmParams"],
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        return cast(
            "RequestedSession",
            await cls._static_request_async(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/confirm".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    async def confirm_async(
        requested_session: str,
        **params: Unpack["RequestedSessionConfirmParams"],
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        ...

    @overload
    async def confirm_async(
        self, **params: Unpack["RequestedSessionConfirmParams"]
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        ...

    @class_method_variant("_cls_confirm_async")
    async def confirm_async(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionConfirmParams"]
    ) -> "RequestedSession":
        """
        Confirms a requested session
        """
        return cast(
            "RequestedSession",
            await self._request_async(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/confirm".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    def create(
        cls, **params: Unpack["RequestedSessionCreateParams"]
    ) -> "RequestedSession":
        """
        Creates a requested session
        """
        return cast(
            "RequestedSession",
            cls._static_request(
                "post",
                cls.class_url(),
                params=params,
            ),
        )

    @classmethod
    async def create_async(
        cls, **params: Unpack["RequestedSessionCreateParams"]
    ) -> "RequestedSession":
        """
        Creates a requested session
        """
        return cast(
            "RequestedSession",
            await cls._static_request_async(
                "post",
                cls.class_url(),
                params=params,
            ),
        )

    @classmethod
    def _cls_expire(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionExpireParams"],
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        return cast(
            "RequestedSession",
            cls._static_request(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/expire".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    def expire(
        requested_session: str,
        **params: Unpack["RequestedSessionExpireParams"],
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        ...

    @overload
    def expire(
        self, **params: Unpack["RequestedSessionExpireParams"]
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        ...

    @class_method_variant("_cls_expire")
    def expire(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionExpireParams"]
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        return cast(
            "RequestedSession",
            self._request(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/expire".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    async def _cls_expire_async(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionExpireParams"],
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        return cast(
            "RequestedSession",
            await cls._static_request_async(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/expire".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    async def expire_async(
        requested_session: str,
        **params: Unpack["RequestedSessionExpireParams"],
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        ...

    @overload
    async def expire_async(
        self, **params: Unpack["RequestedSessionExpireParams"]
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        ...

    @class_method_variant("_cls_expire_async")
    async def expire_async(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionExpireParams"]
    ) -> "RequestedSession":
        """
        Expires a requested session
        """
        return cast(
            "RequestedSession",
            await self._request_async(
                "post",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/expire".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    def _cls_list_orders(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionListOrdersParams"],
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        return cast(
            ListObject["Order"],
            cls._static_request(
                "get",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/orders".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    def list_orders(
        requested_session: str,
        **params: Unpack["RequestedSessionListOrdersParams"],
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        ...

    @overload
    def list_orders(
        self, **params: Unpack["RequestedSessionListOrdersParams"]
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        ...

    @class_method_variant("_cls_list_orders")
    def list_orders(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionListOrdersParams"]
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        return cast(
            ListObject["Order"],
            self._request(
                "get",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/orders".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    async def _cls_list_orders_async(
        cls,
        requested_session: str,
        **params: Unpack["RequestedSessionListOrdersParams"],
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        return cast(
            ListObject["Order"],
            await cls._static_request_async(
                "get",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/orders".format(
                    requested_session=sanitize_id(requested_session)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    async def list_orders_async(
        requested_session: str,
        **params: Unpack["RequestedSessionListOrdersParams"],
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        ...

    @overload
    async def list_orders_async(
        self, **params: Unpack["RequestedSessionListOrdersParams"]
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        ...

    @class_method_variant("_cls_list_orders_async")
    async def list_orders_async(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["RequestedSessionListOrdersParams"]
    ) -> ListObject["Order"]:
        """
        Lists orders for a delegated checkout requested session.
        """
        return cast(
            ListObject["Order"],
            await self._request_async(
                "get",
                "/v1/delegated_checkout/requested_sessions/{requested_session}/orders".format(
                    requested_session=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    def modify(
        cls, id: str, **params: Unpack["RequestedSessionModifyParams"]
    ) -> "RequestedSession":
        """
        Updates a requested session
        """
        url = "%s/%s" % (cls.class_url(), sanitize_id(id))
        return cast(
            "RequestedSession",
            cls._static_request(
                "post",
                url,
                params=params,
            ),
        )

    @classmethod
    async def modify_async(
        cls, id: str, **params: Unpack["RequestedSessionModifyParams"]
    ) -> "RequestedSession":
        """
        Updates a requested session
        """
        url = "%s/%s" % (cls.class_url(), sanitize_id(id))
        return cast(
            "RequestedSession",
            await cls._static_request_async(
                "post",
                url,
                params=params,
            ),
        )

    @classmethod
    def retrieve(
        cls, id: str, **params: Unpack["RequestedSessionRetrieveParams"]
    ) -> "RequestedSession":
        """
        Retrieves a requested session
        """
        instance = cls(id, **params)
        instance.refresh()
        return instance

    @classmethod
    async def retrieve_async(
        cls, id: str, **params: Unpack["RequestedSessionRetrieveParams"]
    ) -> "RequestedSession":
        """
        Retrieves a requested session
        """
        instance = cls(id, **params)
        await instance.refresh_async()
        return instance

    _inner_class_types = {
        "affiliate_attributions": AffiliateAttribution,
        "buyer_consents": BuyerConsents,
        "discounts": Discounts,
        "fulfillment_details": FulfillmentDetails,
        "line_item_details": LineItemDetail,
        "order_details": OrderDetails,
        "payment_method_options": PaymentMethodOptions,
        "payment_method_preview": PaymentMethodPreview,
        "risk_details": RiskDetails,
        "seller_details": SellerDetails,
        "total_details": TotalDetails,
    }
