Module: IqairAirvisual::Community

Included in:
Client
Defined in:
lib/iqair_airvisual/community.rb

Instance Method Summary collapse

Instance Method Details

#cities(country_name, state_name) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/iqair_airvisual/community.rb', line 14

def cities(country_name, state_name)
  path = 'cities'
  params = {
    country: country_name,
    state: state_name
  }
  authorise_and_send(http_method: :get, path: path, params: params)
end

#city(country_name, state_name, city_name) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/iqair_airvisual/community.rb', line 39

def city(country_name, state_name, city_name)
  path = 'city'
  params = {
    country: country_name,
    state: state_name,
    city: city_name
  }

  authorise_and_send(http_method: :get, path: path, params: params)
end

#countriesObject



3
4
5
6
# File 'lib/iqair_airvisual/community.rb', line 3

def countries
  path = 'countries'
  authorise_and_send(http_method: :get, path: path)
end

#nearest_city(latitude: nil, longitude: nil) ⇒ Object

IP Geo-locate



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/iqair_airvisual/community.rb', line 24

def nearest_city(latitude: nil, longitude: nil)
  if (latitude && !longitude) || (!latitude && longitude)
    raise 'Both latitude and longitude are required if GPS co-ordinates specified.'
  end

  path = 'nearest_city'

  params = {}
  if (latitude && longitude)
    params = { lat: latitude, lon: longitude }
  end

  authorise_and_send(http_method: :get, path: path, params: params)
end

#states(country_name) ⇒ Object



8
9
10
11
12
# File 'lib/iqair_airvisual/community.rb', line 8

def states(country_name)
  path = 'states'
  params = { country: country_name }
  authorise_and_send(http_method: :get, path: path, params: params)
end