Skip to content

Instantly share code, notes, and snippets.

@epaulet
Last active October 10, 2019 18:18
Show Gist options
  • Save epaulet/ef15fa77195b6fc8aadd4dd1d2481870 to your computer and use it in GitHub Desktop.
Save epaulet/ef15fa77195b6fc8aadd4dd1d2481870 to your computer and use it in GitHub Desktop.
Find nearby EScreen location
request_id = 36630 # replace this with the real response ID
payload = Request.find(request_id).payload
appointment = Appointment.find_by(external_donor_id: payload[:external_donor_id])
location_query = OpenStruct.new(
account_id: appointment.account_id,
exam_slugs: appointment.exam_slugs,
zipcode: payload[:collection_site_zipcode],
)
location_hashes = LocationsService.get_locations_as_hashes(location_query)
## Browse through location_hashes and select a replacement location. Using the first location as an example.
location_hash = location_hashes.first
duped_payload = payload.dup
duped_payload[:collection_site_id] = location_hash[:site_id]
duped_payload[:collection_site_zipcode] = location_hash[:zipcode]
response.payload = duped_payload
response.save # probably not necessary, but doesn't hurt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment