class Rasp::Yandex::Client
Constants
- URL
Public Class Methods
new(api_key = nil, api_version = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 12 def initialize(api_key = nil, api_version = nil) @api_key = api_key || ENV["RASP_YANDEX_API_KEY"] @api_version = "3.0" || ENV["RASP_YANDEX_API_VERSION"] end
Public Instance Methods
all_stations(default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 18 def all_stations(default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/stations_list/?apikey=#{@api_key}", default_params end
copyright_yandex_rasp(format)
click to toggle source
# File lib/rasp/yandex.rb, line 81 def copyright_yandex_rasp(format) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "v#{@api_key}/copyright/?apikey=#{@api_key}&format=#{format}" end
information_about_carrier(code, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 72 def information_about_carrier(code, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/carrier/?apikey=#{@api_key}&code=#{code}", default_params end
near_city(latitude, longitude, distance = nil, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 54 def near_city(latitude, longitude, distance = nil, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/nearest_settlement/?apikey=#{@api_key}&lat=#{latitude}&lng=#{longitude}&distance=#{distance}", default_params end
near_stations(latitude, longitude, distance, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 45 def near_stations(latitude, longitude, distance, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/nearest_stations/?apikey=#{@api_key}&lat=#{latitude}&lng=#{longitude}&distance=#{distance}", default_params end
stations_of_route(uid, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 63 def stations_of_route(uid, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/thread/?apikey=#{@api_key}&uid=#{uid}", default_params end
timetable_at_station(station, date = nil, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 36 def timetable_at_station(station, date = nil, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/schedule/?apikey=#{@api_key}&station=#{station}&date=#{date}", default_params end
timetable_between_stations(from, to, date = nil, default_params = nil)
click to toggle source
# File lib/rasp/yandex.rb, line 27 def timetable_between_stations(from, to, date = nil, default_params = nil) conn = Faraday.new(url: URL) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end conn.get "/v#{@api_version}/search/?apikey=#{@api_key}&from=#{from}&to=#{to}&date=#{date}", default_params end