add West Northamptonshire council, UK

This commit is contained in:
5ila5
2024-04-30 10:31:49 +02:00
committed by 5ila5
parent 190c8aaca5
commit 56a0b48210
4 changed files with 93 additions and 1 deletions

View File

@@ -1366,6 +1366,7 @@ Waste collection schedules in the following formats and countries are supported.
- [West Berkshire Council](/doc/source/westberks_gov_uk.md) / westberks.gov.uk
- [West Devon Borough Council](/doc/source/fccenvironment_co_uk.md) / westdevon.gov.uk
- [West Dunbartonshire Council](/doc/source/west_dunbartonshire_gov_uk.md) / west-dunbarton.gov.uk
- [West Northamptonshire council](/doc/source/westnorthants_gov_uk.md) / westnorthants.gov.uk
- [West Suffolk Council](/doc/source/westsuffolk_gov_uk.md) / westsuffolk.gov.uk
- [Westmorland & Furness Council, Barrow area](/doc/ics/barrowbc_gov_uk.md) / barrowbc.gov.uk
- [Westmorland & Furness Council, South Lakeland area](/doc/ics/southlakeland_gov_uk.md) / southlakeland.gov.uk

View File

@@ -0,0 +1,54 @@
from datetime import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "West Northamptonshire council"
DESCRIPTION = "Source for West Northamptonshire council."
URL = "https://www.westnorthants.gov.uk/"
TEST_CASES = {
"28058314": {"uprn": 28058314},
"15049111": {"uprn": "15049111"},
}
ICON_MAP = {
"refuse": "mdi:trash-can",
"food": "mdi:food",
"garden": "mdi:recycle",
"recycling": "mdi:package-variant",
"recycling_boxes": "mdi:package-variant",
"sacks": "mdi:sack",
}
API_URL = (
"https://api.westnorthants.digital/openapi/v1/unified-waste-collections/{uprn}"
)
class Source:
def __init__(self, uprn: str | int):
self._uprn: str | int = uprn
def fetch(self):
# Get variables for workings
response = requests.get(
API_URL.format(uprn=self._uprn),
)
response.raise_for_status()
data = response.json()
entries = []
for collection in data["collectionItems"]:
day = datetime.strptime(collection["date"], "%Y-%m-%d").date()
entries.append(
Collection(
t=collection["type"],
date=day,
icon=ICON_MAP.get(collection["type"]),
)
)
return sorted(entries, key=lambda x: x.date)

View File

@@ -0,0 +1,37 @@
# West Northamptonshire council
Support for schedules provided by [West Northamptonshire council](https://www.northnorthants.gov.uk/), serving West Northamptonshire council.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: westnorthants_gov_uk
args:
uprn: "UPRN"
```
### Configuration Variables
**uprn**
*(String | Integer) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: westnorthants_gov_uk
args:
uprn: "28058314"
```
## How to get the source argument
An easy way to discover your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.
Or by inspection the webtraffic of your browser while filling out the form you will see a request to <https://api.westnorthants.digital/openapi/v1/unified-waste-collections/28058314> where `28058314` is your UPRN.

File diff suppressed because one or more lines are too long