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

from __future__ import annotations
from dub.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from enum import Enum
import pydantic
from pydantic import model_serializer
from typing import List
from typing_extensions import Annotated, NotRequired, TypedDict


class PartnerApplicationSubmittedEventEvent(str, Enum):
    PARTNER_APPLICATION_SUBMITTED = "partner.application_submitted"


class PartnerApplicationSubmittedEventStatus(str, Enum):
    r"""The status of the partner's enrollment in the program."""

    PENDING = "pending"
    APPROVED = "approved"
    REJECTED = "rejected"
    INVITED = "invited"
    DECLINED = "declined"
    DEACTIVATED = "deactivated"
    BANNED = "banned"
    ARCHIVED = "archived"


class PartnerApplicationSubmittedEventPartnerTypedDict(TypedDict):
    id: str
    r"""The partner's unique ID on Dub."""
    name: str
    r"""The partner's full legal name."""
    company_name: Nullable[str]
    r"""If the partner profile type is a company, this is the partner's legal company name."""
    email: Nullable[str]
    r"""The partner's email address. Should be a unique value across Dub."""
    image: Nullable[str]
    r"""The partner's avatar image."""
    country: Nullable[str]
    r"""The partner's country (required for tax purposes)."""
    status: PartnerApplicationSubmittedEventStatus
    r"""The status of the partner's enrollment in the program."""
    description: NotRequired[Nullable[str]]
    r"""A brief description of the partner and their background."""
    group_id: NotRequired[Nullable[str]]
    r"""The partner's group ID on Dub."""
    website: NotRequired[Nullable[str]]
    r"""The partner's website URL (including the https protocol)."""
    youtube: NotRequired[Nullable[str]]
    r"""The partner's YouTube channel username (e.g. `johndoe`)."""
    twitter: NotRequired[Nullable[str]]
    r"""The partner's Twitter username (e.g. `johndoe`)."""
    linkedin: NotRequired[Nullable[str]]
    r"""The partner's LinkedIn username (e.g. `johndoe`)."""
    instagram: NotRequired[Nullable[str]]
    r"""The partner's Instagram username (e.g. `johndoe`)."""
    tiktok: NotRequired[Nullable[str]]
    r"""The partner's TikTok username (e.g. `johndoe`)."""


class PartnerApplicationSubmittedEventPartner(BaseModel):
    id: str
    r"""The partner's unique ID on Dub."""

    name: str
    r"""The partner's full legal name."""

    company_name: Annotated[Nullable[str], pydantic.Field(alias="companyName")]
    r"""If the partner profile type is a company, this is the partner's legal company name."""

    email: Nullable[str]
    r"""The partner's email address. Should be a unique value across Dub."""

    image: Nullable[str]
    r"""The partner's avatar image."""

    country: Nullable[str]
    r"""The partner's country (required for tax purposes)."""

    status: PartnerApplicationSubmittedEventStatus
    r"""The status of the partner's enrollment in the program."""

    description: OptionalNullable[str] = UNSET
    r"""A brief description of the partner and their background."""

    group_id: Annotated[OptionalNullable[str], pydantic.Field(alias="groupId")] = UNSET
    r"""The partner's group ID on Dub."""

    website: OptionalNullable[str] = UNSET
    r"""The partner's website URL (including the https protocol)."""

    youtube: OptionalNullable[str] = UNSET
    r"""The partner's YouTube channel username (e.g. `johndoe`)."""

    twitter: OptionalNullable[str] = UNSET
    r"""The partner's Twitter username (e.g. `johndoe`)."""

    linkedin: OptionalNullable[str] = UNSET
    r"""The partner's LinkedIn username (e.g. `johndoe`)."""

    instagram: OptionalNullable[str] = UNSET
    r"""The partner's Instagram username (e.g. `johndoe`)."""

    tiktok: OptionalNullable[str] = UNSET
    r"""The partner's TikTok username (e.g. `johndoe`)."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "description",
                "groupId",
                "website",
                "youtube",
                "twitter",
                "linkedin",
                "instagram",
                "tiktok",
            ]
        )
        nullable_fields = set(
            [
                "companyName",
                "email",
                "image",
                "description",
                "country",
                "groupId",
                "website",
                "youtube",
                "twitter",
                "linkedin",
                "instagram",
                "tiktok",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class ApplicationFormDataTypedDict(TypedDict):
    label: str
    value: Nullable[str]


class ApplicationFormData(BaseModel):
    label: str

    value: Nullable[str]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                m[k] = val

        return m


class PartnerApplicationSubmittedEventDataTypedDict(TypedDict):
    id: str
    created_at: str
    partner: PartnerApplicationSubmittedEventPartnerTypedDict
    application_form_data: Nullable[List[ApplicationFormDataTypedDict]]


class PartnerApplicationSubmittedEventData(BaseModel):
    id: str

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]

    partner: PartnerApplicationSubmittedEventPartner

    application_form_data: Annotated[
        Nullable[List[ApplicationFormData]], pydantic.Field(alias="applicationFormData")
    ]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                m[k] = val

        return m


class PartnerApplicationSubmittedEventTypedDict(TypedDict):
    r"""Triggered when a partner submits an application to join a program."""

    id: str
    event: PartnerApplicationSubmittedEventEvent
    created_at: str
    data: PartnerApplicationSubmittedEventDataTypedDict


class PartnerApplicationSubmittedEvent(BaseModel):
    r"""Triggered when a partner submits an application to join a program."""

    id: str

    event: PartnerApplicationSubmittedEventEvent

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]

    data: PartnerApplicationSubmittedEventData
