from dataclasses import dataclass, field
from typing import Any, Protocol

from pydantic import BaseModel


@dataclass
class EndpointMetadata:
    http_method: str
    path: str
    return_type: type[BaseModel]


class EndpointFunction(Protocol):
    _accord_endpoint: EndpointMetadata

    def __call__(self, *args, **kwargs): ...


@dataclass
class ParsedInteraction:
    description: str = ""
    request: dict[str, str] = field(default_factory=dict)
    response: dict[str, Any] = field(default_factory=dict)
    matching_rules: dict[str, dict[str, str]] = field(default_factory=dict)


@dataclass
class ParsedContract:
    consumer: str = ""
    producer: str = ""
    interactions: list[ParsedInteraction] = field(default_factory=list)
