class SteamApiService
  attr_reader :player
  CSGO_APP_ID = 730

  def initialize(_player)
    @player = _player
  end

  def download_player_stats
    uri = URI("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=#{CSGO_APP_ID}&key=#{api_key}&steamid=#{player.steam_id}")
    raw_stats = JSON.parse(Net::HTTP.get(uri))["playerstats"]["stats"]
    Stats.create(player_id: player.id, data: parse_stats(raw_stats))
  end

  private
  def api_key
    Rails.configuration.steam["api_key"]
  end

  def parse_stats(data_hash)
    data_hash.each_with_object({}) { |stat, hsh| hsh[stat["name"]] = stat["value"] }
  end
end

class SteamApiService
  attr_reader :player

  def initialize(_player)
    @player = _player
  end

  def download_player_stats
    uri = URI("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=#{app_id}&key=#{api_key}&steamid=#{player.steam_id}")
    raw_stats = JSON.parse(Net::HTTP.get(uri))["playerstats"]["stats"]
    Stats.create(player_id: player.id, data: parse_stats(raw_stats))
  end

  private
  def api_key
    Rails.configuration.steam["api_key"]
  end

  def app_id
    730 #CSGO
  end

  def parse_stats(data_hash)
    data_hash.each_with_object({}) { |stat, hsh| hsh[stat["name"]] = stat["value"] }
  end
end

--- 
+++ 
@@ -1,12 +1,13 @@
 class SteamApiService
   attr_reader :player
+  CSGO_APP_ID = 730
 
   def initialize(_player)
     @player = _player
   end
 
   def download_player_stats
-    uri = URI("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=#{app_id}&key=#{api_key}&steamid=#{player.steam_id}")
+    uri = URI("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=#{CSGO_APP_ID}&key=#{api_key}&steamid=#{player.steam_id}")
     raw_stats = JSON.parse(Net::HTTP.get(uri))["playerstats"]["stats"]
     Stats.create(player_id: player.id, data: parse_stats(raw_stats))
   end
@@ -16,10 +17,6 @@
     Rails.configuration.steam["api_key"]
   end
 
-  def app_id
-    730 #CSGO
-  end
-
   def parse_stats(data_hash)
     data_hash.each_with_object({}) { |stat, hsh| hsh[stat["name"]] = stat["value"] }
   end
Move app id to constant
