fix: decode actual API response format #29
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "schwifty/fix-api-response-decoding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Every API call in the beacon app was failing with "Failed to load businesses" (and similar errors for other endpoints).
Root Cause
The iOS
APIResponse<T>generic decoder expected{Success, Message, Data}keys, but the actual Payfrit API returns{OK, ERROR, BUSINESSES}(flat keys, no nestedData). SinceSuccesswas never present, the decoder defaulted tofalseand threw errors.Additionally:
Businessmodel mappedidto"ID"but API returns"BusinessID"Businessmodel mappednameto"BusinessName"but API returns"Name"ServicePointmodel had the sameIDvsServicePointIDmismatchFix
APIResponse<T>with endpoint-specific response structs that match the actual API formatBusinessmodel to decode bothBusinessID/IDandName/BusinessNameServicePointmodel to decode bothServicePointID/IDTest Plan
The API returns {OK: true, BUSINESSES: [...]} but the iOS client was decoding {Success: true, Data: [...]} which never matched — causing "Failed to load businesses" on every call. Also fixes Business model (BusinessID/Name vs ID/BusinessName) and ServicePoint model (ServicePointID vs ID). All response decoders now match the real API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>