mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Add x-client headers to Habitica API calls (#127952)
Add x-client headers
This commit is contained in:
parent
63391717e7
commit
38fc0bd889
@ -10,12 +10,14 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
APPLICATION_NAME,
|
||||
ATTR_NAME,
|
||||
CONF_API_KEY,
|
||||
CONF_NAME,
|
||||
CONF_URL,
|
||||
CONF_VERIFY_SSL,
|
||||
Platform,
|
||||
__version__,
|
||||
)
|
||||
from homeassistant.core import (
|
||||
HomeAssistant,
|
||||
@ -41,6 +43,7 @@ from .const import (
|
||||
ATTR_SKILL,
|
||||
ATTR_TASK,
|
||||
CONF_API_USER,
|
||||
DEVELOPER_ID,
|
||||
DOMAIN,
|
||||
EVENT_API_CALL_SUCCESS,
|
||||
SERVICE_API_CALL,
|
||||
@ -164,6 +167,13 @@ async def async_setup_entry(
|
||||
def __call__(self, **kwargs):
|
||||
return super().__call__(websession, **kwargs)
|
||||
|
||||
def _make_headers(self) -> dict[str, str]:
|
||||
headers = super()._make_headers()
|
||||
headers.update(
|
||||
{"x-client": f"{DEVELOPER_ID} - {APPLICATION_NAME} {__version__}"}
|
||||
)
|
||||
return headers
|
||||
|
||||
async def handle_api_call(call: ServiceCall) -> None:
|
||||
name = call.data[ATTR_NAME]
|
||||
path = call.data[ATTR_PATH]
|
||||
|
@ -26,3 +26,5 @@ ATTR_CONFIG_ENTRY = "config_entry"
|
||||
ATTR_SKILL = "skill"
|
||||
ATTR_TASK = "task"
|
||||
SERVICE_CAST_SKILL = "cast_skill"
|
||||
|
||||
DEVELOPER_ID = "4c4ca53f-c059-4ffa-966e-9d29dd405daf"
|
||||
|
Loading…
x
Reference in New Issue
Block a user