"""
Clients API namespace.

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

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class ClientsAPI(BaseAPI):
    """Clients namespace: assign_portfolio, create, delete, get, list, portfolios, unassign_portfolio, update."""

    def assign_portfolio(
        self,
        *,
        client_id: str,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Assign portfolio to client

        Args:
        client_id: Client ID
        id: Portfolio ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["id"] = id
        return self._call("clients.assign_portfolio", params=params, options=options, context=context)

    def create(
        self,
        *,
        name: str,
        email: Optional[str] = None,
        external_id: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create client

        Args:
        name: Client name
        email: Client email
        external_id: External system ID
        metadata: Additional metadata"""
        params: Dict[str, Any] = {}
        params["name"] = name
        if email is not None:
            params["email"] = email
        if external_id is not None:
            params["external_id"] = external_id
        if metadata is not None:
            params["metadata"] = metadata
        return self._call("clients.create", params=params, options=options, context=context)

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

        Args:
        client_id: Client ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        return self._call("clients.delete", params=params, options=options, context=context)

    def get(
        self,
        *,
        client_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get client

        Args:
        client_id: Client ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        return self._call("clients.get", params=params, options=options, context=context)

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

        Args:
        search: Search in name
        status: active|inactive|all
        limit: Maximum results
        offset: Pagination offset"""
        params: Dict[str, Any] = {}
        if search is not None:
            params["search"] = search
        if status is not None:
            params["status"] = status
        if limit is not None:
            params["limit"] = limit
        if offset is not None:
            params["offset"] = offset
        return self._call("clients.list", params=params, options=options, context=context, response_format=response_format)

    def portfolios(
        self,
        *,
        client_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List client portfolios

        Args:
        client_id: Client ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        return self._call("clients.portfolios", params=params, options=options, context=context, response_format=response_format)

    def unassign_portfolio(
        self,
        *,
        client_id: str,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Unassign portfolio from client

        Args:
        client_id: Client ID
        id: Portfolio ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["id"] = id
        return self._call("clients.unassign_portfolio", params=params, options=options, context=context)

    def update(
        self,
        *,
        client_id: str,
        name: Optional[str] = None,
        email: Optional[str] = None,
        status: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update client

        Args:
        client_id: Client ID
        name: New name
        email: New email
        status: New status
        metadata: New metadata"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        if name is not None:
            params["name"] = name
        if email is not None:
            params["email"] = email
        if status is not None:
            params["status"] = status
        if metadata is not None:
            params["metadata"] = metadata
        return self._call("clients.update", params=params, options=options, context=context)



class AsyncClientsAPI(AsyncBaseAPI):
    """Clients namespace: assign_portfolio, create, delete, get, list, portfolios, unassign_portfolio, update."""

    async def assign_portfolio(
        self,
        *,
        client_id: str,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Assign portfolio to client

        Args:
        client_id: Client ID
        id: Portfolio ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["id"] = id
        return await self._call("clients.assign_portfolio", params=params, options=options, context=context)

    async def create(
        self,
        *,
        name: str,
        email: Optional[str] = None,
        external_id: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Create client

        Args:
        name: Client name
        email: Client email
        external_id: External system ID
        metadata: Additional metadata"""
        params: Dict[str, Any] = {}
        params["name"] = name
        if email is not None:
            params["email"] = email
        if external_id is not None:
            params["external_id"] = external_id
        if metadata is not None:
            params["metadata"] = metadata
        return await self._call("clients.create", params=params, options=options, context=context)

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

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

    async def get(
        self,
        *,
        client_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get client

        Args:
        client_id: Client ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        return await self._call("clients.get", params=params, options=options, context=context)

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

        Args:
        search: Search in name
        status: active|inactive|all
        limit: Maximum results
        offset: Pagination offset"""
        params: Dict[str, Any] = {}
        if search is not None:
            params["search"] = search
        if status is not None:
            params["status"] = status
        if limit is not None:
            params["limit"] = limit
        if offset is not None:
            params["offset"] = offset
        return await self._call("clients.list", params=params, options=options, context=context, response_format=response_format)

    async def portfolios(
        self,
        *,
        client_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List client portfolios

        Args:
        client_id: Client ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        return await self._call("clients.portfolios", params=params, options=options, context=context, response_format=response_format)

    async def unassign_portfolio(
        self,
        *,
        client_id: str,
        id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Unassign portfolio from client

        Args:
        client_id: Client ID
        id: Portfolio ID"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        params["id"] = id
        return await self._call("clients.unassign_portfolio", params=params, options=options, context=context)

    async def update(
        self,
        *,
        client_id: str,
        name: Optional[str] = None,
        email: Optional[str] = None,
        status: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Update client

        Args:
        client_id: Client ID
        name: New name
        email: New email
        status: New status
        metadata: New metadata"""
        params: Dict[str, Any] = {}
        params["client_id"] = client_id
        if name is not None:
            params["name"] = name
        if email is not None:
            params["email"] = email
        if status is not None:
            params["status"] = status
        if metadata is not None:
            params["metadata"] = metadata
        return await self._call("clients.update", params=params, options=options, context=context)


