Skip to content

Commit

Permalink
reformatting + comment for parameter + additional test case
Browse files Browse the repository at this point in the history
  • Loading branch information
5ila5 committed Jul 29, 2023
1 parent adb332c commit f2bd445
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import datetime

from waste_collection_schedule import Collection
from waste_collection_schedule.service.SSLError import get_legacy_session

TITLE = "Hamilton City Council"
DESCRIPTION = "Source script for Hamilton City Council"
URL = "https://www.fightthelandfill.co.nz/"
TEST_CASES = {
"1 Hamilton Parade": {"address": "1 Hamilton Parade"}
"1 Hamilton Parade": {"address": "1 Hamilton Parade"},
"221b fox Street": {"address": "221b fox Street"},
}

API_URL = "https://api.hcc.govt.nz/FightTheLandFill/get_Collection_Dates"
ICON_MAP = {
"Rubbish": "mdi:trash-can",
"Recycling": "mdi:recycle"
}
ICON_MAP = {"Rubbish": "mdi:trash-can", "Recycling": "mdi:recycle"}


class Source:
Expand All @@ -24,23 +23,28 @@ def fetch(self):

s = get_legacy_session()

r = s.get(API_URL,
r = s.get(
API_URL,
params={"address_string": self.address},
)
json = r.json()

#Extract entries from RedBin/YellowBin fields
# Extract entries from RedBin/YellowBin fields
entries = [
Collection(
date = datetime.datetime.strptime(json[0]["RedBin"], "%Y-%m-%dT%H:%M:%S").date(),
t = "Rubbish",
icon = ICON_MAP.get("Rubbish"),
date=datetime.datetime.strptime(
json[0]["RedBin"], "%Y-%m-%dT%H:%M:%S"
).date(),
t="Rubbish",
icon=ICON_MAP.get("Rubbish"),
),
Collection(
date = datetime.datetime.strptime(json[0]["YellowBin"], "%Y-%m-%dT%H:%M:%S").date(),
t = "Recycling",
icon = ICON_MAP.get("Recycling"),
)
date=datetime.datetime.strptime(
json[0]["YellowBin"], "%Y-%m-%dT%H:%M:%S"
).date(),
t="Recycling",
icon=ICON_MAP.get("Recycling"),
),
]

return entries
return entries
1 change: 1 addition & 0 deletions doc/source/hcc_govt_nz.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ waste_collection_schedule:
**address**
*(string) (required)*
excactyl written like autocompleted by <https://www.fightthelandfill.co.nz>
## Bin Names example - Rubbish, Recycling
Expand Down

0 comments on commit f2bd445

Please sign in to comment.