# generated by datamodel-codegen:
#   filename:  core/optimization_goal.json
#   timestamp: 2026-02-12T02:11:19+00:00

from __future__ import annotations

from typing import Annotated

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

from ..enums import event_type as event_type_1


class AttributionWindow(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    click_through: Annotated[
        str, Field(description="Click-through attribution window (e.g. '7d', '28d', '30d')")
    ]
    view_through: Annotated[
        str | None, Field(description="View-through attribution window (e.g. '1d', '7d')")
    ] = None


class OptimizationGoal(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    attribution_window: Annotated[
        AttributionWindow | None,
        Field(
            description="Attribution window for this optimization goal. Values must match an option declared in the seller's conversion_tracking.attribution_windows capability. When omitted, the seller uses their default window."
        ),
    ] = None
    event_source_id: Annotated[
        str,
        Field(
            description='Event source to optimize against (must be configured on this account via sync_event_sources)'
        ),
    ]
    event_type: Annotated[
        event_type_1.EventType,
        Field(description='Event type to optimize for (e.g. purchase, lead)'),
    ]
    target_cpa: Annotated[
        float | None,
        Field(
            description='Target cost per acquisition in the buy currency. Mutually exclusive with target_roas.',
            gt=0.0,
        ),
    ] = None
    target_roas: Annotated[
        float | None,
        Field(
            description='Target return on ad spend (e.g. 4.0 = $4 conversion value per $1 spent). Mutually exclusive with target_cpa.',
            gt=0.0,
        ),
    ] = None
