improve awido_de support for city-only destinations

This change is backward compatible because I don't know if there are
city-only use cases which do not require to set a street name.
This commit is contained in:
mampfes
2022-01-04 18:59:02 +01:00
parent 15c226be6e
commit 2aac893be1
2 changed files with 21 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ TEST_CASES = {
"city": "Kaufbeuren",
"street": "Rehgrund",
},
"Tübingen, Dettenhausen": {"customer": "tuebingen", "city": "Dettenhausen"},
}
_LOGGER = logging.getLogger(__name__)
@@ -54,7 +55,25 @@ class Source:
oid = city_to_oid[self._city]
if self._street is not None:
if self._street is None:
# test if we have to use city also as street name
self._street = self._city
r = requests.get(
f"https://awido.cubefour.de/WebServices/Awido.Service.svc/secure/getGroupedStreets/{oid}",
params={"client": self._customer},
)
streets = json.loads(r.text)
# create street to key map from retrieved places
street_to_oid = {
street["value"].strip(): street["key"] for (street) in streets
}
if self._street in street_to_oid:
oid = street_to_oid[self._street]
else:
# street specified
r = requests.get(
f"https://awido.cubefour.de/WebServices/Awido.Service.svc/secure/getGroupedStreets/{oid}",
params={"client": self._customer},

View File

@@ -84,6 +84,6 @@ List of customers (2021-07-09):
### city, street, house number
- Go to your calendar at `https://awido.cubefour.de/Customer/<customer>/v2/Calendar2.aspx`. Replace `<customer>` with the one of the keys listed above.
- Enter your city name from the first page into the `city` field, except for single-city customers, then the parameter `city` is the city.
- Enter your city name from the first page into the `city` field.
- If you have to enter a street or district, enter the name into the `street` field.
- If you have to enter a house number, enter the house number into the `housenumber` field.