Module: Barometer::Query::Service::ToWeatherId

Defined in:
lib/barometer/query/services/to_weather_id.rb

Class Method Summary collapse

Class Method Details

._parse_content(payload) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/barometer/query/services/to_weather_id.rb', line 15

def self._parse_content(payload)
  if payload.fetch('loc').is_a? Array
    payload.fetch('loc', 0, '@id')
  else
    payload.fetch('loc', '@id')
  end
end

.call(query) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/barometer/query/services/to_weather_id.rb', line 7

def self.call(query)
  converted_query = query.get_conversion(:geocode, :unknown)
  return unless converted_query

  api = WeatherId::Api.new(converted_query)
  _parse_content(api.get)
end