From 400df7624f730a8fe13a8ba143b67227dffd0ee4 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Wed, 28 Jan 2026 00:12:18 -0800 Subject: [PATCH] Simplify address API - delivery addresses only - Remove TypeID/Label from list response - Hardcode TypeID=2 (delivery) in add endpoint - Filter to personal addresses only (BusinessID=0 or NULL) - Just IsDefault flag, no home/work labels Co-Authored-By: Claude Opus 4.5 --- api/addresses/add.cfm | 9 +++++---- api/addresses/list.cfm | 11 +++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/api/addresses/add.cfm b/api/addresses/add.cfm index 0903699..b6ac483 100644 --- a/api/addresses/add.cfm +++ b/api/addresses/add.cfm @@ -31,7 +31,6 @@ try { data = readJsonBody(); // Required fields - typeId = val(data.TypeID ?: 0); line1 = trim(data.Line1 ?: ""); city = trim(data.City ?: ""); stateId = val(data.StateID ?: 0); @@ -39,15 +38,17 @@ try { // Optional fields line2 = trim(data.Line2 ?: ""); - label = trim(data.Label ?: ""); setAsDefault = (data.SetAsDefault ?: false) == true; + // Hardcoded to delivery address type + typeId = 2; + // Validation - if (typeId <= 0 || len(line1) == 0 || len(city) == 0 || stateId <= 0 || len(zipCode) == 0) { + if (len(line1) == 0 || len(city) == 0 || stateId <= 0 || len(zipCode) == 0) { writeOutput(serializeJSON({ "OK": false, "ERROR": "missing_fields", - "MESSAGE": "TypeID, Line1, City, StateID, and ZIPCode are required" + "MESSAGE": "Line1, City, StateID, and ZIPCode are required" })); abort; } diff --git a/api/addresses/list.cfm b/api/addresses/list.cfm index 1fe3075..f4176c4 100644 --- a/api/addresses/list.cfm +++ b/api/addresses/list.cfm @@ -46,12 +46,10 @@ if (userId <= 0) { } try { - // Get user's addresses + // Get user's delivery addresses qAddresses = queryExecute(" SELECT a.AddressID, - a.AddressLabel, - a.AddressTypeID, a.AddressIsDefaultDelivery, a.AddressLine1, a.AddressLine2, @@ -64,6 +62,7 @@ try { LEFT JOIN tt_States s ON a.AddressStateID = s.tt_StateID WHERE a.AddressUserID = :userId AND (a.AddressBusinessID = 0 OR a.AddressBusinessID IS NULL) + AND a.AddressTypeID = 2 AND a.AddressIsDeleted = 0 ORDER BY a.AddressIsDefaultDelivery DESC, a.AddressID DESC ", { @@ -74,15 +73,12 @@ try { for (row in qAddresses) { arrayAppend(addresses, { "AddressID": row.AddressID, - "TypeID": val(row.AddressTypeID), - "Label": len(row.AddressLabel) ? row.AddressLabel : "Address", "IsDefault": row.AddressIsDefaultDelivery == 1, "Line1": row.AddressLine1, "Line2": row.AddressLine2 ?: "", "City": row.AddressCity, "StateID": row.AddressStateID, "StateAbbr": row.StateAbbreviation ?: "", - "StateName": row.StateName ?: "", "ZIPCode": row.AddressZIPCode, "DisplayText": row.AddressLine1 & (len(row.AddressLine2) ? ", " & row.AddressLine2 : "") & ", " & row.AddressCity & ", " & (row.StateAbbreviation ?: "") & " " & row.AddressZIPCode }); @@ -97,8 +93,7 @@ try { apiAbort({ "OK": false, "ERROR": "server_error", - "MESSAGE": e.message, - "LINE": e.tagContext[1].line ?: 0 + "MESSAGE": e.message }); }