"""
Alternatives API namespace.

AUTO-GENERATED by scripts/generate_sdk.py - DO NOT EDIT MANUALLY!
Regenerate with: python scripts/generate_sdk.py --category alternatives
"""
from __future__ import annotations

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class AlternativesAPI(BaseAPI):
    """Alternatives namespace: cash_flow, create, delete, get, list, nav_update, performance, summary, update."""

    def cash_flow(
        self,
        *,
        asset_id: str,
        date: str,
        flow_type: str,
        amount: float,
        description: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Add cash flow

        Args:
        asset_id: Asset ID
        date: Cash flow date
        flow_type: capital_call|distribution|fee
        amount: Amount
        description: Description"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        params["date"] = date
        params["flow_type"] = flow_type
        params["amount"] = amount
        if description is not None:
            params["description"] = description
        return self._call("alternatives.cash_flow", params=params, options=options, context=context)

    def create(
        self,
        *,
        name: str,
        asset_type: str,
        fund_name: Optional[str] = None,
        commitment: Optional[float] = None,
        currency: Optional[str] = "EUR",
        vintage_year: Optional[int] = None,
        manager: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alternative asset

        Args:
        name: Asset name
        asset_type: private_equity|real_estate|hedge_fund|private_credit|other
        fund_name: Fund name
        commitment: Total commitment
        currency: Currency
        vintage_year: Vintage year
        manager: Manager name"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["asset_type"] = asset_type
        if fund_name is not None:
            params["fund_name"] = fund_name
        if commitment is not None:
            params["commitment"] = commitment
        if currency is not None:
            params["currency"] = currency
        if vintage_year is not None:
            params["vintage_year"] = vintage_year
        if manager is not None:
            params["manager"] = manager
        return self._call("alternatives.create", params=params, options=options, context=context)

    def delete(
        self,
        *,
        asset_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete alternative asset

        Args:
        asset_id: Asset ID"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        return self._call("alternatives.delete", params=params, options=options, context=context)

    def get(
        self,
        *,
        asset_id: str,
        include_cash_flows: Optional[bool] = True,
        include_nav_history: Optional[bool] = True,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get alternative asset

        Args:
        asset_id: Asset ID
        include_cash_flows: Include cash flows
        include_nav_history: Include NAV history"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if include_cash_flows is not None:
            params["include_cash_flows"] = include_cash_flows
        if include_nav_history is not None:
            params["include_nav_history"] = include_nav_history
        return self._call("alternatives.get", params=params, options=options, context=context)

    def list(
        self,
        *,
        asset_type: Optional[str] = None,
        status: Optional[str] = None,
        search: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List alternative assets

        Args:
        asset_type: Filter by type
        status: Filter by status
        search: Search in name
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if asset_type is not None:
            params["asset_type"] = asset_type
        if status is not None:
            params["status"] = status
        if search is not None:
            params["search"] = search
        if limit is not None:
            params["limit"] = limit
        return self._call("alternatives.list", params=params, options=options, context=context, response_format=response_format)

    def nav_update(
        self,
        *,
        asset_id: str,
        date: str,
        nav: float,
        source: Optional[str] = "manual",
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Add NAV update

        Args:
        asset_id: Asset ID
        date: Valuation date
        nav: NAV value
        source: Source"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        params["date"] = date
        params["nav"] = nav
        if source is not None:
            params["source"] = source
        return self._call("alternatives.nav_update", params=params, options=options, context=context)

    def performance(
        self,
        *,
        asset_id: str,
        as_of_date: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Calculate performance

        Calculate IRR, TVPI, DPI, etc.

        Args:
        asset_id: Asset ID
        as_of_date: As of date"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if as_of_date is not None:
            params["as_of_date"] = as_of_date
        return self._call("alternatives.performance", params=params, options=options, context=context)

    def summary(
        self,
        *,
        asset_type: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Portfolio summary

        Aggregated summary of all alternatives.

        Args:
        asset_type: Filter by type"""
        params: Dict[str, Any] = {}
        if asset_type is not None:
            params["asset_type"] = asset_type
        return self._call("alternatives.summary", params=params, options=options, context=context)

    def update(
        self,
        *,
        asset_id: str,
        name: Optional[str] = None,
        fund_name: Optional[str] = None,
        status: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update alternative asset

        Args:
        asset_id: Asset ID
        name: New name
        fund_name: New fund name
        status: New status"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if name is not None:
            params["name"] = name
        if fund_name is not None:
            params["fund_name"] = fund_name
        if status is not None:
            params["status"] = status
        return self._call("alternatives.update", params=params, options=options, context=context)



class AsyncAlternativesAPI(AsyncBaseAPI):
    """Alternatives namespace: cash_flow, create, delete, get, list, nav_update, performance, summary, update."""

    async def cash_flow(
        self,
        *,
        asset_id: str,
        date: str,
        flow_type: str,
        amount: float,
        description: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Add cash flow

        Args:
        asset_id: Asset ID
        date: Cash flow date
        flow_type: capital_call|distribution|fee
        amount: Amount
        description: Description"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        params["date"] = date
        params["flow_type"] = flow_type
        params["amount"] = amount
        if description is not None:
            params["description"] = description
        return await self._call("alternatives.cash_flow", params=params, options=options, context=context)

    async def create(
        self,
        *,
        name: str,
        asset_type: str,
        fund_name: Optional[str] = None,
        commitment: Optional[float] = None,
        currency: Optional[str] = "EUR",
        vintage_year: Optional[int] = None,
        manager: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create alternative asset

        Args:
        name: Asset name
        asset_type: private_equity|real_estate|hedge_fund|private_credit|other
        fund_name: Fund name
        commitment: Total commitment
        currency: Currency
        vintage_year: Vintage year
        manager: Manager name"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["asset_type"] = asset_type
        if fund_name is not None:
            params["fund_name"] = fund_name
        if commitment is not None:
            params["commitment"] = commitment
        if currency is not None:
            params["currency"] = currency
        if vintage_year is not None:
            params["vintage_year"] = vintage_year
        if manager is not None:
            params["manager"] = manager
        return await self._call("alternatives.create", params=params, options=options, context=context)

    async def delete(
        self,
        *,
        asset_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete alternative asset

        Args:
        asset_id: Asset ID"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        return await self._call("alternatives.delete", params=params, options=options, context=context)

    async def get(
        self,
        *,
        asset_id: str,
        include_cash_flows: Optional[bool] = True,
        include_nav_history: Optional[bool] = True,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get alternative asset

        Args:
        asset_id: Asset ID
        include_cash_flows: Include cash flows
        include_nav_history: Include NAV history"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if include_cash_flows is not None:
            params["include_cash_flows"] = include_cash_flows
        if include_nav_history is not None:
            params["include_nav_history"] = include_nav_history
        return await self._call("alternatives.get", params=params, options=options, context=context)

    async def list(
        self,
        *,
        asset_type: Optional[str] = None,
        status: Optional[str] = None,
        search: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List alternative assets

        Args:
        asset_type: Filter by type
        status: Filter by status
        search: Search in name
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if asset_type is not None:
            params["asset_type"] = asset_type
        if status is not None:
            params["status"] = status
        if search is not None:
            params["search"] = search
        if limit is not None:
            params["limit"] = limit
        return await self._call("alternatives.list", params=params, options=options, context=context, response_format=response_format)

    async def nav_update(
        self,
        *,
        asset_id: str,
        date: str,
        nav: float,
        source: Optional[str] = "manual",
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Add NAV update

        Args:
        asset_id: Asset ID
        date: Valuation date
        nav: NAV value
        source: Source"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        params["date"] = date
        params["nav"] = nav
        if source is not None:
            params["source"] = source
        return await self._call("alternatives.nav_update", params=params, options=options, context=context)

    async def performance(
        self,
        *,
        asset_id: str,
        as_of_date: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Calculate performance

        Calculate IRR, TVPI, DPI, etc.

        Args:
        asset_id: Asset ID
        as_of_date: As of date"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if as_of_date is not None:
            params["as_of_date"] = as_of_date
        return await self._call("alternatives.performance", params=params, options=options, context=context)

    async def summary(
        self,
        *,
        asset_type: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Portfolio summary

        Aggregated summary of all alternatives.

        Args:
        asset_type: Filter by type"""
        params: Dict[str, Any] = {}
        if asset_type is not None:
            params["asset_type"] = asset_type
        return await self._call("alternatives.summary", params=params, options=options, context=context)

    async def update(
        self,
        *,
        asset_id: str,
        name: Optional[str] = None,
        fund_name: Optional[str] = None,
        status: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update alternative asset

        Args:
        asset_id: Asset ID
        name: New name
        fund_name: New fund name
        status: New status"""
        params: Dict[str, Any] = {}
        params["asset_id"] = asset_id
        if name is not None:
            params["name"] = name
        if fund_name is not None:
            params["fund_name"] = fund_name
        if status is not None:
            params["status"] = status
        return await self._call("alternatives.update", params=params, options=options, context=context)


