"""Marketing schemas."""
from __future__ import annotations


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class MarketingCampaignRefCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID | None = None
    branch_id: UUID | None = None
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    external_campaign_ref: str | None = None
    channel: str | None = None
    status: LifecycleStatus = LifecycleStatus.DRAFT
    config: dict | None = None


class MarketingCampaignRefRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID | None
    branch_id: UUID | None
    code: str
    name: str
    external_campaign_ref: str | None
    channel: str | None
    status: LifecycleStatus
    config: dict | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class LoyaltyIntegrationConfigCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID | None = None
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    external_program_ref: str | None = None
    earn_rules: dict | None = None
    status: LifecycleStatus = LifecycleStatus.ACTIVE


class LoyaltyIntegrationConfigRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID | None
    code: str
    name: str
    external_program_ref: str | None
    earn_rules: dict | None
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class CommunicationIntegrationConfigCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID | None = None
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    template_mappings: dict | None = None
    status: LifecycleStatus = LifecycleStatus.ACTIVE


class CommunicationIntegrationConfigRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID | None
    code: str
    name: str
    template_mappings: dict | None
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from app.models.types import IntegrationDispatchStatus


class IntegrationDispatchCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID | None = None
    integration_kind: str = Field(max_length=50)
    config_id: UUID | None = None
    event_type: str = Field(max_length=100)
    payload_ref: str | None = None


class IntegrationDispatchRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID | None
    integration_kind: str
    config_id: UUID | None
    event_type: str
    payload_ref: str | None
    status: IntegrationDispatchStatus
    response_json: dict | None
    notes: str | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime
