Module: Reach::API::Player

Included in:
Reach::API
Defined in:
lib/reach/api/player.rb

Instance Method Summary collapse

Instance Method Details

#get_game_history(gamertag, variant = "Unknown", page = 0) ⇒ Object

Public: Fetches a player’s list of games in reverse chronological order

gamertag - player to fetch game history for variant - which game type to look for (“Unknown” returns all) page - which page of results to get (pages of 25)

Returns a hash



13
14
15
16
17
18
# File 'lib/reach/api/player.rb', line 13

def get_game_history(gamertag, variant = "Unknown", page = 0)
  gamertag = gamertag.gsub(' ', '%20')
  uri = ENDPOINT + "player/gamehistory/#{key}/#{gamertag}/#{variant}/#{page}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end

#get_player_details_with_no_stats(gamertag) ⇒ Object

Public: Fetches basic player information

gamertag - player to get information about

Returns a hash



51
52
53
54
55
56
# File 'lib/reach/api/player.rb', line 51

def get_player_details_with_no_stats(gamertag)
  gamertag = gamertag.gsub(' ', '%20')
  uri = ENDPOINT + "player/details/nostats/#{key}/#{gamertag}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end

#get_player_details_with_stats_by_map(gamertag) ⇒ Object

Public: Fetches detailed player info, sorted by map

gamertag - player to get information about

Returns a hash



26
27
28
29
30
31
# File 'lib/reach/api/player.rb', line 26

def get_player_details_with_stats_by_map(gamertag)
  gamertag = gamertag.gsub(' ', '%20')
  uri = ENDPOINT + "player/details/bymap/#{key}/#{gamertag}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end

#get_player_details_with_stats_by_playlist(gamertag) ⇒ Object

Public: Fetches detailed player info, sorted by playlist

gamertag - player to get information about

Returns a hash



39
40
41
42
43
44
# File 'lib/reach/api/player.rb', line 39

def get_player_details_with_stats_by_playlist(gamertag)
  gamertag = gamertag.gsub(' ', '%20')
  uri = ENDPOINT + "player/details/byplaylist/#{key}/#{gamertag}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end