Source code for britecore_sdk.api.api_calls.v2.notifications

"""BriteCore v2 Notifications API endpoint wrappers.

This module provides wrappers for acknowledging notifications and retrieving
the current unacknowledged notification list.
"""

from logging import Logger
from typing import Any, Unpack, cast

from urllib3 import BaseHTTPResponse, HTTPResponse

from britecore_sdk import logger
from britecore_sdk.api.api_calls import (
    BritecoreAPIClient,
    RequestParameters,
    api_client,
)

LOGGER: Logger = logger

API_CLIENT: BritecoreAPIClient = api_client


def post(
    path: str,
    payload: dict[str, Any] | None = None,
    **kwargs: Unpack[RequestParameters],
) -> Any:
    """Send a notifications request and normalize the response."""
    LOGGER.debug("Calling notifications endpoint %s", path)
    request_result: BaseHTTPResponse | HTTPResponse | None = API_CLIENT.do_request(
        path=path,
        json=payload if payload is not None else {},
        **kwargs,
    )
    return API_CLIENT.process_result(cast(Any, request_result))


[docs] def acknowledge( **kwargs: Unpack[RequestParameters], ) -> Any: """Acknowledge the caller's current notifications. POST /api/v2/notifications/acknowledge """ return post("/api/v2/notifications/acknowledge", {}, **kwargs)
[docs] def current( **kwargs: Unpack[RequestParameters], ) -> Any: """Retrieve the current unacknowledged notifications. POST /api/v2/notifications/current """ return post("/api/v2/notifications/current", {}, **kwargs)
__all__ = [ "acknowledge", "current", ]