Skip to content

Add UnitType DTO for list and detail responses - #6

Merged
jhhazelaar merged 1 commit into
mainfrom
f/jh/unit-type-dto
May 20, 2026
Merged

Add UnitType DTO for list and detail responses#6
jhhazelaar merged 1 commit into
mainfrom
f/jh/unit-type-dto

Conversation

@jhhazelaar

Copy link
Copy Markdown
Member

Summary

  • Introduces UnitType DTO covering both GET /projects/{uuid}/projectwoningen/ (list) and GET /projects/{uuid}/projectwoningen/{uuid}/ (detail) — one DTO, detail-only fields nullable so the list endpoint populates them as null.
  • Wires the DTO through GetUnitTypeRequest::createDtoFromResponse() and GetUnitTypesRequest::createDtoFromResponse(); updates UnitTypeResource::list() to return UnitType[] and get() to return UnitType, matching the ProjectResource shape.
  • Mirrors the casting helpers from Project::fromResponse(): toInt() for numeric strings and toBool() for the "-1"/"0" convention used by Projectwoning_Online. No Carbon needed — the unit-type response carries no dates.
  • Categorical fields (Woning_Typekind, Eigendomownership, Huurkooptenure) stay as ?string for now; promote to enums in a follow-up once the full value sets are known.

Test plan

  • vendor/bin/pest — full suite green locally (32 passed, 213 assertions; +13 new tests).
  • Hit a real list endpoint via NieuwbouwOffice::unitTypes('<project-uuid>')->list() and confirm an array of UnitType instances comes back.
  • Hit a real detail endpoint via ->get('<unit-uuid>') and confirm the detail-only fields (price_from, bedrooms_from, ownership, tenure, etc.) are populated.
  • Confirm the list-endpoint response leaves detail-only fields as null on the returned DTO.

UnitTypeResource was returning raw Saloon Response objects, leaving
callers to dig into Dutch JSON keys themselves. Introduce a typed
UnitType DTO that covers both the list and detail responses, with
nullable detail-only fields, so the resource is on par with
ProjectResource and consumers get typed access end-to-end.

Changelog: added
@jhhazelaar
jhhazelaar merged commit dc9adff into main May 20, 2026
18 checks passed
@jhhazelaar
jhhazelaar deleted the f/jh/unit-type-dto branch May 20, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant