Module: OpenWeather::Endpoints::Stations
- Included in:
- Client
- Defined in:
- lib/open_weather/endpoints/stations.rb
Instance Method Summary collapse
- #create_measurements(measurements, options = {}) ⇒ Object
- #delete_station(id) ⇒ Object
- #get_measurements(options) ⇒ Object
- #get_station(id) ⇒ Object
- #list_stations ⇒ Object
- #register_station(options = {}) ⇒ Object
- #update_station(id, options = {}) ⇒ Object
Instance Method Details
#create_measurements(measurements, options = {}) ⇒ Object
33 34 35 36 |
# File 'lib/open_weather/endpoints/stations.rb', line 33 def create_measurements(measurements, = {}) post('3.0/measurements', .merge(body: measurements)) nil end |
#delete_station(id) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/open_weather/endpoints/stations.rb', line 26 def delete_station(id) validate_id(id) delete("3.0/stations/#{id}") nil end |
#get_measurements(options) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/open_weather/endpoints/stations.rb', line 38 def get_measurements() required_keys = %i[station_id type limit from to] missing_keys = required_keys - .keys raise ArgumentError, "Missing params: #{missing_keys.join(', ')}" if missing_keys.any? get('3.0/measurements', ).map { |m| OpenWeather::Models::Stations::Measurement.new(m) } end |
#get_station(id) ⇒ Object
14 15 16 17 18 |
# File 'lib/open_weather/endpoints/stations.rb', line 14 def get_station(id) validate_id(id) OpenWeather::Models::Station.new(get("3.0/stations/#{id}")) end |
#list_stations ⇒ Object
10 11 12 |
# File 'lib/open_weather/endpoints/stations.rb', line 10 def list_stations get('3.0/stations').map { |data| OpenWeather::Models::Station.new(data) } end |
#register_station(options = {}) ⇒ Object
6 7 8 |
# File 'lib/open_weather/endpoints/stations.rb', line 6 def register_station( = {}) OpenWeather::Models::Station.new(post('3.0/stations', )) end |
#update_station(id, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/open_weather/endpoints/stations.rb', line 20 def update_station(id, = {}) validate_id(id) OpenWeather::Models::Station.new(put("3.0/stations/#{id}", )) end |