class Lol::StaticRequest

Public Instance Methods

api_base_path() click to toggle source

@!visibility private

# File lib/lol/static_request.rb, line 4
def api_base_path
  "/lol/static-data/#{self.class.api_version}"
end
get(endpoint, id=nil, params={}) click to toggle source
# File lib/lol/static_request.rb, line 48
def get(endpoint, id=nil, params={})
  return perform_request(api_url("versions")) if endpoint == "versions"
  id ? find(endpoint, id, params) : all(endpoint, params)
end
language_strings(params={}) click to toggle source
# File lib/lol/static_request.rb, line 20
def language_strings params={}
  perform_request(api_url "language-strings", params).to_hash["data"]
end
languages() click to toggle source
# File lib/lol/static_request.rb, line 24
def languages
  perform_request api_url "languages"
end
maps() click to toggle source
# File lib/lol/static_request.rb, line 28
def maps
  Proxy.new self, "maps"
end
profile_icons(params={}) click to toggle source
# File lib/lol/static_request.rb, line 32
def profile_icons params={}
  all "profile_icons", params
end
realms() click to toggle source
# File lib/lol/static_request.rb, line 36
def realms
  Proxy.new self, "realms"
end
reforged_runes() click to toggle source
# File lib/lol/static_request.rb, line 40
def reforged_runes
  Proxy.new self, "reforged_runes"
end
versions() click to toggle source
# File lib/lol/static_request.rb, line 44
def versions
  Proxy.new self, "versions"
end

Private Instance Methods

all(endpoint, params={}) click to toggle source
# File lib/lol/static_request.rb, line 60
def all(endpoint, params={})
  if %w(realms).include? endpoint
    OpenStruct.new perform_request(api_url(endpoint.dasherize, params)).to_hash
  elsif %w(reforged_runes).include? endpoint
    perform_request(api_url(endpoint.dasherize, params)).map do |hash|
      OpenStruct.new(hash)
    end
  else
    perform_request(api_url(endpoint.dasherize, params))["data"].map do |id, values|
      OpenStruct.new(values.merge(id: values["id"] || id))
    end
  end
end
find(endpoint, id, params={}) click to toggle source
# File lib/lol/static_request.rb, line 55
def find(endpoint, id, params={})
  OpenStruct.new \
    perform_request(api_url("#{endpoint.dasherize}/#{id}", params)).to_hash
end