<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">

<cfcontent type="application/json; charset=utf-8" reset="true">
<cfheader name="Cache-Control" value="no-store">

<cfscript>
function apiAbort(obj) {
  writeOutput(serializeJSON(obj));
  abort;
}
</cfscript>

<!--- No auth required - this is public for beacon scanning before login --->

<cfquery name="q" datasource="payfrit">
  SELECT
    BeaconID,
    BeaconUUID
  FROM Beacons
  WHERE BeaconIsActive = 1
  ORDER BY BeaconID
</cfquery>

<cfset items = []>
<cfloop query="q">
  <cfset arrayAppend(items, {
    "BeaconID" = q.BeaconID,
    "BeaconUUID" = q.BeaconUUID
  })>
</cfloop>

<cfoutput>#serializeJSON({
  "OK" = true,
  "ERROR" = "",
  "ITEMS" = items
})#</cfoutput>
