youyesyet.routes.rest

Manually maintained routes which handle data transfer to/from the canvasser app.

create-intention-and-visit!

(create-intention-and-visit! request)

Doing visit creation logic server side; request params are expected to include an option_id, an elector_id and an address_id, or an option and a location. If no address_id is provided, we simply create an intention record from the option_id and the locality; if an address_id is provided, we need to check whether the last visit by the current user was to the same address, if so use that as the visit_id, if not create a new visit record.

create-request-and-visit!

(create-request-and-visit! request)

Doing visit creation logic server side; request params are expected to include an issue, an elector_id and an address_id (and also a method_id and method_detail). Ye cannae reasonably create a request without having recorded the visit, so let’s not muck about.

current-visit-id

(current-visit-id request)

Return the id of the current visit by the current user, creating it if necessary.

get-local-data

(get-local-data request)

Get data local to the user of the canvasser app. Expects arguments latitude and longitude, or locality. Returns a block of data for that locality

in-get-local-data

Local data is volatile, because hopefully canvassers are updating it as they work. So cache for only 90 seconds.

last-visit-by-current-user

(last-visit-by-current-user request)

Return the most recent visit by the currently logged in user

rest-routes

TODO: write docs

update-elector-signature!

(update-elector-signature! request)

Set the signature in the params of this request as the signature for the elector whose id is in the params of this request.