Class: Dscf::Marketplace::LocationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dscf/marketplace/locations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#bypass_permissions_for_demo?, #pundit_user

Instance Method Details

#get_locationObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/dscf/marketplace/locations_controller.rb', line 4

def get_location
  place_name = params[:name]

  if place_name.blank?
    render_error(
      "locations.errors.name_required",
      status: :unprocessable_entity
    )
    return
  end

  service = GebetaService.new
  locations = service.geocode(place_name)

  render_success(data: locations, status: :ok)
rescue => e
  render_error(
    "locations.errors.geocoding_failed",
    errors: [ e.message ],
    status: :unprocessable_entity
  )
end