Extract business info from Toast __OO_STATE__ JSON

Look for Restaurant: keys and extract name, location (address, city,
state, zip), phone, and brandColor for the wizard business info step.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-13 09:12:24 -08:00
parent 157749060e
commit 5c49054e78

View file

@ -172,7 +172,7 @@
</cfloop>
</cfif>
<!--- Also try to extract from __OO_STATE__ for images --->
<!--- Also try to extract from __OO_STATE__ for images and business info --->
<cfif findNoCase("window.__OO_STATE__", pageHtml)>
<cfset ooStateMatch = reMatchNoCase("window\.__OO_STATE__\s*=\s*(\{.*?\});\s*window\.", pageHtml)>
<cfif arrayLen(ooStateMatch)>
@ -183,6 +183,35 @@
<!--- Build name -> image URL map from OO_STATE --->
<cfset imageMap = structNew()>
<cfloop collection="#ooState#" item="key">
<!--- Extract restaurant/business info --->
<cfif left(key, 11) EQ "Restaurant:">
<cfset restaurant = ooState[key]>
<cfif structKeyExists(restaurant, "name")>
<cfset toastBusiness["name"] = restaurant.name>
</cfif>
<cfif structKeyExists(restaurant, "location")>
<cfset loc = restaurant.location>
<cfif structKeyExists(loc, "address1")>
<cfset toastBusiness["addressLine1"] = loc.address1>
</cfif>
<cfif structKeyExists(loc, "city")>
<cfset toastBusiness["city"] = loc.city>
</cfif>
<cfif structKeyExists(loc, "state")>
<cfset toastBusiness["state"] = loc.state>
</cfif>
<cfif structKeyExists(loc, "zipCode")>
<cfset toastBusiness["zip"] = loc.zipCode>
</cfif>
<cfif structKeyExists(loc, "phone")>
<cfset toastBusiness["phone"] = loc.phone>
</cfif>
</cfif>
<cfif structKeyExists(restaurant, "brandColor")>
<cfset toastBusiness["brandColor"] = replace(restaurant.brandColor, "##", "")>
</cfif>
</cfif>
<!--- Extract menu items and images --->
<cfif left(key, 5) EQ "Menu:">
<cfset menu = ooState[key]>
<cfif structKeyExists(menu, "groups") AND isArray(menu.groups)>
@ -214,6 +243,9 @@
</cfif>
</cfloop>
<cfset arrayAppend(response.steps, "Matched " & imagesMatched & " images from __OO_STATE__")>
<cfif structCount(toastBusiness) GT 0>
<cfset arrayAppend(response.steps, "Extracted business info: " & structKeyList(toastBusiness))>
</cfif>
<cfcatch></cfcatch>
</cftry>
</cfif>