                                             :status "OK"
                                             :version "4"})}))
       (ring-response {:status 422
-                      :body "Provide valid projectId and propertyCode."}))))
+                      :body "Provide valid entityId and timestamp."}))))
 
 (defn resource-exists? [querier ctx]
   (let [{{{:keys [entity-id profile-id]} :route-params} :request} ctx

                ))
      false)))

(defn index-post! [querier commander ctx]
  (let [{:keys [request body]} ctx
        entity-id     (-> request :route-params :entity-id)
        [username _]  (sec/get-username-password request querier)
        user-id       (-> (hecuba/items querier :user [[= :username username]]) first :id)]

    (when-not (empty? (first (hecuba/items querier :entity [[= :id entity-id]])))
      (let [profile   (-> body
                          (assoc :user-id user-id)
                          (update-in [:profile-data] json/encode)
                          ;; here goes the list of "stuff" associated with profiles
                          (update-stringified-lists [:airflow_measurements
                                                    :chps :conservatories
                                                    :door_sets
                                                    :extensions
                                                    :floors
                                                    :heat_pumps
                                                    :heating_systems
                                                    :hot_water_systems
                                                    :low_energy_lights
                                                    :photovoltaics
                                                    :roof_rooms
                                                    :roofs
                                                    :small_hydros
                                                    :solar_thermals
                                                    :storeys
                                                    :thermal-images
                                                    :walls
                                                    :wind_turbines
                                                    :window_sets]))
            profile-id (hecuba/upsert! commander :profile profile)]
        {:profile-id profile-id}))))

(defn index-handle-ok [ctx]
  (let [{items ::items

  :authorized? (authorized? querier :profile)
  :exists? (partial index-exists? querier)
  :malformed? index-malformed?
  :post! (partial index-post! commander querier)
  :handle-ok (partial index-handle-ok)
  :handle-created (partial index-handle-created handlers))

