# generated by datamodel-codegen:
#   filename:  pricing_options/cpv_option.json
#   timestamp: 2025-11-22T15:23:24+00:00

from __future__ import annotations

from typing import Annotated, Literal

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field, RootModel


class ViewThreshold(RootModel[float]):
    root: Annotated[
        float,
        Field(
            description='Percentage completion threshold for CPV pricing (0.0 to 1.0, e.g., 0.5 = 50% completion)',
            ge=0.0,
            le=1.0,
        ),
    ]


class ViewThreshold1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    duration_seconds: Annotated[
        int,
        Field(
            description="Seconds of viewing required (e.g., 30 for YouTube-style '30 seconds = view')",
            ge=1,
        ),
    ]


class Parameters(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    view_threshold: ViewThreshold | ViewThreshold1


class CpvPricingOption(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    currency: Annotated[
        str,
        Field(
            description='ISO 4217 currency code',
            examples=['USD', 'EUR', 'GBP', 'JPY'],
            pattern='^[A-Z]{3}$',
        ),
    ]
    is_fixed: Annotated[
        Literal[True],
        Field(description='Whether this is a fixed rate (true) or auction-based (false)'),
    ]
    min_spend_per_package: Annotated[
        float | None,
        Field(
            description='Minimum spend requirement per package using this pricing option, in the specified currency',
            ge=0.0,
        ),
    ] = None
    parameters: Annotated[
        Parameters, Field(description='CPV-specific parameters defining the view threshold')
    ]
    pricing_model: Annotated[Literal['cpv'], Field(description='Cost per view at threshold')]
    pricing_option_id: Annotated[
        str,
        Field(
            description="Unique identifier for this pricing option within the product (e.g., 'cpv_usd_50pct')"
        ),
    ]
    rate: Annotated[float, Field(description='Fixed CPV rate (cost per view)', ge=0.0)]
