Skip to content

Commit

Permalink
Added user-agent header + remove misplaced field in Coordinates model
Browse files Browse the repository at this point in the history
  • Loading branch information
bendikrb committed Nov 2, 2024
1 parent 9c9d8ac commit 9472c62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions telguarder/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
TelguarderUnauthorizedError,
)
from telguarder.models import LookupResults
from telguarder.version import __version__

_LOGGER = logging.getLogger(__name__)

Expand All @@ -41,6 +42,8 @@ class TelguarderClient:
"""Country code for the Telguarder service."""
request_timeout: int = DEFAULT_REQUEST_TIMEOUT
"""Timeout for API requests in seconds."""
user_agent: str | None = None
"""User agent for API requests."""
session: ClientSession | None = None
"""(ClientSession | None): The :class:`aiohttp.ClientSession` to use for API requests."""

Expand Down Expand Up @@ -139,6 +142,7 @@ def request_header(self) -> dict[str, str]:
"""Generate a header for HTTP requests to the server."""
return {
"Accept": "application/json",
"User-Agent": self.user_agent or f"telguarder/{__version__}",
"X-Country-Code": self.country_code,
"X-ServiceKey": SERVICE_KEY,
}
Expand Down
1 change: 0 additions & 1 deletion telguarder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class Address(BaseDataClassORJSONMixin):
class Coordinates(BaseDataClassORJSONMixin):
longitude: float
latitude: float
address: Address | None = None


@dataclass
Expand Down

0 comments on commit 9472c62

Please sign in to comment.