Module: Waqi::Resource::CityFeed

Included in:
Client
Defined in:
lib/waqi/resources/city_feed.rb

Overview

For more information, visit aqicn.org/json-api/doc

Instance Method Summary collapse

Instance Method Details

#get_city_feed(city) ⇒ Hash, string

@pathparams:

Parameters:

  • `city` (String)
    • Name of the city (eg beijing), or id (eg @7397)

Returns:

  • (Hash)

    data - The station data.

  • (string)

    status - The status code. can be ok or error.



16
17
18
# File 'lib/waqi/resources/city_feed.rb', line 16

def get_city_feed(city)
    get("/feed/#{city}")
end

#get_geo_feed(lat:, lng:) ⇒ Hash, string

Get gelocalized feed based on lat/lng based

@pathparams:

Parameters:

  • `lat` (Integer)
    • latitude

  • `lng` (Integer)
    • longitude

Returns:

  • (Hash)

    data - The real-time air quality infomrmation..

  • (string)

    status - The status code. can be ok or error.



28
29
30
# File 'lib/waqi/resources/city_feed.rb', line 28

def get_geo_feed(lat:, lng:)
    get("/feed/geo:#{lat};#{lng}")
end

#get_geo_feed_by_ipHash, string

Get gelocalized feed based on user’s ip address

Returns:

  • (Hash)

    data - The real-time air quality infomrmation..

  • (string)

    status - The status code. can be ok or error.



36
37
38
# File 'lib/waqi/resources/city_feed.rb', line 36

def get_geo_feed_by_ip
    get("/feed/here")
end

#map_station(latlng:, networks: 'all') ⇒ Hash, string

Get gelocalized feed based on user’s ip address

@queryParams:

Parameters:

  • latlng (Array)
    • map bounds in the format [lat1,lng1,lat2,lng2,…]

  • networks (string) (defaults to: 'all')
    • air quality networks list. possible options are ‘all’, ‘official’ (or ‘hourly’) and ‘citizen’ (or ‘airnet’).

Returns:

  • (Hash)

    data - The real-time air quality infomrmation.

  • (string)

    status - The status code. can be ok or error.

Raises:



48
49
50
51
52
53
54
# File 'lib/waqi/resources/city_feed.rb', line 48

def map_station(latlng:, networks: 'all')
    raise Waqi::Errors::ArgumentError.new("latlng params cannot be empty") if latlng.empty?

    formattedLatLng = latlng.join(',')

    get("/map/bounds", params: { latlng: formattedLatLng, networks: networks })
end

#search_station(name) ⇒ Hash, string

Search station by name

@queryParams:

Returns:

  • (Hash)

    data - The list of station result.

  • (string)

    status - The status code. can be ok or error.



63
64
65
# File 'lib/waqi/resources/city_feed.rb', line 63

def search_station(name)
    get("/search/", params: { keyword: name })
end