class SteamWebApi::Game

Attributes

game_id[R]

Public Class Methods

all() click to toggle source
# File lib/steam_web_api/game.rb, line 13
def all
        response = Faraday.get('http://api.steampowered.com/ISteamApps/GetAppList/v0002/')
        build_response(response, 'applist') { |data| { games: data['apps'] } }      
end
new(game_id) click to toggle source
# File lib/steam_web_api/game.rb, line 7
def initialize(game_id)
        @game_id = game_id   
end

Public Instance Methods

achievement_percentages() click to toggle source
# File lib/steam_web_api/game.rb, line 25
def achievement_percentages
        @response = get('/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002', gameid: game_id)
        build_response('achievementpercentages') { |data| { achievements: data['achievements'] } }
end
news(count: 3, max_length: 300) click to toggle source
# File lib/steam_web_api/game.rb, line 30
def news(count: 3, max_length: 300)
        @response = get('/ISteamNews/GetNewsForApp/v0002', appid: game_id, count: count, maxlength: max_length)
        build_response('appnews') { |data|{ app_id: data['appid'], news_items: data['newsitems'] } }
end
schema() click to toggle source
# File lib/steam_web_api/game.rb, line 20
def schema
        @response = get('/ISteamUserStats/GetSchemaForGame/v2', appid: game_id, key: SteamWebApi.config.api_key)
        build_response('game') { |data| { name: data['gameName'], version: data['gameVersion'], achievements: data.fetch('availableGameStats') { {} }.fetch('achievements') { [] }, stats: data.fetch('availableGameStats') { {} }.fetch('stats') { [] } } }
end