"""
Auto-generated account_settings resource.

DO NOT EDIT THIS FILE MANUALLY.
Run `python scripts/generate_resources.py` to regenerate.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
    from ..client.base import BaseClient


class AccountSettingsResource:
    """
    account_settings operations.
    """

    def __init__(self, client: BaseClient) -> None:
        self._client = client

    def _build_params(self, **kwargs: Any) -> dict[str, Any]:
        """Build query parameters, filtering None values."""

        def to_camel(s: str) -> str:
            parts = s.split("_")
            return parts[0] + "".join(p.title() for p in parts[1:])

        return {to_camel(k): v for k, v in kwargs.items() if v is not None}

    def _build_payload(self, **kwargs: Any) -> dict[str, Any]:
        """Build request payload, filtering None values."""
        from datetime import datetime

        def to_camel(s: str) -> str:
            parts = s.split("_")
            return parts[0] + "".join(p.title() for p in parts[1:])

        result: dict[str, Any] = {}
        for k, v in kwargs.items():
            if v is None:
                continue
            if isinstance(v, datetime):
                result[to_camel(k)] = v.isoformat()
            else:
                result[to_camel(k)] = v
        return result

    def get_messenger_menu(self, account_id: str) -> dict[str, Any]:
        """Get FB persistent menu"""
        return self._client._get(f"/v1/accounts/{account_id}/messenger-menu")

    def set_messenger_menu(
        self, account_id: str, persistent_menu: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set FB persistent menu"""
        payload = self._build_payload(
            persistent_menu=persistent_menu,
        )
        return self._client._put(
            f"/v1/accounts/{account_id}/messenger-menu", data=payload
        )

    def delete_messenger_menu(self, account_id: str) -> dict[str, Any]:
        """Delete FB persistent menu"""
        return self._client._delete(f"/v1/accounts/{account_id}/messenger-menu")

    def get_instagram_ice_breakers(self, account_id: str) -> dict[str, Any]:
        """Get IG ice breakers"""
        return self._client._get(f"/v1/accounts/{account_id}/instagram-ice-breakers")

    def set_instagram_ice_breakers(
        self, account_id: str, ice_breakers: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set IG ice breakers"""
        payload = self._build_payload(
            ice_breakers=ice_breakers,
        )
        return self._client._put(
            f"/v1/accounts/{account_id}/instagram-ice-breakers", data=payload
        )

    def delete_instagram_ice_breakers(self, account_id: str) -> dict[str, Any]:
        """Delete IG ice breakers"""
        return self._client._delete(f"/v1/accounts/{account_id}/instagram-ice-breakers")

    def get_telegram_commands(self, account_id: str) -> dict[str, Any]:
        """Get TG bot commands"""
        return self._client._get(f"/v1/accounts/{account_id}/telegram-commands")

    def set_telegram_commands(
        self, account_id: str, commands: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set TG bot commands"""
        payload = self._build_payload(
            commands=commands,
        )
        return self._client._put(
            f"/v1/accounts/{account_id}/telegram-commands", data=payload
        )

    def delete_telegram_commands(self, account_id: str) -> dict[str, Any]:
        """Delete TG bot commands"""
        return self._client._delete(f"/v1/accounts/{account_id}/telegram-commands")

    async def aget_messenger_menu(self, account_id: str) -> dict[str, Any]:
        """Get FB persistent menu (async)"""
        return await self._client._aget(f"/v1/accounts/{account_id}/messenger-menu")

    async def aset_messenger_menu(
        self, account_id: str, persistent_menu: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set FB persistent menu (async)"""
        payload = self._build_payload(
            persistent_menu=persistent_menu,
        )
        return await self._client._aput(
            f"/v1/accounts/{account_id}/messenger-menu", data=payload
        )

    async def adelete_messenger_menu(self, account_id: str) -> dict[str, Any]:
        """Delete FB persistent menu (async)"""
        return await self._client._adelete(f"/v1/accounts/{account_id}/messenger-menu")

    async def aget_instagram_ice_breakers(self, account_id: str) -> dict[str, Any]:
        """Get IG ice breakers (async)"""
        return await self._client._aget(
            f"/v1/accounts/{account_id}/instagram-ice-breakers"
        )

    async def aset_instagram_ice_breakers(
        self, account_id: str, ice_breakers: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set IG ice breakers (async)"""
        payload = self._build_payload(
            ice_breakers=ice_breakers,
        )
        return await self._client._aput(
            f"/v1/accounts/{account_id}/instagram-ice-breakers", data=payload
        )

    async def adelete_instagram_ice_breakers(self, account_id: str) -> dict[str, Any]:
        """Delete IG ice breakers (async)"""
        return await self._client._adelete(
            f"/v1/accounts/{account_id}/instagram-ice-breakers"
        )

    async def aget_telegram_commands(self, account_id: str) -> dict[str, Any]:
        """Get TG bot commands (async)"""
        return await self._client._aget(f"/v1/accounts/{account_id}/telegram-commands")

    async def aset_telegram_commands(
        self, account_id: str, commands: list[dict[str, Any]]
    ) -> dict[str, Any]:
        """Set TG bot commands (async)"""
        payload = self._build_payload(
            commands=commands,
        )
        return await self._client._aput(
            f"/v1/accounts/{account_id}/telegram-commands", data=payload
        )

    async def adelete_telegram_commands(self, account_id: str) -> dict[str, Any]:
        """Delete TG bot commands (async)"""
        return await self._client._adelete(
            f"/v1/accounts/{account_id}/telegram-commands"
        )
