class ClashRoyale::Client

Constants

BASE_URL

Attributes

api_key[RW]

Public Class Methods

new(options = {}) { |self| ... } click to toggle source
# File lib/clash_royale/client.rb, line 11
def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
end

Public Instance Methods

cards() click to toggle source
# File lib/clash_royale/client.rb, line 86
def cards
  res = http_request('/cards')
  res.body
end
clan_currentwar(tag) click to toggle source
# File lib/clash_royale/client.rb, line 51
def clan_currentwar(tag)
  res = http_request('/clans/' + tag + '/currentwar')
  res.body
end
clan_information(tag) click to toggle source
# File lib/clash_royale/client.rb, line 36
def clan_information(tag)
  res = http_request('/clans/' + tag)
  res.body
end
clan_members(tag, options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 41
def clan_members(tag, options = {})
  res = http_request('/clans/' + tag + '/members', options)
  res.body
end
clan_warlog(tag , options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 46
def clan_warlog(tag , options = {})
  res = http_request('/clans/' + tag + '/warlog', options)
  res.body
end
global_tournaments() click to toggle source
# File lib/clash_royale/client.rb, line 81
def global_tournaments
  res = http_request('/globaltournaments')
  res.body
end
http_request(path, options={}) click to toggle source
# File lib/clash_royale/client.rb, line 18
def http_request(path, options={})
  url = URI.parse(BASE_URL + path)
  url.query = URI.encode_www_form(options)
  req = Net::HTTP::Get.new url
  req['authorization'] = "Bearer #{api_key}"
  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  res = http.request(req)
  return res
end
location_clan_ranking(tag, options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 101
def location_clan_ranking(tag, options = {})
  res = http_request('/locations/' + tag + '/rankings/clans', options)
  res.body
end
location_clanwar_ranking(tag, options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 111
def location_clanwar_ranking(tag, options = {})
  res = http_request('/locations/' + tag + '/rankings/clanwars', options)
  res.body
end
location_information(tag) click to toggle source
# File lib/clash_royale/client.rb, line 96
def location_information(tag)
  res = http_request('/locations' + tag)
  res.body
end
location_player_ranking(tag, options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 106
def location_player_ranking(tag, options = {})
  res = http_request('/locations/' + tag + '/rankings/players', options)
  res.body
end
locations() click to toggle source
# File lib/clash_royale/client.rb, line 91
def locations
  res = http_request('/locations')
  res.body
end
player(tag) click to toggle source
# File lib/clash_royale/client.rb, line 56
def player(tag)
  res = http_request('/players/' + tag)
  res.body
end
player_battlelog(tag) click to toggle source
# File lib/clash_royale/client.rb, line 66
def player_battlelog(tag)
  res = http_request('/players/' + tag + '/battlelog')
  res.body
end
player_upcomingchests(tag) click to toggle source
# File lib/clash_royale/client.rb, line 61
def player_upcomingchests(tag)
  res = http_request('/players/' + tag + '/upcomingchests')
  res.body
end
search_clans(options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 31
def search_clans(options = {})
  res = http_request('/clans', options)
  res.body
end
search_tournaments(options = {}) click to toggle source
# File lib/clash_royale/client.rb, line 71
def search_tournaments(options = {})
  res = http_request('/tournaments', options)
  res.body
end
tournament_information(tag) click to toggle source
# File lib/clash_royale/client.rb, line 76
def tournament_information(tag)
  res = http_request('/tournaments' + tag)
  res.body
end