Class: Halo::Reach::API
- Inherits:
-
Object
- Object
- Halo::Reach::API
- Includes:
- HTTParty
- Defined in:
- lib/version.rb,
lib/halo-reach-api.rb
Constant Summary collapse
- VERSION =
'1.0.5'.freeze
- API_URL =
'http://www.bungie.net/api/reach/reachapijson.svc/'
- DEFAULT_HEADERS =
{ 'User-Agent' => "Halo:Reach API gem #{VERSION}" }
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#debug(location = $stderr) ⇒ Object
Set a new location for debug output.
-
#get_current_challenges ⇒ Object
The “GetCurrentChallenges” method returns the currently active weekly and daily challenges.
-
#get_file_details(file_id) ⇒ Object
The “GetFileDetails” method returns the file details for a single file.
-
#get_game_details(game_id) ⇒ Object
The “GetGameDetails” method returns detailed information for a given game ID.
-
#get_game_history(gamertag, variant_class = 'Unknown', page = 0) ⇒ Object
The “GetGameHistory” method returns a players list of games, in chronological reverse over.
-
#get_game_metadata ⇒ Object
The “GetGameMetadata” method returns several dictionaries so that resource ids can be translated into their more detailed versions.
-
#get_player_details_with_no_stats(gamertag) ⇒ Object
The “GetPlayerDetailsWithNoStats” method returns basic information about a player.
-
#get_player_details_with_stats_by_map(gamertag) ⇒ Object
Undocumented.
-
#get_player_details_with_stats_by_playlist(gamertag) ⇒ Object
The “GetPlayerDetailsWithStatsByPlaylist” method Returns detailed aggregate information on a player, including arena information.
-
#get_player_file_set_files(gamertag, file_set_id) ⇒ Object
The “GetPlayerFileSetFiles” method returns a listing of files in the specified file set.
-
#get_player_file_sets(gamertag) ⇒ Object
The “GetPlayerFileSets” method returns a listing of file sets created by the player.
-
#get_player_file_share(gamertag) ⇒ Object
The “GetPlayerFileShare” method returns a listing of files in a player’s file share.
-
#get_player_recent_screenshots(gamertag) ⇒ Object
The “GetPlayerRecentScreenshots” method returns a list of the player’s recent screenshots.
-
#get_player_rendered_videos(gamertag, page = 0) ⇒ Object
The “GetPlayerRenderedVideos” method returns a listing of rendered videos created by a player.
-
#initialize(token, api_url = API_URL) ⇒ API
constructor
Create a new Halo::Reach::API class with your token.
-
#reach_file_search(file_category, map_filter, engine_filter, date_filter, sort_filter, tags, page = 0) ⇒ Object
The “ReachFileSearch” method returns a listing of files matching the specified criteria.
-
#set_http_headers(http_headers = {}) ⇒ Object
Set new HTTP headers.
-
#set_timeout(timeout) ⇒ Object
Set a new default HTTP timeout.
Constructor Details
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
21 22 23 |
# File 'lib/halo-reach-api.rb', line 21 def api_url @api_url end |
#token ⇒ Object
Returns the value of attribute token.
22 23 24 |
# File 'lib/halo-reach-api.rb', line 22 def token @token end |
Instance Method Details
#debug(location = $stderr) ⇒ Object
Set a new location for debug output
31 32 33 |
# File 'lib/halo-reach-api.rb', line 31 def debug(location = $stderr) self.class.debug_output(location) end |
#get_current_challenges ⇒ Object
The “GetCurrentChallenges” method returns the currently active weekly and daily challenges.
58 59 60 61 |
# File 'lib/halo-reach-api.rb', line 58 def get_current_challenges current_challenges_uri = "game/challenges/#{@token}" self.class.get(@api_url + current_challenges_uri) end |
#get_file_details(file_id) ⇒ Object
The “GetFileDetails” method returns the file details for a single file.
115 116 117 118 |
# File 'lib/halo-reach-api.rb', line 115 def get_file_details(file_id) get_file_details_uri = "file/details/#{@token}/#{file_id}" self.class.get(@api_url + get_file_details_uri) end |
#get_game_details(game_id) ⇒ Object
The “GetGameDetails” method returns detailed information for a given game ID.
66 67 68 69 |
# File 'lib/halo-reach-api.rb', line 66 def get_game_details(game_id) get_game_details_uri = "game/details/#{@token}/#{game_id}" self.class.get(@api_url + get_game_details_uri) end |
#get_game_history(gamertag, variant_class = 'Unknown', page = 0) ⇒ Object
The “GetGameHistory” method returns a players list of games, in chronological reverse over. Returned games is paginated, and you can specific which game variant, (Invasion, Campaign, for example), or Unknown for all games.
75 76 77 78 |
# File 'lib/halo-reach-api.rb', line 75 def get_game_history(gamertag, variant_class = 'Unknown', page = 0) get_game_history_uri = "player/gamehistory/#{@token}/#{msftize(gamertag)}/#{variant_class}/#{page}" self.class.get(@api_url + get_game_history_uri) end |
#get_game_metadata ⇒ Object
The “GetGameMetadata” method returns several dictionaries so that resource ids can be translated into their more detailed versions. For example, this method can be used to associate a medal resource id with its representative medal (say, a killing spree).
50 51 52 53 |
# File 'lib/halo-reach-api.rb', line 50 def = "game/metadata/#{@token}" self.class.get(@api_url + ) end |
#get_player_details_with_no_stats(gamertag) ⇒ Object
The “GetPlayerDetailsWithNoStats” method returns basic information about a player.
99 100 101 102 |
# File 'lib/halo-reach-api.rb', line 99 def get_player_details_with_no_stats(gamertag) get_player_details_with_no_stats_uri = "player/details/nostats/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_details_with_no_stats_uri) end |
#get_player_details_with_stats_by_map(gamertag) ⇒ Object
83 84 85 86 |
# File 'lib/halo-reach-api.rb', line 83 def get_player_details_with_stats_by_map(gamertag) get_player_details_with_stats_by_map_uri = "player/details/bymap/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_details_with_stats_by_map_uri) end |
#get_player_details_with_stats_by_playlist(gamertag) ⇒ Object
The “GetPlayerDetailsWithStatsByPlaylist” method Returns detailed aggregate information on a player, including arena information.
www.haloreachapi.net/wiki/GetPlayerDetailsWithStatsByPlaylist
91 92 93 94 |
# File 'lib/halo-reach-api.rb', line 91 def get_player_details_with_stats_by_playlist(gamertag) get_player_details_with_stats_by_playlist_uri = "player/details/byplaylist/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_details_with_stats_by_playlist_uri) end |
#get_player_file_set_files(gamertag, file_set_id) ⇒ Object
The “GetPlayerFileSetFiles” method returns a listing of files in the specified file set.
139 140 141 142 |
# File 'lib/halo-reach-api.rb', line 139 def get_player_file_set_files(gamertag, file_set_id) get_player_file_set_files_uri = "file/sets/files/#{@token}/#{msftize(gamertag)}/#{file_set_id}" self.class.get(@api_url + get_player_file_set_files_uri) end |
#get_player_file_sets(gamertag) ⇒ Object
The “GetPlayerFileSets” method returns a listing of file sets created by the player.
131 132 133 134 |
# File 'lib/halo-reach-api.rb', line 131 def get_player_file_sets(gamertag) get_player_file_sets_uri = "file/sets/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_file_sets_uri) end |
#get_player_file_share(gamertag) ⇒ Object
The “GetPlayerFileShare” method returns a listing of files in a player’s file share.
107 108 109 110 |
# File 'lib/halo-reach-api.rb', line 107 def get_player_file_share(gamertag) get_player_file_share_uri = "file/share/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_file_share_uri) end |
#get_player_recent_screenshots(gamertag) ⇒ Object
The “GetPlayerRecentScreenshots” method returns a list of the player’s recent screenshots.
123 124 125 126 |
# File 'lib/halo-reach-api.rb', line 123 def get_player_recent_screenshots(gamertag) get_player_recent_screenshots_uri = "file/screenshots/#{@token}/#{msftize(gamertag)}" self.class.get(@api_url + get_player_recent_screenshots_uri) end |
#get_player_rendered_videos(gamertag, page = 0) ⇒ Object
The “GetPlayerRenderedVideos” method returns a listing of rendered videos created by a player.
147 148 149 150 |
# File 'lib/halo-reach-api.rb', line 147 def get_player_rendered_videos(gamertag, page = 0) get_player_rendered_videos_uri = "file/videos/#{@token}/#{msftize(gamertag)}/#{page}" self.class.get(@api_url + get_player_rendered_videos_uri) end |
#reach_file_search(file_category, map_filter, engine_filter, date_filter, sort_filter, tags, page = 0) ⇒ Object
The “ReachFileSearch” method returns a listing of files matching the specified criteria.
155 156 157 158 159 160 161 162 |
# File 'lib/halo-reach-api.rb', line 155 def reach_file_search(file_category, map_filter, engine_filter, date_filter, sort_filter, , page = 0) reach_file_search_uri = "file/search/#{@token}/#{file_category}/#{map_filter}/#{engine_filter}/#{date_filter}/#{sort_filter}/#{page}" unless .nil? reach_file_search_uri += "?tags=#{CGI.escape()}" end self.class.get(@api_url + reach_file_search_uri) end |
#set_http_headers(http_headers = {}) ⇒ Object
Set new HTTP headers
36 37 38 39 |
# File 'lib/halo-reach-api.rb', line 36 def set_http_headers(http_headers = {}) http_headers.merge!(DEFAULT_HEADERS) headers(http_headers) end |
#set_timeout(timeout) ⇒ Object
Set a new default HTTP timeout
42 43 44 |
# File 'lib/halo-reach-api.rb', line 42 def set_timeout(timeout) default_timeout(timeout) end |