Class: SpreeCmCommissioner::GooglePlacesFetcher

Inherits:
BaseInteractor show all
Defined in:
app/interactors/spree_cm_commissioner/google_places_fetcher.rb

Instance Method Summary collapse

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/interactors/spree_cm_commissioner/google_places_fetcher.rb', line 5

def call
  json_response = fetch_google_place_by_name

  context.google_places = json_response['results'].map do |json|
    SpreeCmCommissioner::Place.new(
      reference: json['reference'],
      types: json['types'].blank? ? '' : json['types'][0],
      name: json['name'],
      vicinity: json['vicinity'],
      formatted_address: json['formatted_address'],
      lat: json['geometry']['location']['lat'],
      lon: json['geometry']['location']['lng'],
      icon: json['icon'],
      rating: json['rating']
    )
  end
end