// api/session-detail.prg — Format session detail response // ctx: row (JSON of single session row joined with device) FUNCTION Main() LOCAL hRow hRow := hb_jsonDecode(ctx_get("row", "{}")) IF ! HB_ISHASH(hRow) .OR. Empty(hRow) AP_JSONRESPONSE({ "error" => { "code" => "SESSION_NOT_FOUND", "message" => "session not found", "status" => 404 } }, 404) RETURN NIL ENDIF AP_JSONRESPONSE({ ; "sessionId" => fn_HGet(hRow, "session_id"), ; "sessionName" => fn_HGet(hRow, "session_name"), ; "deviceName" => fn_HGet(hRow, "device_name"), ; "deviceAddress" => fn_HGet(hRow, "device_address"), ; "startTime" => fn_HGet(hRow, "start_time"), ; "endTime" => fn_HGet(hRow, "end_time"), ; "recordCount" => fn_HGet(hRow, "record_count"), ; "params" => fn_HGet(hRow, "params"), ; "note" => fn_HGet(hRow, "note"), ; "hwNumber" => fn_HGet(hRow, "hw_number"), ; "serialNumber" => fn_HGet(hRow, "serial_number"), ; "fwVersion" => fn_HGet(hRow, "fw_version"), ; "status" => fn_HGet(hRow, "status") ; }) RETURN NIL FUNCTION session_detail_fn_hget(h, k) IF HB_ISHASH(h) .AND. hb_HHasKey(h, k) ; RETURN h[k] ; ENDIF RETURN ""