"""
Auto-generated gmb_location_details 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 GmbLocationDetailsResource:
    """
    gmb_location_details 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_google_business_location_details(
        self, account_id: str, *, read_mask: str | None = None
    ) -> dict[str, Any]:
        """Get Google Business Profile location details"""
        params = self._build_params(
            read_mask=read_mask,
        )
        return self._client._get(
            f"/v1/accounts/{account_id}/gmb-location-details", params=params
        )

    def update_google_business_location_details(
        self,
        account_id: str,
        update_mask: str,
        *,
        regular_hours: dict[str, Any] | None = None,
        special_hours: dict[str, Any] | None = None,
        profile: dict[str, Any] | None = None,
        website_uri: str | None = None,
        phone_numbers: dict[str, Any] | None = None,
    ) -> dict[str, Any]:
        """Update Google Business Profile location details"""
        payload = self._build_payload(
            update_mask=update_mask,
            regular_hours=regular_hours,
            special_hours=special_hours,
            profile=profile,
            website_uri=website_uri,
            phone_numbers=phone_numbers,
        )
        return self._client._put(
            f"/v1/accounts/{account_id}/gmb-location-details", data=payload
        )

    async def aget_google_business_location_details(
        self, account_id: str, *, read_mask: str | None = None
    ) -> dict[str, Any]:
        """Get Google Business Profile location details (async)"""
        params = self._build_params(
            read_mask=read_mask,
        )
        return await self._client._aget(
            f"/v1/accounts/{account_id}/gmb-location-details", params=params
        )

    async def aupdate_google_business_location_details(
        self,
        account_id: str,
        update_mask: str,
        *,
        regular_hours: dict[str, Any] | None = None,
        special_hours: dict[str, Any] | None = None,
        profile: dict[str, Any] | None = None,
        website_uri: str | None = None,
        phone_numbers: dict[str, Any] | None = None,
    ) -> dict[str, Any]:
        """Update Google Business Profile location details (async)"""
        payload = self._build_payload(
            update_mask=update_mask,
            regular_hours=regular_hours,
            special_hours=special_hours,
            profile=profile,
            website_uri=website_uri,
            phone_numbers=phone_numbers,
        )
        return await self._client._aput(
            f"/v1/accounts/{account_id}/gmb-location-details", data=payload
        )
