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

import datetime as _datetime
from typing import List, Optional
from typing_extensions import Literal

from pydantic import Field as FieldInfo

from .ticket import Ticket
from .account import Account
from .add_ons import AddOns
from .voucher import Voucher
from .promotion import Promotion
from ...._models import BaseModel
from .price_item import PriceItem
from .seats_info import SeatsInfo
from .product_type import ProductType
from .post_hold_input_body import PostHoldInputBody
from .shows.admission_type import AdmissionType
from .carts.currency_object import CurrencyObject
from .carts.delivery_method import DeliveryMethod
from .customers.ticket_type import TicketType
from .earned_rewards_summary import EarnedRewardsSummary
from .customers.payment_method import PaymentMethod
from .ticket_protection_summary import TicketProtectionSummary

__all__ = [
    "Hold",
    "PspOption",
    "Showtime",
    "ShowtimeShow",
    "ShowtimeShowLocation",
    "SupportedDeliveryMethod",
    "AvailableTicketProtectionRewardsBenefit",
    "ConfigurableTexts",
    "ConfigurableTextsAboutSeatsButton",
    "ReservedOfferHold",
]


class PspOption(BaseModel):
    api_type: str = FieldInfo(alias="_type")

    is_primary_psp: bool = FieldInfo(alias="isPrimaryPsp")

    merchant_account: str = FieldInfo(alias="merchantAccount")

    payment_gateway_type: str = FieldInfo(alias="paymentGatewayType")

    payment_session: object = FieldInfo(alias="paymentSession")

    third_party_payments_enabled: List[object] = FieldInfo(alias="thirdPartyPaymentsEnabled")


class ShowtimeShowLocation(BaseModel):
    id: int
    """Numeric identifier for a resource"""

    api_type: str = FieldInfo(alias="_type")

    abbr: str
    """Location abbreviation"""

    country: Literal["US", "GB", "CA", "AU"]
    """The location's country.

    2-letter ISO code at the end of the locale string. e.g. `US` for `en_US`
    """

    currency: Literal["USD", "GBP", "CAD", "AUD"]
    """The location's currency (3-letter ISO code)"""

    currency_symbol: Literal["$", "£"] = FieldInfo(alias="currencySymbol")
    """The location's currency symbol."""

    include_fees: bool = FieldInfo(alias="includeFees")
    """Whether or not fees are included in the display price."""

    language: Literal["en"]
    """The location's language.

    2-letter ISO code at the beginning of the locale string (e.g. `en` for `en_US`).
    """

    locale: Literal["en_US", "en_GB", "en_CA", "en_AU"]
    """ISO locale string (2-letter language code, underscore, 2-letter country code)"""

    name: str
    """The location's full name."""

    seo_name: str = FieldInfo(alias="seoName")
    """The location's SEO name."""

    timezone: str
    """The location's ISO timezone string."""


class ShowtimeShow(BaseModel):
    id: int
    """Numeric identifier for a resource"""

    api_type: str = FieldInfo(alias="_type")

    admission_type: AdmissionType = FieldInfo(alias="admissionType")
    """
    The type of admission allowed for the Show. TIMED = regular theater performance,
    e.g. on date X at time Y. DATED = open-ended admission on a specific date, like
    a museum. OPEN = open-ended admission on any date, like a streamed performance.
    """

    location: ShowtimeShowLocation

    name: str
    """The name of the show"""

    product_type: ProductType = FieldInfo(alias="productType")
    """The type of show being sold (Attraction, Show, Streaming and Bus Tour)"""

    account: Optional[Account] = None
    """TodayTix partner account"""

    avg_rating: Optional[float] = FieldInfo(alias="avgRating", default=None)
    """The average rating for this show among TT customers."""

    num_ratings: Optional[int] = FieldInfo(alias="numRatings", default=None)
    """The number of ratings for this show among unique TT customers."""


