# generated by datamodel-codegen:
#   filename:  core/account.json
#   timestamp: 2026-02-27T02:10:10+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, Field

from . import brand_ref
from . import ext as ext_1


class AccountScope(Enum):
    operator = 'operator'
    brand = 'brand'
    operator_brand = 'operator_brand'
    agent = 'agent'


class Billing(Enum):
    operator = 'operator'
    agent = 'agent'


class CreditLimit(AdCPBaseModel):
    amount: Annotated[float, Field(ge=0.0)]
    currency: Annotated[str, Field(pattern='^[A-Z]{3}$')]


class Setup(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    expires_at: Annotated[
        AwareDatetime | None, Field(description='When this setup link expires.')
    ] = None
    message: Annotated[str, Field(description="Human-readable description of what's needed.")]
    url: Annotated[
        AnyUrl | None,
        Field(
            description='URL where the human can complete the required action (credit application, legal agreement, add funds).'
        ),
    ] = None


class Status(Enum):
    active = 'active'
    pending_approval = 'pending_approval'
    rejected = 'rejected'
    payment_required = 'payment_required'
    suspended = 'suspended'
    closed = 'closed'


class Account(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    account_id: Annotated[str, Field(description='Unique identifier for this account')]
    account_scope: Annotated[
        AccountScope | None,
        Field(
            description="How the seller scoped this account. operator: shared across all brands for this operator. brand: shared across all operators for this brand. operator_brand: dedicated to a specific operator+brand combination. agent: the agent's default account with no brand or operator association."
        ),
    ] = None
    advertiser: Annotated[
        str | None, Field(description='The advertiser whose rates apply to this account')
    ] = None
    billing: Annotated[
        Billing | None,
        Field(
            description='Who is invoiced on this account. operator: seller invoices the operator (agency or brand buying direct). agent: agent consolidates billing.'
        ),
    ] = None
    billing_proxy: Annotated[
        str | None,
        Field(
            description='Optional intermediary who receives invoices on behalf of the advertiser (e.g., agency)'
        ),
    ] = None
    brand: Annotated[
        brand_ref.BrandReference | None,
        Field(description='Brand reference identifying the advertiser'),
    ] = None
    credit_limit: Annotated[
        CreditLimit | None, Field(description='Maximum outstanding balance allowed')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    name: Annotated[
        str, Field(description="Human-readable account name (e.g., 'Acme', 'Acme c/o Pinnacle')")
    ]
    operator: Annotated[
        str | None,
        Field(
            description="Domain of the entity operating this account. When the brand operates directly, this is the brand's domain.",
            pattern='^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$',
        ),
    ] = None
    payment_terms: Annotated[
        str | None, Field(description="Payment terms (e.g., 'net_30', 'prepay')")
    ] = None
    rate_card: Annotated[
        str | None, Field(description='Identifier for the rate card applied to this account')
    ] = None
    sandbox: Annotated[
        bool | None,
        Field(
            description='When true, this is a sandbox account. All requests using this account_id are treated as sandbox — no real platform calls, no real spend.'
        ),
    ] = None
    setup: Annotated[
        Setup | None,
        Field(
            description="Present when status is 'pending_approval'. Contains next steps for completing account activation."
        ),
    ] = None
    status: Annotated[
        Status,
        Field(
            description='Account status. pending_approval: seller reviewing (credit, contracts). rejected: seller declined the account request. payment_required: credit limit reached or funds depleted. suspended: was active, now paused. closed: was active, now terminated.'
        ),
    ]
