# generated by datamodel-codegen:
#   filename:  sponsored_intelligence/si_identity.json
#   timestamp: 2026-02-23T01:56:40+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import AnyUrl, AwareDatetime, ConfigDict, EmailStr, Field


class ConsentScopeEnum(Enum):
    name = 'name'
    email = 'email'
    shipping_address = 'shipping_address'
    phone = 'phone'
    locale = 'locale'


class PrivacyPolicyAcknowledged(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    brand_policy_url: Annotated[
        AnyUrl | None, Field(description="URL to brand's privacy policy")
    ] = None
    brand_policy_version: Annotated[
        str | None, Field(description='Version of policy acknowledged')
    ] = None


class ShippingAddress(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    city: str | None = None
    country: str | None = None
    postal_code: str | None = None
    state: str | None = None
    street: str | None = None


class User(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    email: Annotated[EmailStr | None, Field(description="User's email address")] = None
    locale: Annotated[str | None, Field(description="User's locale (e.g., en-US)")] = None
    name: Annotated[str | None, Field(description="User's display name")] = None
    phone: Annotated[str | None, Field(description="User's phone number")] = None
    shipping_address: Annotated[
        ShippingAddress | None, Field(description="User's shipping address for accurate pricing")
    ] = None


class SiIdentity(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    anonymous_session_id: Annotated[
        str | None,
        Field(description='Session ID for anonymous users (when consent_granted is false)'),
    ] = None
    consent_granted: Annotated[bool, Field(description='Whether user consented to share identity')]
    consent_scope: Annotated[
        list[ConsentScopeEnum] | None, Field(description='What data was consented to share')
    ] = None
    consent_timestamp: Annotated[
        AwareDatetime | None, Field(description='When consent was granted (ISO 8601)')
    ] = None
    privacy_policy_acknowledged: Annotated[
        PrivacyPolicyAcknowledged | None, Field(description='Brand privacy policy acknowledgment')
    ] = None
    user: Annotated[
        User | None, Field(description='User data (only present if consent_granted is true)')
    ] = None
