Class: ArseniysWeatherApp::Requests

Inherits:
Object
  • Object
show all
Defined in:
lib/ArseniysWeatherApp.rb

Class Method Summary collapse

Class Method Details

.ip_addrObject



23
24
25
26
27
# File 'lib/ArseniysWeatherApp.rb', line 23

def self.ip_addr
  url = "https://obscure-temple-73986.herokuapp.com/"
  response = Faraday.get(url, { "get_ip" => "yes" })
  JSON.parse(response.body)["ip_addr"]
end

.weather_json(location: [59.9573887, 30.3430287], lang: "ru_RU", forecasts: 7, hours: false, extra: false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ArseniysWeatherApp.rb', line 11

def self.weather_json(location: [59.9573887, 30.3430287],
                      lang: "ru_RU", forecasts: 7,
                      hours: false, extra: false)
  url = "https://api.weather.yandex.ru/v2/forecast"
  params = { "lat" => location[0], "lon" => location[1],
             "lang" => lang, "limit" => forecasts,
             "hours" => hours, "extra" => extra }
  header = { "X-Yandex-API-Key" => "01cafac0-8fd8-48ca-956a-f442580428a0" }
  response = Faraday.get(url, params, header)
  JSON.parse(response.body)
end