koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
356 stars 67 forks source link

How to use Dota2Inventory #260

Closed bhardin closed 9 years ago

bhardin commented 9 years ago

I would assume a WebApi.api_key is necessary since I get 403 without one.

>> WebApi.api_key = SUPER_PRIVATE_KEY
SUPER_PRIVATE_KEY
>> inventory = Dota2Inventory.new(id.steam_id64)

However, once I set my key, I receive the following:

WebApiError: The Web API request failed with the following error: Permission denied (status code: 15).

Any help?

koraktor commented 9 years ago

Can you open the inventory of that user when using the website (when not being logged in)?

bhardin commented 9 years ago

This helped. However, problem is still unsolved.

require 'steam-condenser'
require 'steam/community/game_inventory'

id = SteamId.new(USERNAME)
WebApi.api_key = SUPER_PRIVATE_KEY
inventory = Dota2Inventory.new(id.steam_id64)

returns:

NoMethodError: undefined method `new' for GameItem:Module
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/game_inventory.rb:138:in `block in fetch'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/game_inventory.rb:136:in `each'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/game_inventory.rb:136:in `fetch'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/cacheable.rb:42:in `block in method_added'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/cacheable.rb:105:in `new'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/game_inventory.rb:90:in `call'
    from /Users/bhardin/.rvm/gems/ruby-2.1.5/gems/steam-condenser-1.3.9/lib/steam/community/game_inventory.rb:90:in `new'
    from (irb):15
    from /Users/bhardin/.rvm/rubies/ruby-2.1.5/bin/irb:11:in `<main>'
bhardin commented 9 years ago

I'm pretty sure this is the line that is broken:

https://github.com/koraktor/steam-condenser-ruby/blob/master/lib/steam-condenser/community/game_inventory.rb#L142

koraktor commented 9 years ago

Ok, this seems indeed like a bug.

koraktor commented 9 years ago

I wonder why Dota2Inventory doesn't pick up Dota2Item as its item class (defined here: https://github.com/koraktor/steam-condenser-ruby/blob/1.3-stable/lib/steam/community/dota2/dota2_inventory.rb#L28).

Nevertheless, GameItem has to be a class (instead of a module) so other games (without specific implementations) work too.

bhardin commented 9 years ago

I have some of it working locally by using a mashup of your code and my own. Don't fully grok the code or else I'd submit a PR.

koraktor commented 9 years ago

This was fixed in the commits above. If you can't use the development version and don't want to wait for a new release, you can also fix this by requiring steam/community/dota2/dota2_inventory directly.

bhardin commented 9 years ago

Thanks for this. Looks great!