class Showtime(BaseModel):
    id: int
    """Numeric identifier for a resource"""

    api_type: str = FieldInfo(alias="_type")

    datetime: _datetime.datetime
    """The show's local datetime in ISO format."""

    datetime_epoch: int = FieldInfo(alias="datetimeEpoch")
    """The epoch time representation of a date-time."""

    day_of_week: Literal["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"] = FieldInfo(
        alias="dayOfWeek"
    )
    """The showtime's local day of week"""

    daypart: Literal["MATINEE", "EVENING"]
    """Matinée vs evening"""

    local_date: _datetime.date = FieldInfo(alias="localDate")
    """A local date (in the format yyyy-MM-dd)."""

    local_time: str = FieldInfo(alias="localTime")
    """A local time (in the format hh:mm:ss)."""

    num_days_out: int = FieldInfo(alias="numDaysOut")
    """
    The number of days in between today (in the show's local timezone) and the
    showtime's local date.
    """

    admission_type: Optional[AdmissionType] = FieldInfo(alias="admissionType", default=None)
    """
    The type of admission allowed for the Show. TIMED = regular theater performance,
    e.g. on date X at time Y. DATED = open-ended admission on a specific date, like
    a museum. OPEN = open-ended admission on any date, like a streamed performance.
    """

    end_datetime: Optional[_datetime.datetime] = FieldInfo(alias="endDatetime", default=None)
    """Showtime's end datetime"""

    end_datetime_epoch: Optional[int] = FieldInfo(alias="endDatetimeEpoch", default=None)
    """The epoch time representation of a date-time."""

    end_local_date: Optional[_datetime.date] = FieldInfo(alias="endLocalDate", default=None)
    """A local date (in the format yyyy-MM-dd)."""

    end_local_time: Optional[str] = FieldInfo(alias="endLocalTime", default=None)
    """A local time (in the format hh:mm:ss)."""

    part_two_datetime: Optional[_datetime.datetime] = FieldInfo(alias="partTwoDatetime", default=None)
    """The date-time of the part two performance, if there is one."""

    part_two_datetime_epoch: Optional[int] = FieldInfo(alias="partTwoDatetimeEpoch", default=None)
    """The epoch time representation of a date-time."""

    show: Optional[ShowtimeShow] = None
    """
    Show-level core data needed for analytics (including lower associations like
    Location and Account).
    """


class SupportedDeliveryMethod(BaseModel):
    method: Optional[DeliveryMethod] = None
    """How to pickup the tickets"""

    post_purchase_text: Optional[str] = FieldInfo(alias="postPurchaseText", default=None)

    pre_purchase_text: Optional[str] = FieldInfo(alias="prePurchaseText", default=None)

    price: Optional[CurrencyObject] = None


class AvailableTicketProtectionRewardsBenefit(TicketProtectionSummary):
    api_type: Optional[str] = FieldInfo(alias="_type", default=None)  # type: ignore

    available_uses: Optional[float] = FieldInfo(alias="availableUses", default=None)
    """Available uses of the ticket protection benefit"""

    remaining_uses_text: Optional[str] = FieldInfo(alias="remainingUsesText", default=None)
    """Formatted string including the remaining uses"""

    total_uses: Optional[float] = FieldInfo(alias="totalUses", default=None)
    """Total uses of the ticket protection benefit"""


class ConfigurableTextsAboutSeatsButton(BaseModel):
    api_type: str = FieldInfo(alias="_type")

    message: str
    """Main message to display on where my seats page"""

    title: str
    """Title for button and for modal"""

    seats_info: Optional[List[str]] = FieldInfo(alias="seatsInfo", default=None)
    """Array of seats info, that user more likely will get"""

    seats_info_title: Optional[str] = FieldInfo(alias="seatsInfoTitle", default=None)


