"""
DBIS IRU Types
"""

from dataclasses import dataclass
from typing import Optional
from datetime import datetime


@dataclass
class IRUOffering:
    """IRU Offering"""
    id: str
    offering_id: str
    name: str
    description: Optional[str] = None
    capacity_tier: int = 3
    institutional_type: str = "CommercialBank"
    base_price: Optional[float] = None
    currency: str = "USD"

    def dict(self):
        """Convert to dictionary"""
        return {
            'id': self.id,
            'offeringId': self.offering_id,
            'name': self.name,
            'description': self.description,
            'capacityTier': self.capacity_tier,
            'institutionalType': self.institutional_type,
            'basePrice': self.base_price,
            'currency': self.currency,
        }


@dataclass
class IRUInquiry:
    """IRU Inquiry"""
    offering_id: str
    organization_name: str
    institutional_type: str
    jurisdiction: str
    contact_email: str
    contact_phone: Optional[str] = None
    contact_name: str = ""
    estimated_volume: Optional[str] = None
    expected_go_live: Optional[datetime] = None

    def dict(self):
        """Convert to dictionary"""
        data = {
            'offeringId': self.offering_id,
            'organizationName': self.organization_name,
            'institutionalType': self.institutional_type,
            'jurisdiction': self.jurisdiction,
            'contactEmail': self.contact_email,
            'contactName': self.contact_name,
        }
        
        if self.contact_phone:
            data['contactPhone'] = self.contact_phone
        if self.estimated_volume:
            data['estimatedVolume'] = self.estimated_volume
        if self.expected_go_live:
            data['expectedGoLive'] = self.expected_go_live.isoformat()
        
        return data


@dataclass
class IRUSubscription:
    """IRU Subscription"""
    subscription_id: str
    offering_id: str
    subscription_status: str
    activation_date: Optional[datetime] = None

    def dict(self):
        """Convert to dictionary"""
        data = {
            'subscriptionId': self.subscription_id,
            'offeringId': self.offering_id,
            'subscriptionStatus': self.subscription_status,
        }
        
        if self.activation_date:
            data['activationDate'] = self.activation_date.isoformat()
        
        return data
