"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from polar_sdk.types import BaseModel
from typing import Dict, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


SubscriptionCreateExternalCustomerMetadataTypedDict = TypeAliasType(
    "SubscriptionCreateExternalCustomerMetadataTypedDict", Union[str, int, float, bool]
)


SubscriptionCreateExternalCustomerMetadata = TypeAliasType(
    "SubscriptionCreateExternalCustomerMetadata", Union[str, int, float, bool]
)


class SubscriptionCreateExternalCustomerTypedDict(TypedDict):
    r"""Create a subscription for an existing customer identified by an external ID."""

    product_id: str
    r"""The ID of the recurring product to subscribe to. Must be a free product, otherwise the customer should go through a checkout flow."""
    external_customer_id: str
    r"""The ID of the customer in your system to create the subscription for. It must already exist in Polar."""
    metadata: NotRequired[
        Dict[str, SubscriptionCreateExternalCustomerMetadataTypedDict]
    ]
    r"""Key-value object allowing you to store additional information.

    The key must be a string with a maximum length of **40 characters**.
    The value must be either:

    * A string with a maximum length of **500 characters**
    * An integer
    * A floating-point number
    * A boolean

    You can store up to **50 key-value pairs**.
    """


class SubscriptionCreateExternalCustomer(BaseModel):
    r"""Create a subscription for an existing customer identified by an external ID."""

    product_id: str
    r"""The ID of the recurring product to subscribe to. Must be a free product, otherwise the customer should go through a checkout flow."""

    external_customer_id: str
    r"""The ID of the customer in your system to create the subscription for. It must already exist in Polar."""

    metadata: Optional[Dict[str, SubscriptionCreateExternalCustomerMetadata]] = None
    r"""Key-value object allowing you to store additional information.

    The key must be a string with a maximum length of **40 characters**.
    The value must be either:

    * A string with a maximum length of **500 characters**
    * An integer
    * A floating-point number
    * A boolean

    You can store up to **50 key-value pairs**.
    """
