aioamazondevices 3.1.23__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/PKG-INFO +1 -1
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/pyproject.toml +1 -1
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/api.py +31 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/exceptions.py +4 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/LICENSE +0 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/README.md +0 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/const.py +0 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/sounds.py +0 -0
- {aioamazondevices-3.1.23 → aioamazondevices-3.2.0}/src/aioamazondevices/utils.py +0 -0
@@ -56,6 +56,7 @@ from .exceptions import (
|
|
56
56
|
CannotConnect,
|
57
57
|
CannotRegisterDevice,
|
58
58
|
CannotRetrieveData,
|
59
|
+
WrongCountry,
|
59
60
|
WrongMethod,
|
60
61
|
)
|
61
62
|
from .utils import obfuscate_email, scrub_fields
|
@@ -525,6 +526,31 @@ class AmazonEchoApi:
|
|
525
526
|
await self._save_to_file(login_data, "login_data", JSON_EXTENSION)
|
526
527
|
return login_data
|
527
528
|
|
529
|
+
async def _check_country(self) -> None:
|
530
|
+
"""Check if user selected country matches Amazon account country."""
|
531
|
+
url = f"https://alexa.amazon.{self._domain}/api/users/me"
|
532
|
+
_, resp_me = await self._session_request(HTTPMethod.GET, url)
|
533
|
+
|
534
|
+
if resp_me.status != HTTPStatus.OK:
|
535
|
+
raise CannotAuthenticate
|
536
|
+
|
537
|
+
resp_me_json = await resp_me.json()
|
538
|
+
market = resp_me_json["marketPlaceDomainName"]
|
539
|
+
language = resp_me_json["marketPlaceLocale"]
|
540
|
+
|
541
|
+
_domain = f"https://www.amazon.{self._domain}"
|
542
|
+
|
543
|
+
if market != _domain or language != self._language:
|
544
|
+
_LOGGER.debug(
|
545
|
+
"Selected country <%s> doesn't matches Amazon account:\n%s\n vs \n%s",
|
546
|
+
self._login_country_code.upper(),
|
547
|
+
{"site ": _domain, "locale": self._language},
|
548
|
+
{"market": market, "locale": language},
|
549
|
+
)
|
550
|
+
raise WrongCountry
|
551
|
+
|
552
|
+
_LOGGER.debug("User selected country matches Amazon account one")
|
553
|
+
|
528
554
|
async def _get_devices_ids(self) -> list[dict[str, str]]:
|
529
555
|
"""Retrieve devices entityId and applianceId."""
|
530
556
|
_, raw_resp = await self._session_request(
|
@@ -698,6 +724,9 @@ class AmazonEchoApi:
|
|
698
724
|
self._login_stored_data = register_device
|
699
725
|
|
700
726
|
_LOGGER.info("Register device: %s", scrub_fields(register_device))
|
727
|
+
|
728
|
+
await self._check_country()
|
729
|
+
|
701
730
|
return register_device
|
702
731
|
|
703
732
|
async def login_mode_stored_data(self) -> dict[str, Any]:
|
@@ -716,6 +745,8 @@ class AmazonEchoApi:
|
|
716
745
|
|
717
746
|
self._client_session()
|
718
747
|
|
748
|
+
await self._check_country()
|
749
|
+
|
719
750
|
return self._login_stored_data
|
720
751
|
|
721
752
|
async def close(self) -> None:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|