class ArseniysWeatherApp::Requests
Public Class Methods
ip_addr()
click to toggle source
# 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)
click to toggle source
# 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