class ConfigurableTexts(BaseModel):
    api_type: Optional[str] = FieldInfo(alias="_type", default=None)

    about_seats_button: Optional[ConfigurableTextsAboutSeatsButton] = FieldInfo(alias="aboutSeatsButton", default=None)
    """
    Contains information what seats user will likely to get, or at least some
    additional info about seats.
    """

    delivery_instructions: Optional[str] = FieldInfo(alias="deliveryInstructions", default=None)
    """Instructions how to pickup tickets"""

    delivery_instructions_for_mobile: Optional[str] = FieldInfo(alias="deliveryInstructionsForMobile", default=None)
    """Instructions how to pickup tickets"""

    optional_text: Optional[str] = FieldInfo(alias="optionalText", default=None)
    """Optional text for Final Order Review. Configurable in the CMS at the show level"""

    optional_title: Optional[str] = FieldInfo(alias="optionalTitle", default=None)
    """
    Optional title for Final Order Review, Configurable in the CMS at the show level
    """

    override_cancellation_policy_text: Optional[str] = FieldInfo(alias="overrideCancellationPolicyText", default=None)
    """
    Optional override for the default cancellation text. Configurable in the CMS at
    the show level
    """

    so_you_know_text: Optional[str] = FieldInfo(alias="soYouKnowText", default=None)
    """So you know text"""


class ReservedOfferHold(BaseModel):
    description: str
    """The description of the attached reserved offer"""

    display_name: str = FieldInfo(alias="displayName")
    """The display name of the attached reserved offer"""

    expiration_date_time: _datetime.datetime = FieldInfo(alias="expirationDateTime")
    """Datetime at which the offer hold will expire."""

    face_value: float = FieldInfo(alias="faceValue")
    """A monetary amount with 2 decimal places of precision. N.B.

    In some cases, this may be used to represent percentages (for fees, commissions,
    etc.), where `0.10` would represent 10%.
    """

    hold_id: int = FieldInfo(alias="holdId")
    """The HoldId for the offer hold"""

    includes_fees: bool = FieldInfo(alias="includesFees")
    """whether the price for the offer hold includes fees"""

    num_seats: int = FieldInfo(alias="numSeats")
    """the number of seats in the offer hold"""

    price: float
    """A monetary amount with 2 decimal places of precision. N.B.

    In some cases, this may be used to represent percentages (for fees, commissions,
    etc.), where `0.10` would represent 10%.
    """

    price_difference: float = FieldInfo(alias="priceDifference")
    """A monetary amount with 2 decimal places of precision. N.B.

    In some cases, this may be used to represent percentages (for fees, commissions,
    etc.), where `0.10` would represent 10%.
    """

    seats_info: SeatsInfo = FieldInfo(alias="seatsInfo")
    """
    Information to highlight the seats being held / purchased. This is DEPRECATED
    and should be replaced by the information in the `tickets` array, which includes
    section/row/seat details of each ticket, as well as pricing and barcode
    information.
    """

    service_fees: float = FieldInfo(alias="serviceFees")
    """A monetary amount with 2 decimal places of precision. N.B.

    In some cases, this may be used to represent percentages (for fees, commissions,
    etc.), where `0.10` would represent 10%.
    """

    fee_text_per_ticket: Optional[str] = FieldInfo(alias="feeTextPerTicket", default=None)
    """A display string to indicate fees, according to local requirements."""

    type: Optional[Literal["HOLD_UPGRADE", "HOLD_UPSELL", "HOLD_DISCOUNT", "PUSH_OFFER", "REWARDS_HOLD_UPGRADE"]] = None
    """The type of the attached reserved offer"""

    venue_area_ids: Optional[str] = FieldInfo(alias="venueAreaIds", default=None)
    """
    A comma separated list of venue area ids that should be highlighted for this
    hold
    """


