# generated by datamodel-codegen:
#   filename:  provide-performance-feedback-request.json
#   timestamp: 2025-11-15T22:03:55+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated, Any

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


class FeedbackSource(Enum):
    buyer_attribution = "buyer_attribution"
    third_party_measurement = "third_party_measurement"
    platform_analytics = "platform_analytics"
    verification_partner = "verification_partner"


class MeasurementPeriod(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    end: Annotated[
        AwareDatetime, Field(description="ISO 8601 end timestamp for measurement period")
    ]
    start: Annotated[
        AwareDatetime, Field(description="ISO 8601 start timestamp for measurement period")
    ]


class MetricType(Enum):
    overall_performance = "overall_performance"
    conversion_rate = "conversion_rate"
    brand_lift = "brand_lift"
    click_through_rate = "click_through_rate"
    completion_rate = "completion_rate"
    viewability = "viewability"
    brand_safety = "brand_safety"
    cost_efficiency = "cost_efficiency"


class ProvidePerformanceFeedbackRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    context: Annotated[
        dict[str, Any] | None,
        Field(
            description="Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata."
        ),
    ] = None
    creative_id: Annotated[
        str | None,
        Field(
            description="Specific creative asset (if feedback is creative-specific)", min_length=1
        ),
    ] = None
    feedback_source: Annotated[
        FeedbackSource | None, Field(description="Source of the performance data")
    ] = FeedbackSource.buyer_attribution
    measurement_period: Annotated[
        MeasurementPeriod, Field(description="Time period for performance measurement")
    ]
    media_buy_id: Annotated[
        str, Field(description="Publisher's media buy identifier", min_length=1)
    ]
    metric_type: Annotated[
        MetricType | None, Field(description="The business metric being measured")
    ] = MetricType.overall_performance
    package_id: Annotated[
        str | None,
        Field(
            description="Specific package within the media buy (if feedback is package-specific)",
            min_length=1,
        ),
    ] = None
    performance_index: Annotated[
        float,
        Field(
            description="Normalized performance score (0.0 = no value, 1.0 = expected, >1.0 = above expected)",
            ge=0.0,
        ),
    ]
