Module: Steam::User

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

Overview

A Ruby DSL for communicating with the Steam::User Web API.

Class Method Summary collapse

Class Method Details

.bans(steamids) ⇒ Hash

Get Multiple Player Bans

Parameters:

  • steamids (Array)

    Array of SteamIDs

Returns:

  • (Hash)

    A hash containing the API response

See Also:

Since:

  • 1.0.0



28
29
30
31
32
33
# File 'lib/steam-api/steam/user.rb', line 28

def self.bans(steamids)
  steamids = [steamids] unless steamids.is_a?(Array)
  response = client.get 'GetPlayerBans/v1/',
                        params: { steamids: steamids.join(',') }
  response
end

.clientObject

Since:

  • 1.0.0



84
85
86
# File 'lib/steam-api/steam/user.rb', line 84

def self.client
  build_client 'ISteamUser'
end

.friends(steamid, relationship: :all) ⇒ Hash

Get User’s Friend List

Parameters:

  • steamid (String)
  • relationship (String) (defaults to: :all)

    Relationship filter. Possibles values: all, friend.

Returns:

  • (Hash)

    A hash object resulting from the API call; should returns the friend list of any Steam user, provided their Steam Community profile visibility is set to “Public”.

See Also:

Since:

  • 1.0.0



15
16
17
18
19
20
21
22
# File 'lib/steam-api/steam/user.rb', line 15

def self.friends(steamid, relationship: :all)
  response = client.get 'GetFriendList/v1/',
                        params: { steamid: steamid,
                                  relationship: relationship }
  response = response.parse_key('friendslist')
                     .parse_key('friends')
  response
end

.groups(steamid) ⇒ Hash

Get User Groups

Parameters:

  • steamid (Fixnum)

    64bit Steam ID to return friend list.

Returns:

  • (Hash)

    A hash containing the API response

See Also:

Since:

  • 1.0.0



64
65
66
67
68
69
# File 'lib/steam-api/steam/user.rb', line 64

def self.groups(steamid)
  response = client.get 'GetUserGroupList/v1', params: { steamid: steamid }
  response = response.parse_key('response')
  response.check_success
  response.parse_key('groups')
end

.summaries(steamids) ⇒ Hash

Get Player Summaries

Parameters:

  • steamids (Array)

    List of player’s steamids

Returns:

  • (Hash)

    The hash object resulting from the API call. Some data associated with a Steam account may be hidden if the user has their profile visibility set to “Friends Only” or “Private”. In that case, only public data will be returned.

See Also:

Since:

  • 1.0.0



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

def self.summaries(steamids)
  response = client.get 'GetPlayerSummaries/v2/',
                        params: { steamids: steamids.join(',') }
  response.parse_key('response')
          .parse_key('players')
end

.summary(steamid) ⇒ Hash

Get Player Summaries

Parameters:

  • params (Hash)

    a customizable set of options

Returns:

  • (Hash)

    The hash object resulting from the API call. Some data associated with a Steam account may be hidden if the user has their profile visibility set to “Friends Only” or “Private”. In that case, only public data will be returned.

See Also:

Since:

  • 1.0.0



42
43
44
# File 'lib/steam-api/steam/user.rb', line 42

def self.summary(steamid)
  summaries([steamid]).first
end

.vanity_to_steamid(vanityurl) ⇒ Hash

Resolve Vanity URL

Parameters:

  • vanityurl (String)

    The vanity URL part of a user’s Steam profile URL. This is the basename of steamcommunity.com/id/ URLs

Returns:

  • (Hash)

    A hash containing the API response

See Also:

Since:

  • 1.0.0



76
77
78
79
80
81
82
# File 'lib/steam-api/steam/user.rb', line 76

def self.vanity_to_steamid(vanityurl)
  response = client.get 'ResolveVanityURL/v1',
                        params: { vanityurl: vanityurl }
  response = response.parse_key('response')
  response.check_success(success_condition: 1)
  response.parse_key('steamid')
end