Class: Tenkit::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tenkit/client.rb

Constant Summary collapse

DATA_SETS =
{
  current_weather: 'currentWeather',
  forecast_daily: 'forecastDaily',
  forecast_hourly: 'forecastHourly',
  trend_comparison: 'trendComparison',
  weather_alerts: 'weatherAlerts',
  forecast_next_hour: 'forecastNextHour'
}.freeze

Instance Method Summary collapse

Instance Method Details

#availability(lat, lon, **options) ⇒ Object



22
23
24
25
# File 'lib/tenkit/client.rb', line 22

def availability(lat, lon, **options)
  options[:country] ||= 'US'
  get("/availability/#{lat}/#{lon}?country=#{options[:country]}")
end

#weather(lat, lon, **options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/tenkit/client.rb', line 27

def weather(lat, lon, **options)
  options[:data_sets] ||= [:current_weather]
  options[:language] ||= 'en'

  path_root = "/weather/#{options[:language]}/#{lat}/#{lon}?dataSets="
  path = path_root + options[:data_sets].map { |ds| DATA_SETS[ds] }.compact.join(',')

  response = get(path)
  WeatherResponse.new(response)
end

#weather_alert(id, **options) ⇒ Object



38
39
40
41
42
43
# File 'lib/tenkit/client.rb', line 38

def weather_alert(id, **options)
  options[:language] ||= 'en'
  puts 'TODO: implement weather alert endpoint'
  puts language
  puts id
end