class Hold(BaseModel):
    id: int
    """Numeric identifier for a resource"""

    api_type: str = FieldInfo(alias="_type")

    allocated_seat_id: int = FieldInfo(alias="allocatedSeatId")
    """Numeric identifier for a resource"""

    base_total: CurrencyObject = FieldInfo(alias="baseTotal")

    calculated_total: CurrencyObject = FieldInfo(alias="calculatedTotal")

    created_datetime: _datetime.datetime = FieldInfo(alias="createdDatetime")
    """Datetime at which this hold was created."""

    delivery_method: DeliveryMethod = FieldInfo(alias="deliveryMethod")
    """How to pickup the tickets"""

    delivery_method_id: int = FieldInfo(alias="deliveryMethodId")
    """Numeric identifier for a resource"""

    expiration_datetime: _datetime.datetime = FieldInfo(alias="expirationDatetime")
    """
    Datetime at which this hold expires -- after this point, any held inventory is
    released to the public.
    """

    hold_expiration_time: _datetime.datetime = FieldInfo(alias="holdExpirationTime")
    """The UTC date-time at which the hold expires."""

    hold_time_allowed_seconds: int = FieldInfo(alias="holdTimeAllowedSeconds")
    """The duration of the hold, in seconds."""

    is_eligible_for_quick_checkout: bool = FieldInfo(alias="isEligibleForQuickCheckout")
    """
    If true, the client can display a quick checkout button to the customer allowing
    them to bypass the TodayTix checkout screen using a payment app.
    """

    num_seats: int = FieldInfo(alias="numSeats")
    """Number of tickets held"""

    payment_option: Literal["IN_APP", "BOX_OFFICE"] = FieldInfo(alias="paymentOption")
    """How to pay for the tickets (in app or at the box office)"""

    post_hold_input_body: PostHoldInputBody = FieldInfo(alias="postHoldInputBody")

    price_items: List[PriceItem] = FieldInfo(alias="priceItems")

    provider_id: int = FieldInfo(alias="providerId")
    """Numeric identifier for a resource"""

    provider_name: str = FieldInfo(alias="providerName")
    """The name of the ticket provider."""

    provider_platform_enum: Literal[
        "AUDIENCE_VIEW", "ENTA", "MERLIN", "NLIVEN", "OUTBOX", "SPEKTRIX", "SRO4", "TESSITURA", "TODAYTIX"
    ] = FieldInfo(alias="providerPlatformEnum")
    """The name of the ticket provider platform."""

    psp_options: List[PspOption] = FieldInfo(alias="pspOptions")
    """
    An array of pspOptions to dictate to the client what psp to use, with a denoted
    "primary" PSP.
    """

    retailer_id: str = FieldInfo(alias="retailerId")
    """A retailer public facing Id (String). (pub_id on server side)"""

    rewards: EarnedRewardsSummary
    """
    Rewards summary that includes information pertaining to the availability and
    amount of the calculated credit.
    """

    seat_selection_type: Literal["BEST_AVAILABLE", "PYOS"] = FieldInfo(alias="seatSelectionType")
    """The available options for a customer when holding seats.

    The default option is BEST_AVAILABLE. For backwards compatibility, we allow null
    value for this enum, and the backend assumes the default value was used.
    """

    seats_info: SeatsInfo = FieldInfo(alias="seatsInfo")
    """
    Information to highlight the seats being held / purchased. This is DEPRECATED
    and should be replaced by the information in the `tickets` array, which includes
    section/row/seat details of each ticket, as well as pricing and barcode
    information.
    """

    section_description_metadata: str = FieldInfo(alias="sectionDescriptionMetadata")
    """this hold show's targeted section description metadata, if any"""

    show_datetime: _datetime.datetime = FieldInfo(alias="showDatetime")
    """Showtime datetime"""

    show_id: int = FieldInfo(alias="showId")
    """Numeric identifier for a resource"""

    showtime: Showtime
    """
    A simple showtime object used for analytics. Does not include availability data.
    """

    supported_delivery_methods: List[SupportedDeliveryMethod] = FieldInfo(alias="supportedDeliveryMethods")

    ticket_type: TicketType = FieldInfo(alias="ticketType")
    """Type of the tickets (Lottery, Rush and Regular tickets)"""

    total_amount_saved: CurrencyObject = FieldInfo(alias="totalAmountSaved")

    total_sales_tax_amount: CurrencyObject = FieldInfo(alias="totalSalesTaxAmount")

    accessibility_text: Optional[str] = FieldInfo(alias="accessibilityText", default=None)
    """Text explaining how customers can obtain handicap-accessible tickets."""

    add_ons: Optional[AddOns] = FieldInfo(alias="addOns", default=None)

    admission_type: Optional[AdmissionType] = FieldInfo(alias="admissionType", default=None)
    """
    The type of admission allowed for the Show. TIMED = regular theater performance,
    e.g. on date X at time Y. DATED = open-ended admission on a specific date, like
    a museum. OPEN = open-ended admission on any date, like a streamed performance.
    """

    available_ticket_protection: Optional[TicketProtectionSummary] = FieldInfo(
        alias="availableTicketProtection", default=None
    )
    """Only available for AllocatedSeat.type = PURCHASE"""

    available_ticket_protection_rewards_benefit: Optional[AvailableTicketProtectionRewardsBenefit] = FieldInfo(
        alias="availableTicketProtectionRewardsBenefit", default=None
    )
    """Only available for AllocatedSeat.type = PURCHASE"""

    braintree_client_token: Optional[str] = FieldInfo(alias="braintreeClientToken", default=None)
    """
    Braintree client token used by apps for configuring Braintree SDK Optional: only
    used when retailer is TodayTix.
    """

    configurable_texts: Optional[ConfigurableTexts] = FieldInfo(alias="configurableTexts", default=None)
    """All texts needed to complete hold and checkout api"""

    credits: Optional[CurrencyObject] = None

    customer_id: Optional[str] = FieldInfo(alias="customerId", default=None)
    """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.
    """

    has_promotion: Optional[bool] = FieldInfo(alias="hasPromotion", default=None)
    """Whether or not the tickets in this hold are part of a promotion."""

    is_potential_duplicate: Optional[bool] = FieldInfo(alias="isPotentialDuplicate", default=None)
    """
    Determines if a similar transaction (same show and customer) was done a specific
    number of hours ago.
    """

    part_two_show_datetime: Optional[_datetime.datetime] = FieldInfo(alias="partTwoShowDatetime", default=None)
    """
    If this is a 2-part show, the datetime of the part 2 performance. Otherwise,
    null.
    """

    payment_method: Optional[PaymentMethod] = FieldInfo(alias="paymentMethod", default=None)

    pdf: Optional[str] = None
    """A link points to an external resource. For images we using IMGX.

    To get the right size see link "https://docs.imgix.com/apis/url/size"
    """

    promotion: Optional[Promotion] = None

    reserved_offer_hold: Optional[ReservedOfferHold] = FieldInfo(alias="reservedOfferHold", default=None)

    show_end_datetime: Optional[_datetime.datetime] = FieldInfo(alias="showEndDatetime", default=None)
    """Showtime's end datetime"""

    ticket_protection_plan_id: Optional[float] = FieldInfo(alias="ticketProtectionPlanId", default=None)
    """Non-null if holdTransaction is linked to a valid ticket protection plan."""

    tickets: Optional[List[Ticket]] = None

    tickets_type: Optional[TicketType] = FieldInfo(alias="ticketsType", default=None)
    """Type of the tickets (Lottery, Rush and Regular tickets)"""

    venue_area_ids: Optional[str] = FieldInfo(alias="venueAreaIds", default=None)
    """
    A comma separated list of venue area ids that should be highlighted for this
    hold
    """

    voucher: Optional[Voucher] = None

    voucher_application_message: Optional[str] = FieldInfo(alias="voucherApplicationMessage", default=None)
    """Used in the creation of fallback vouchers in CMS"""

    voucher_code: Optional[str] = FieldInfo(alias="voucherCode", default=None)

    voucher_discount: Optional[CurrencyObject] = FieldInfo(alias="voucherDiscount", default=None)
