Module: Reach::API::Game

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

Instance Method Summary collapse

Instance Method Details

#get_current_challenges(gamertag = nil) ⇒ Object

Public: Fetches current challenges

gamertag - optional gamertag to get

challenge progress for

Returns a hash



31
32
33
34
35
36
37
38
39
40
# File 'lib/reach/api/game.rb', line 31

def get_current_challenges(gamertag = nil)
  if gamertag
    gamertag = gamertag.gsub(' ', '%20')
    uri = ENDPOINT + "game/challenges/#{key}/#{gamertag}"
  else
    uri = ENDPOINT + "game/challenges/#{key}"
  end
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end

#get_game_details(id) ⇒ Object

Public: Fetches detailed game information

id - the ID of the game to get details for

Returns a hash



19
20
21
22
23
# File 'lib/reach/api/game.rb', line 19

def get_game_details(id)
  uri = ENDPOINT + "game/details/#{key}/#{id}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end

#get_game_metadataObject

Public: Fetches metadata dictionaries

Returns a hash



8
9
10
11
12
# File 'lib/reach/api/game.rb', line 8

def 
  uri = ENDPOINT + "game/metadata/#{key}"
  data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)
  Reach::Helper::convert_keys(data)
end