Initial commit: Waste Collection API

This commit is contained in:
2026-04-05 07:29:36 +00:00
commit 109b682a88
17 changed files with 1016 additions and 0 deletions

100
app/schemas.py Normal file
View File

@@ -0,0 +1,100 @@
from pydantic import BaseModel, Field
from typing import Optional
# ─── Collection ───────────────────────────────────────────────
class Collection(BaseModel):
date: str = Field(description="Collection date YYYY-MM-DD")
type: str = Field(description="Waste type label")
daysUntil: int = Field(description="Days until collection")
icon: Optional[str] = Field(default=None, description="MDI icon name")
# ─── Source descriptors ────────────────────────────────────────
class SourceInfo(BaseModel):
id: str
name: str
class SourceParam(BaseModel):
name: str
type: str
required: bool
example: str
class SourceDetailResponse(BaseModel):
id: str
name: str
params: list[SourceParam]
class SourceListResponse(BaseModel):
count: int
sources: list[SourceInfo]
# ─── Request bodies ────────────────────────────────────────────
class ICSRequest(BaseModel):
url: str = Field(description="Direct URL to .ics / .ical file")
count: int = Field(default=20, ge=1, le=100)
class AbfallIORequest(BaseModel):
key: str = Field(description="Abfall.IO API key")
f_id_kommune: int = Field(description="Municipality ID")
f_id_strasse: int = Field(description="Street ID")
count: int = Field(default=20, ge=1, le=100)
class AWMRequest(BaseModel):
street: str = Field(description="Street name in Munich")
house_number: str = Field(description="House number")
count: int = Field(default=20, ge=1, le=100)
class StuttgartRequest(BaseModel):
street: str = Field(description="Street name in Stuttgart")
streetnr: int = Field(description="House number")
count: int = Field(default=20, ge=1, le=100)
class NotifyRequest(BaseModel):
source_id: str
collection: Collection
notify_at_days_before: int = Field(default=1, ge=0)
channels: list[str] = Field(description='Notification channels, e.g. ["telegram"]')
chat_id: int
# ─── Response wrappers ─────────────────────────────────────────
class CollectionsResponse(BaseModel):
source: str
collections: list[Collection]
class Notification(BaseModel):
id: str
source_id: str
collection_type: str
collection_date: str
notify_at_days_before: int
channels: list[str]
chat_id: int
fired: bool
class NotificationsResponse(BaseModel):
count: int
notifications: list[Notification]
class NotifyResponse(BaseModel):
ok: bool
notification_id: str
message: str
class DeleteResponse(BaseModel):
ok: bool
deleted: str