Add regional task templates API with climate zone lookup
Adds a new endpoint GET /api/tasks/templates/by-region/?zip= that resolves ZIP codes to IECC climate regions and returns relevant home maintenance task templates. Includes climate region model, region lookup service with tests, seed data for all 8 climate zones with 50+ templates, and OpenAPI spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,24 @@ func (h *TaskTemplateHandler) GetTemplatesByCategory(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, templates)
|
||||
}
|
||||
|
||||
// GetTemplatesByRegion handles GET /api/tasks/templates/by-region/?state=XX or ?zip=12345
|
||||
// Returns templates specific to the user's climate region based on state abbreviation or ZIP code
|
||||
func (h *TaskTemplateHandler) GetTemplatesByRegion(c echo.Context) error {
|
||||
state := c.QueryParam("state")
|
||||
zip := c.QueryParam("zip")
|
||||
|
||||
if state == "" && zip == "" {
|
||||
return apperrors.BadRequest("error.state_or_zip_required")
|
||||
}
|
||||
|
||||
templates, err := h.templateService.GetByRegion(state, zip)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, templates)
|
||||
}
|
||||
|
||||
// GetTemplate handles GET /api/tasks/templates/:id/
|
||||
// Returns a single template by ID
|
||||
func (h *TaskTemplateHandler) GetTemplate(c echo.Context) error {
|
||||
|
||||
Reference in New Issue
Block a user