Add x-client headers to Habitica API calls (#127952)

Add x-client headers
This commit is contained in:
Manu 2024-10-11 17:28:22 +02:00 committed by GitHub
parent 63391717e7
commit 38fc0bd889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -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]

View File

@ -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"