"""Billing domain - Protocols for Stripe client."""
from __future__ import annotations
from typing import Optional, Protocol


class StripeClient(Protocol):
    async def create_customer(self, email: str, workspace_name: str) -> str: ...
    async def create_subscription_checkout(
        self,
        customer_id: str,
        price_id: str,
        success_url: str,
        cancel_url: str,
        metadata: Optional[dict] = None,
        idempotency_key: Optional[str] = None,
    ) -> tuple[str, str]: ...
    async def create_payment_checkout(
        self,
        customer_id: str,
        price_id: str,
        success_url: str,
        cancel_url: str,
        metadata: Optional[dict] = None,
        idempotency_key: Optional[str] = None,
    ) -> tuple[str, str]: ...
    async def create_customer_portal(self, customer_id: str) -> str: ...
    async def create_subscription_update_portal(
        self, customer_id: str, subscription_id: str, price_id: str, return_url: str
    ) -> str: ...
    async def get_subscription(self, subscription_id: str) -> dict: ...
    def get_checkout_session(self, session_id: str) -> dict: ...
    async def list_invoices(self, customer_id: str) -> list[dict]: ...
    async def report_usage(self, event_name: str, stripe_customer_id: str, quantity: int, timestamp: Optional[int] = None) -> None: ...
    async def create_invoice_item(
        self,
        stripe_customer_id: str,
        *,
        amount_minor: int,
        currency: str,
        description: str,
        idempotency_key: Optional[str] = None,
    ) -> str: ...
    def verify_webhook_signature(self, payload: bytes, sig_header: str) -> dict: ...


class StripeSyncCapable(Protocol):
    """Extended Stripe client for sync services (product/price creation)."""

    async def create_product(
        self, name: str, description: Optional[str] = None, metadata: Optional[dict] = None
    ) -> dict: ...

    async def create_price(
        self,
        product_id: str,
        unit_amount: int,
        currency: str = "usd",
        interval: str = "month",
        nickname: Optional[str] = None,
    ) -> dict: ...

    async def create_meter(
        self,
        event_name: str,
        display_name: str,
    ) -> dict: ...

    async def create_metered_price(
        self,
        product_id: str,
        meter_id: str,
        currency: str = "usd",
        unit_amount: int = 0,
        nickname: Optional[str] = None,
    ) -> dict: ...

    async def create_one_time_price(
        self,
        product_id: str,
        unit_amount: int,
        currency: str = "usd",
        nickname: Optional[str] = None,
    ) -> dict: ...

    async def retrieve_price(self, price_id: str) -> Optional[dict]: ...

    async def update_product(self, product_id: str, **kwargs) -> dict: ...

    async def deactivate_price(self, price_id: str) -> None: ...
