"""
Billing API namespace.

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

from typing import Any, Dict, List, Optional

from ._base import AsyncBaseAPI, BaseAPI


class BillingAPI(BaseAPI):
    """Billing namespace: aggregate, calculate, record_create, record_list, schedule_create, schedule_delete, schedule_get, schedule_list, schedule_update, simulate."""

    def aggregate(
        self,
        *,
        client_id: str,
        year: Optional[int] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Aggregate fees

        Aggregate fees for a client.

        Args:
        client_id: Client ID
        year: Filter by year"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        if year is not None:
            params["year"] = year
        return self._call("billing.aggregate", params=params, options=options, context=context, response_format=response_format)

    def calculate(
        self,
        *,
        fee_schedule: Optional[Dict[str, Any]] = None,
        aum: Optional[float] = None,
        portfolio_return: Optional[float] = None,
        benchmark_return: Optional[float] = None,
        high_water_mark: Optional[float] = None,
        period_start: Optional[str] = None,
        period_end: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Calculate fee

        Calculate fee based on schedule.

        Args:
        fee_schedule: Fee schedule (inline dict or ID/name string)
        aum: Assets under management
        portfolio_return: Portfolio return
        benchmark_return: Benchmark return
        high_water_mark: High water mark
        period_start: Period start date
        period_end: Period end date"""
        params: Dict[str, Any] = {}
        if fee_schedule is not None:
            params["fee_schedule"] = fee_schedule
        if aum is not None:
            params["aum"] = aum
        if portfolio_return is not None:
            params["portfolio_return"] = portfolio_return
        if benchmark_return is not None:
            params["benchmark_return"] = benchmark_return
        if high_water_mark is not None:
            params["high_water_mark"] = high_water_mark
        if period_start is not None:
            params["period_start"] = period_start
        if period_end is not None:
            params["period_end"] = period_end
        return self._call("billing.calculate", params=params, options=options, context=context)

    def record_create(
        self,
        *,
        client_id: str,
        fee_schedule_id: str,
        period_start: str,
        period_end: str,
        aum: Optional[float] = None,
        portfolio_return: Optional[float] = None,
        benchmark_return: Optional[float] = None,
        high_water_mark: Optional[float] = None,
        portfolio_id: Optional[str] = None,
        notes: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create billing record

        Args:
        client_id: Client ID
        fee_schedule_id: Fee schedule ID
        period_start: Period start date
        period_end: Period end date
        aum: AUM
        portfolio_return: Portfolio return
        benchmark_return: Benchmark return
        high_water_mark: High water mark
        portfolio_id: Portfolio ID
        notes: Notes"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["fee_schedule_id"] = fee_schedule_id
        params["period_start"] = period_start
        params["period_end"] = period_end
        if aum is not None:
            params["aum"] = aum
        if portfolio_return is not None:
            params["portfolio_return"] = portfolio_return
        if benchmark_return is not None:
            params["benchmark_return"] = benchmark_return
        if high_water_mark is not None:
            params["high_water_mark"] = high_water_mark
        if portfolio_id is not None:
            params["portfolio_id"] = portfolio_id
        if notes is not None:
            params["notes"] = notes
        return self._call("billing.record_create", params=params, options=options, context=context)

    def record_list(
        self,
        *,
        client_id: Optional[str] = None,
        year: Optional[int] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List billing records

        Args:
        client_id: Filter by client
        year: Filter by year
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if client_id is not None:
            params["client_id"] = client_id
        if year is not None:
            params["year"] = year
        if limit is not None:
            params["limit"] = limit
        return self._call("billing.record_list", params=params, options=options, context=context, response_format=response_format)

    def schedule_create(
        self,
        *,
        name: str,
        fee_type: str,
        frequency: Optional[str] = "quarterly",
        currency: Optional[str] = "EUR",
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create fee schedule

        Args:
        name: Schedule name
        fee_type: aum_percentage|flat|tiered|performance
        frequency: monthly|quarterly|annually
        currency: Currency"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["fee_type"] = fee_type
        if frequency is not None:
            params["frequency"] = frequency
        if currency is not None:
            params["currency"] = currency
        return self._call("billing.schedule_create", params=params, options=options, context=context)

    def schedule_delete(
        self,
        *,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete fee schedule

        Args:
        id: Schedule ID"""
        params: Dict[str, Any] = {}
        params["id"] = id
        return self._call("billing.schedule_delete", params=params, options=options, context=context)

    def schedule_get(
        self,
        *,
        id: Optional[str] = None,
        name: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get fee schedule

        Args:
        id: Schedule ID
        name: Schedule name"""
        params: Dict[str, Any] = {}
        if id is not None:
            params["id"] = id
        if name is not None:
            params["name"] = name
        return self._call("billing.schedule_get", params=params, options=options, context=context)

    def schedule_list(
        self,
        *,
        fee_type: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List fee schedules

        Args:
        fee_type: Filter by fee type
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if fee_type is not None:
            params["fee_type"] = fee_type
        if limit is not None:
            params["limit"] = limit
        return self._call("billing.schedule_list", params=params, options=options, context=context, response_format=response_format)

    def schedule_update(
        self,
        *,
        id: str,
        name: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update fee schedule

        Args:
        id: Schedule ID
        name: New name"""
        params: Dict[str, Any] = {}
        params["id"] = id
        if name is not None:
            params["name"] = name
        return self._call("billing.schedule_update", params=params, options=options, context=context)

    def simulate(
        self,
        *,
        fee_schedule: Dict[str, Any],
        scenarios: Optional[List[Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Simulate fees

        Simulate fees for different scenarios.

        Args:
        fee_schedule: Fee schedule
        scenarios: Scenarios to simulate"""
        params: Dict[str, Any] = {}
        params["fee_schedule"] = fee_schedule
        if scenarios is not None:
            params["scenarios"] = scenarios
        return self._call("billing.simulate", params=params, options=options, context=context)



class AsyncBillingAPI(AsyncBaseAPI):
    """Billing namespace: aggregate, calculate, record_create, record_list, schedule_create, schedule_delete, schedule_get, schedule_list, schedule_update, simulate."""

    async def aggregate(
        self,
        *,
        client_id: str,
        year: Optional[int] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Aggregate fees

        Aggregate fees for a client.

        Args:
        client_id: Client ID
        year: Filter by year"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        if year is not None:
            params["year"] = year
        return await self._call("billing.aggregate", params=params, options=options, context=context, response_format=response_format)

    async def calculate(
        self,
        *,
        fee_schedule: Optional[Dict[str, Any]] = None,
        aum: Optional[float] = None,
        portfolio_return: Optional[float] = None,
        benchmark_return: Optional[float] = None,
        high_water_mark: Optional[float] = None,
        period_start: Optional[str] = None,
        period_end: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Calculate fee

        Calculate fee based on schedule.

        Args:
        fee_schedule: Fee schedule (inline dict or ID/name string)
        aum: Assets under management
        portfolio_return: Portfolio return
        benchmark_return: Benchmark return
        high_water_mark: High water mark
        period_start: Period start date
        period_end: Period end date"""
        params: Dict[str, Any] = {}
        if fee_schedule is not None:
            params["fee_schedule"] = fee_schedule
        if aum is not None:
            params["aum"] = aum
        if portfolio_return is not None:
            params["portfolio_return"] = portfolio_return
        if benchmark_return is not None:
            params["benchmark_return"] = benchmark_return
        if high_water_mark is not None:
            params["high_water_mark"] = high_water_mark
        if period_start is not None:
            params["period_start"] = period_start
        if period_end is not None:
            params["period_end"] = period_end
        return await self._call("billing.calculate", params=params, options=options, context=context)

    async def record_create(
        self,
        *,
        client_id: str,
        fee_schedule_id: str,
        period_start: str,
        period_end: str,
        aum: Optional[float] = None,
        portfolio_return: Optional[float] = None,
        benchmark_return: Optional[float] = None,
        high_water_mark: Optional[float] = None,
        portfolio_id: Optional[str] = None,
        notes: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create billing record

        Args:
        client_id: Client ID
        fee_schedule_id: Fee schedule ID
        period_start: Period start date
        period_end: Period end date
        aum: AUM
        portfolio_return: Portfolio return
        benchmark_return: Benchmark return
        high_water_mark: High water mark
        portfolio_id: Portfolio ID
        notes: Notes"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["fee_schedule_id"] = fee_schedule_id
        params["period_start"] = period_start
        params["period_end"] = period_end
        if aum is not None:
            params["aum"] = aum
        if portfolio_return is not None:
            params["portfolio_return"] = portfolio_return
        if benchmark_return is not None:
            params["benchmark_return"] = benchmark_return
        if high_water_mark is not None:
            params["high_water_mark"] = high_water_mark
        if portfolio_id is not None:
            params["portfolio_id"] = portfolio_id
        if notes is not None:
            params["notes"] = notes
        return await self._call("billing.record_create", params=params, options=options, context=context)

    async def record_list(
        self,
        *,
        client_id: Optional[str] = None,
        year: Optional[int] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List billing records

        Args:
        client_id: Filter by client
        year: Filter by year
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if client_id is not None:
            params["client_id"] = client_id
        if year is not None:
            params["year"] = year
        if limit is not None:
            params["limit"] = limit
        return await self._call("billing.record_list", params=params, options=options, context=context, response_format=response_format)

    async def schedule_create(
        self,
        *,
        name: str,
        fee_type: str,
        frequency: Optional[str] = "quarterly",
        currency: Optional[str] = "EUR",
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create fee schedule

        Args:
        name: Schedule name
        fee_type: aum_percentage|flat|tiered|performance
        frequency: monthly|quarterly|annually
        currency: Currency"""
        params: Dict[str, Any] = {}
        params["name"] = name
        params["fee_type"] = fee_type
        if frequency is not None:
            params["frequency"] = frequency
        if currency is not None:
            params["currency"] = currency
        return await self._call("billing.schedule_create", params=params, options=options, context=context)

    async def schedule_delete(
        self,
        *,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Delete fee schedule

        Args:
        id: Schedule ID"""
        params: Dict[str, Any] = {}
        params["id"] = id
        return await self._call("billing.schedule_delete", params=params, options=options, context=context)

    async def schedule_get(
        self,
        *,
        id: Optional[str] = None,
        name: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get fee schedule

        Args:
        id: Schedule ID
        name: Schedule name"""
        params: Dict[str, Any] = {}
        if id is not None:
            params["id"] = id
        if name is not None:
            params["name"] = name
        return await self._call("billing.schedule_get", params=params, options=options, context=context)

    async def schedule_list(
        self,
        *,
        fee_type: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List fee schedules

        Args:
        fee_type: Filter by fee type
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if fee_type is not None:
            params["fee_type"] = fee_type
        if limit is not None:
            params["limit"] = limit
        return await self._call("billing.schedule_list", params=params, options=options, context=context, response_format=response_format)

    async def schedule_update(
        self,
        *,
        id: str,
        name: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update fee schedule

        Args:
        id: Schedule ID
        name: New name"""
        params: Dict[str, Any] = {}
        params["id"] = id
        if name is not None:
            params["name"] = name
        return await self._call("billing.schedule_update", params=params, options=options, context=context)

    async def simulate(
        self,
        *,
        fee_schedule: Dict[str, Any],
        scenarios: Optional[List[Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Simulate fees

        Simulate fees for different scenarios.

        Args:
        fee_schedule: Fee schedule
        scenarios: Scenarios to simulate"""
        params: Dict[str, Any] = {}
        params["fee_schedule"] = fee_schedule
        if scenarios is not None:
            params["scenarios"] = scenarios
        return await self._call("billing.simulate", params=params, options=options, context=context)


