Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Ealing Council #813

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@
"url": "https://www.durham.gov.uk/bincollections?uprn=",
"wiki_name": "Durham Council"
},
"EalingCouncil": {
"skip_get_url": true,
"uprn": "12073883",
"url": "https://www.ealing.gov.uk/site/custom_scripts/WasteCollectionWS/home/FindCollection",
"wiki_name": "Ealing Council"
},
"EastCambridgeshireCouncil": {
"skip_get_url": true,
"uprn": "10002597178",
Expand Down
43 changes: 43 additions & 0 deletions uk_bin_collection/uk_bin_collection/councils/EalingCouncil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import json
from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass


class CouncilClass(AbstractGetBinDataClass):
"""
Concrete classes have to implement all abstract operations of the
base class. They can also override some operations with a default
implementation.
"""

def parse_data(self, page: str, **kwargs) -> dict:
api_url = "https://www.ealing.gov.uk/site/custom_scripts/WasteCollectionWS/home/FindCollection"
user_uprn = kwargs.get("uprn")

# Check the UPRN is valid
check_uprn(user_uprn)

# Create the form data
form_data = {
"UPRN": user_uprn,
}

# Make a request to the API
requests.packages.urllib3.disable_warnings()
response = requests.post(api_url, data=form_data)

json_data = json.loads(response.text)

data = {"bins": []}

for param in json_data["param2"]:
data["bins"].append(
{
"type": param["Service"],
"collectionDate": datetime.strptime(
param["collectionDateString"], "%d/%m/%Y"
).strftime(date_format),
}
)

return data