class XboxLeaders::Api
Attributes
api_url[R]
timeout[RW]
Public Class Methods
new(api_url, timeout = 6)
click to toggle source
# File lib/xbox_leaders/api.rb, line 9 def initialize(api_url, timeout = 6) @timeout = timeout @api_url = api_url.chomp('/') end
Public Instance Methods
fetch_achievements(gamertag, game_id)
click to toggle source
# File lib/xbox_leaders/api.rb, line 14 def fetch_achievements(gamertag, game_id) get('/achievements', gamertag: gamertag, gameid: game_id) end
fetch_friends(gamertag)
click to toggle source
# File lib/xbox_leaders/api.rb, line 18 def fetch_friends(gamertag) get('/friends', gamertag: gamertag) end
fetch_games(gamertag)
click to toggle source
# File lib/xbox_leaders/api.rb, line 22 def fetch_games(gamertag) get('/games', gamertag: gamertag) end
fetch_profile(gamertag)
click to toggle source
# File lib/xbox_leaders/api.rb, line 26 def fetch_profile(gamertag) get('/profile', gamertag: gamertag) end
Private Instance Methods
get(path, query={})
click to toggle source
# File lib/xbox_leaders/api.rb, line 32 def get(path, query={}) response = self.class.get("#{api_url}#{path}.json", timeout: timeout, query: query).to_hash if response['status'] == 'error' raise ArgumentError, "#{response['data']['code']}: #{response['data']['message']}" end response['data'] end