Module: Steam::Economy

Defined in:
lib/steam-api/steam/economy.rb

Overview

A Ruby DSL for communicating with the Steam Web API.

Class Method Summary collapse

Class Method Details

.asset_info(appid, params: {}) ⇒ Hash

Get Asset Class Info

Parameters:

  • appid (String)

    The application ID for the Steam Game.

  • params (Hash) (defaults to: {})

    Parameters to pass to the API

Options Hash (params:):

  • :class_count (Fixnum)

    The number of classids passed to the request.

  • :classidN (Fixnum)

    Where N can be a series of sequential numbers to form a list of class IDs. [1] [2]

  • :instanceidN (Fixnum)

    Instance ID of the nth class.

  • :language (String)

    The ISO639-1 language code for the language all localized strings should be returned in. Not all strings have been translated to every language. If a language does not have a string, the English string will be returned instead. If this parameter is omitted the string token will be returned for the strings.

Returns:

  • (Hash)

    A hash containing the API response

See Also:

Since:

  • 1.0.0



22
23
24
25
26
# File 'lib/steam-api/steam/economy.rb', line 22

def self.asset_info(appid, params: {})
  params[:appid] = appid
  response = client.get 'GetAssetClassInfo/v1', params: params
  parse_response(response)
end

.asset_prices(appid, language: nil, currency: nil) ⇒ Hash

Get Asset Prices

Parameters:

  • appid (String)

    The application ID for the Steam Game.

  • language (String) (defaults to: nil)

    The ISO639-1 language code for the language all localized strings should be returned in. Not all strings have been translated to every language. If a language does not have a string, the English string will be returned instead. If this parameter is omitted the string token will be returned for the strings. (Optional)

  • currency (String) (defaults to: nil)

    The ISO 4217 code for currency specific filtering. (Optional)

Returns:

  • (Hash)

    A hash containing the API response

See Also:

Since:

  • 1.0.0



40
41
42
43
44
45
46
47
# File 'lib/steam-api/steam/economy.rb', line 40

def self.asset_prices(appid, language: nil, currency: nil)
  params = { appid: appid }
  params[:language] = language unless language.nil?
  params[:currency] = currency unless currency.nil?
  response = client.get 'GetAssetPrices/v1',
                        params: params
  parse_response(response)
end

.clientObject

Since:

  • 1.0.0



49
50
51
# File 'lib/steam-api/steam/economy.rb', line 49

def self.client
  build_client 'ISteamEconomy'
end

.parse_response(response) ⇒ Object

Since:

  • 1.0.0



53
54
55
56
57
58
# File 'lib/steam-api/steam/economy.rb', line 53

def self.parse_response(response)
  response = response.parse_key('result')
  response.check_success
  response.delete('success')
  response
end