steam_api_client 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +21 -0
- data/.pronto.yml +12 -0
- data/.reek.yml +25 -0
- data/.rspec +4 -0
- data/.ruby-version +1 -0
- data/.standard.yml +3 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +9 -0
- data/CLAUDE.md +52 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +34 -0
- data/Gemfile.lock +220 -0
- data/LICENSE +21 -0
- data/README.md +158 -0
- data/lib/steam_api_client/client.rb +112 -0
- data/lib/steam_api_client/errors/api_error.rb +48 -0
- data/lib/steam_api_client/errors/response_parse_error.rb +19 -0
- data/lib/steam_api_client/errors/url_error.rb +5 -0
- data/lib/steam_api_client/failure_handler.rb +46 -0
- data/lib/steam_api_client/request.rb +86 -0
- data/lib/steam_api_client/requestors/app_details.rb +27 -0
- data/lib/steam_api_client/requestors/app_global_achievements.rb +19 -0
- data/lib/steam_api_client/requestors/app_news.rb +23 -0
- data/lib/steam_api_client/requestors/base.rb +32 -0
- data/lib/steam_api_client/requestors/game_current_players.rb +19 -0
- data/lib/steam_api_client/requestors/player_achievements.rb +21 -0
- data/lib/steam_api_client/requestors/player_friends.rb +21 -0
- data/lib/steam_api_client/requestors/player_game_stats.rb +21 -0
- data/lib/steam_api_client/requestors/player_level.rb +18 -0
- data/lib/steam_api_client/requestors/player_owned_games.rb +23 -0
- data/lib/steam_api_client/requestors/player_recent_games.rb +21 -0
- data/lib/steam_api_client/requestors/player_steamid.rb +19 -0
- data/lib/steam_api_client/requestors/player_summaries.rb +19 -0
- data/lib/steam_api_client/response.rb +64 -0
- data/lib/steam_api_client/structs/app_details/achievement.rb +12 -0
- data/lib/steam_api_client/structs/app_details/category.rb +12 -0
- data/lib/steam_api_client/structs/app_details/details.rb +82 -0
- data/lib/steam_api_client/structs/app_details/genre.rb +12 -0
- data/lib/steam_api_client/structs/app_details/movie.rb +25 -0
- data/lib/steam_api_client/structs/app_details/package_group.rb +18 -0
- data/lib/steam_api_client/structs/app_details/requirements.rb +12 -0
- data/lib/steam_api_client/structs/app_details/screenshot.rb +13 -0
- data/lib/steam_api_client/structs/app_details/sub.rb +18 -0
- data/lib/steam_api_client/structs/app_global_achievements.rb +18 -0
- data/lib/steam_api_client/structs/app_new.rb +20 -0
- data/lib/steam_api_client/structs/app_news.rb +13 -0
- data/lib/steam_api_client/structs/base.rb +15 -0
- data/lib/steam_api_client/structs/game_current_players.rb +12 -0
- data/lib/steam_api_client/structs/player_achievements.rb +23 -0
- data/lib/steam_api_client/structs/player_friends.rb +17 -0
- data/lib/steam_api_client/structs/player_game_stats.rb +20 -0
- data/lib/steam_api_client/structs/player_level.rb +11 -0
- data/lib/steam_api_client/structs/player_owned_games.rb +25 -0
- data/lib/steam_api_client/structs/player_recent_games.rb +22 -0
- data/lib/steam_api_client/structs/player_steamid.rb +16 -0
- data/lib/steam_api_client/structs/player_summaries.rb +11 -0
- data/lib/steam_api_client/structs/player_summary.rb +34 -0
- data/lib/steam_api_client/structs/requests/abstract.rb +59 -0
- data/lib/steam_api_client/structs/requests/get_app_details.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_app_global_achievements.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_app_news.rb +62 -0
- data/lib/steam_api_client/structs/requests/get_game_current_players.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_player_achievements.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_player_friends.rb +57 -0
- data/lib/steam_api_client/structs/requests/get_player_game_stats.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_player_level.rb +48 -0
- data/lib/steam_api_client/structs/requests/get_player_owned_games.rb +56 -0
- data/lib/steam_api_client/structs/requests/get_player_recent_games.rb +54 -0
- data/lib/steam_api_client/structs/requests/get_player_steamid.rb +48 -0
- data/lib/steam_api_client/structs/requests/get_player_summaries.rb +52 -0
- data/lib/steam_api_client/structs/requests/storefront_abstract.rb +58 -0
- data/lib/steam_api_client/structs/types.rb +14 -0
- data/lib/steam_api_client/version.rb +5 -0
- data/lib/steam_api_client.rb +75 -0
- metadata +161 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetAppNews < Abstract
|
|
5
|
+
attribute :appid, Types::Integer
|
|
6
|
+
attribute :count, Types::Integer
|
|
7
|
+
attribute :maxlength, Types::Integer
|
|
8
|
+
|
|
9
|
+
# Build the struct through the received params.
|
|
10
|
+
# @params [Hash] params The hash params.
|
|
11
|
+
# @return an instance of the Struct
|
|
12
|
+
def self.build_from_params(params)
|
|
13
|
+
%i[appid count maxlength].each do |attrib|
|
|
14
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
new(params)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns the version value to create the request path
|
|
21
|
+
# @return [String] the version of the request path
|
|
22
|
+
def version
|
|
23
|
+
"v0002/"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns the interface value to create the request path
|
|
27
|
+
# @return [String] the interface of the request path
|
|
28
|
+
def interface
|
|
29
|
+
"ISteamNews/"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the API path value to create the request path
|
|
33
|
+
# @return [String] the API path of the request path
|
|
34
|
+
def path
|
|
35
|
+
"GetNewsForApp/"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Returns the query params needed for the HTTP request
|
|
39
|
+
# @return [Hash]
|
|
40
|
+
def query_params
|
|
41
|
+
{
|
|
42
|
+
appid: appid,
|
|
43
|
+
count: count,
|
|
44
|
+
maxlength: maxlength
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Return the class attributes as a Hash
|
|
49
|
+
# @return [Hash]
|
|
50
|
+
def body
|
|
51
|
+
{}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Tells if the request require the api_token in the query params
|
|
55
|
+
# @return [Boolean]
|
|
56
|
+
def needs_authorization?
|
|
57
|
+
false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetGameCurrentPlayers < Abstract
|
|
5
|
+
attribute :appid, Types::Integer
|
|
6
|
+
|
|
7
|
+
# Build the struct through the received params.
|
|
8
|
+
# @params [Hash] params The hash params.
|
|
9
|
+
# @return an instance of the Struct
|
|
10
|
+
def self.build_from_params(params)
|
|
11
|
+
raise StandardError, ":appid is missing" unless params.key?(:appid)
|
|
12
|
+
|
|
13
|
+
new(params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the version value to create the request path
|
|
17
|
+
# @return [String] the version of the request path
|
|
18
|
+
def version
|
|
19
|
+
"v0001/"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the interface value to create the request path
|
|
23
|
+
# @return [String] the interface of the request path
|
|
24
|
+
def interface
|
|
25
|
+
"ISteamUserStats/"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the API path value to create the request path
|
|
29
|
+
# @return [String] the API path of the request path
|
|
30
|
+
def path
|
|
31
|
+
"GetNumberOfCurrentPlayers/"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the query params needed for the HTTP request
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def query_params
|
|
37
|
+
{appid: appid}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Return the class attributes as a Hash
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
def body
|
|
43
|
+
{}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Tells if the request require the api_token in the query params
|
|
47
|
+
# @return [Boolean]
|
|
48
|
+
def needs_authorization?
|
|
49
|
+
false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerAchievements < Abstract
|
|
5
|
+
attribute :appid, Types::Integer
|
|
6
|
+
attribute :steamid, Types::Integer
|
|
7
|
+
|
|
8
|
+
# Build the struct through the received params.
|
|
9
|
+
# @params [Hash] params The hash params.
|
|
10
|
+
# @return an instance of the Struct
|
|
11
|
+
def self.build_from_params(params)
|
|
12
|
+
%i[appid steamid].each do |attrib|
|
|
13
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
new(params)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns the version value to create the request path
|
|
20
|
+
# @return [String] the version of the request path
|
|
21
|
+
def version
|
|
22
|
+
"v0001/"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns the interface value to create the request path
|
|
26
|
+
# @return [String] the interface of the request path
|
|
27
|
+
def interface
|
|
28
|
+
"ISteamUserStats/"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the API path value to create the request path
|
|
32
|
+
# @return [String] the API path of the request path
|
|
33
|
+
def path
|
|
34
|
+
"GetPlayerAchievements/"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the query params needed for the HTTP request
|
|
38
|
+
# @return [Hash]
|
|
39
|
+
def query_params
|
|
40
|
+
{
|
|
41
|
+
appid: appid,
|
|
42
|
+
steamid: steamid
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Return the class attributes as a Hash
|
|
47
|
+
# @return [Hash]
|
|
48
|
+
def body
|
|
49
|
+
{}
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerFriends < Abstract
|
|
5
|
+
attribute :steamid, Types::Integer
|
|
6
|
+
attribute :relationship, Types::String
|
|
7
|
+
|
|
8
|
+
# Build the struct through the received params.
|
|
9
|
+
# @params [Hash] params The hash params.
|
|
10
|
+
# @return an instance of the Struct
|
|
11
|
+
def self.build_from_params(params)
|
|
12
|
+
%i[steamid relationship].each do |attrib|
|
|
13
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# The only possible values are: all, friend.
|
|
17
|
+
raise StandardError, ":relationship value not allowed" unless %w[all friend].include? params[:relationship]
|
|
18
|
+
|
|
19
|
+
new(params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the version value to create the request path
|
|
23
|
+
# @return [String] the version of the request path
|
|
24
|
+
def version
|
|
25
|
+
"v0001/"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the interface value to create the request path
|
|
29
|
+
# @return [String] the interface of the request path
|
|
30
|
+
def interface
|
|
31
|
+
"ISteamUser/"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the API path value to create the request path
|
|
35
|
+
# @return [String] the API path of the request path
|
|
36
|
+
def path
|
|
37
|
+
"GetFriendList/"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns the query params needed for the HTTP request
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
def query_params
|
|
43
|
+
{
|
|
44
|
+
steamid: steamid,
|
|
45
|
+
relationship: relationship
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Return the class attributes as a Hash
|
|
50
|
+
# @return [Hash]
|
|
51
|
+
def body
|
|
52
|
+
{}
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerGameStats < Abstract
|
|
5
|
+
attribute :appid, Types::Integer
|
|
6
|
+
attribute :steamid, Types::Integer
|
|
7
|
+
|
|
8
|
+
# Build the struct through the received params.
|
|
9
|
+
# @params [Hash] params The hash params.
|
|
10
|
+
# @return an instance of the Struct
|
|
11
|
+
def self.build_from_params(params)
|
|
12
|
+
%i[appid steamid].each do |attrib|
|
|
13
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
new(params)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns the version value to create the request path
|
|
20
|
+
# @return [String] the version of the request path
|
|
21
|
+
def version
|
|
22
|
+
"v0002/"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns the interface value to create the request path
|
|
26
|
+
# @return [String] the interface of the request path
|
|
27
|
+
def interface
|
|
28
|
+
"ISteamUserStats/"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the API path value to create the request path
|
|
32
|
+
# @return [String] the API path of the request path
|
|
33
|
+
def path
|
|
34
|
+
"GetUserStatsForGame/"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the query params needed for the HTTP request
|
|
38
|
+
# @return [Hash]
|
|
39
|
+
def query_params
|
|
40
|
+
{
|
|
41
|
+
appid: appid,
|
|
42
|
+
steamid: steamid
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Return the class attributes as a Hash
|
|
47
|
+
# @return [Hash]
|
|
48
|
+
def body
|
|
49
|
+
{}
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerLevel < Abstract
|
|
5
|
+
attribute :steamid, Types::Integer
|
|
6
|
+
|
|
7
|
+
# Build the struct through the received params.
|
|
8
|
+
# @params [Hash] params The hash params.
|
|
9
|
+
# @return an instance of the Struct
|
|
10
|
+
def self.build_from_params(params)
|
|
11
|
+
raise StandardError, ":steamid is missing" unless params.key?(:steamid)
|
|
12
|
+
|
|
13
|
+
new(params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the version value to create the request path
|
|
17
|
+
# @return [String] the version of the request path
|
|
18
|
+
def version
|
|
19
|
+
"v0001/"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the interface value to create the request path
|
|
23
|
+
# @return [String] the interface of the request path
|
|
24
|
+
def interface
|
|
25
|
+
"IPlayerService/"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the API path value to create the request path
|
|
29
|
+
# @return [String] the API path of the request path
|
|
30
|
+
def path
|
|
31
|
+
"GetSteamLevel/"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the query params needed for the HTTP request
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def query_params
|
|
37
|
+
{steamid: steamid}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Return the class attributes as a Hash
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
def body
|
|
43
|
+
{}
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerOwnedGames < Abstract
|
|
5
|
+
attribute :steamid, Types::Integer
|
|
6
|
+
attribute :include_appinfo, Types::Bool
|
|
7
|
+
attribute :include_played_free_games, Types::Bool
|
|
8
|
+
|
|
9
|
+
# Build the struct through the received params.
|
|
10
|
+
# @params [Hash] params The hash params.
|
|
11
|
+
# @return an instance of the Struct
|
|
12
|
+
def self.build_from_params(params)
|
|
13
|
+
%i[steamid include_appinfo include_played_free_games].each do |attrib|
|
|
14
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
new(params)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns the version value to create the request path
|
|
21
|
+
# @return [String] the version of the request path
|
|
22
|
+
def version
|
|
23
|
+
"v0001/"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns the interface value to create the request path
|
|
27
|
+
# @return [String] the interface of the request path
|
|
28
|
+
def interface
|
|
29
|
+
"IPlayerService/"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the API path value to create the request path
|
|
33
|
+
# @return [String] the API path of the request path
|
|
34
|
+
def path
|
|
35
|
+
"GetOwnedGames/"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Returns the query params needed for the HTTP request
|
|
39
|
+
# @return [Hash]
|
|
40
|
+
def query_params
|
|
41
|
+
{
|
|
42
|
+
steamid: steamid,
|
|
43
|
+
include_appinfo: include_appinfo,
|
|
44
|
+
include_played_free_games: include_played_free_games
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Return the class attributes as a Hash
|
|
49
|
+
# @return [Hash]
|
|
50
|
+
def body
|
|
51
|
+
{}
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerRecentGames < Abstract
|
|
5
|
+
attribute :steamid, Types::Integer
|
|
6
|
+
attribute :count, Types::Integer
|
|
7
|
+
|
|
8
|
+
# Build the struct through the received params.
|
|
9
|
+
# @params [Hash] params The hash params.
|
|
10
|
+
# @return an instance of the Struct
|
|
11
|
+
def self.build_from_params(params)
|
|
12
|
+
%i[steamid count].each do |attrib|
|
|
13
|
+
raise StandardError, "#{attrib} is missing" unless params.key?(attrib)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
new(params)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns the version value to create the request path
|
|
20
|
+
# @return [String] the version of the request path
|
|
21
|
+
def version
|
|
22
|
+
"v0001/"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns the interface value to create the request path
|
|
26
|
+
# @return [String] the interface of the request path
|
|
27
|
+
def interface
|
|
28
|
+
"IPlayerService/"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the API path value to create the request path
|
|
32
|
+
# @return [String] the API path of the request path
|
|
33
|
+
def path
|
|
34
|
+
"GetRecentlyPlayedGames/"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the query params needed for the HTTP request
|
|
38
|
+
# @return [Hash]
|
|
39
|
+
def query_params
|
|
40
|
+
{
|
|
41
|
+
steamid: steamid,
|
|
42
|
+
count: count
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Return the class attributes as a Hash
|
|
47
|
+
# @return [Hash]
|
|
48
|
+
def body
|
|
49
|
+
{}
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerSteamId < Abstract
|
|
5
|
+
attribute :vanityurl, Types::String
|
|
6
|
+
|
|
7
|
+
# Build the struct through the received params.
|
|
8
|
+
# @params [Hash] params The hash params.
|
|
9
|
+
# @return an instance of the Struct
|
|
10
|
+
def self.build_from_params(params)
|
|
11
|
+
raise StandardError, ":vanityurl is missing" unless params.key?(:vanityurl)
|
|
12
|
+
|
|
13
|
+
new(params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the version value to create the request path
|
|
17
|
+
# @return [String] the version of the request path
|
|
18
|
+
def version
|
|
19
|
+
"v0001/"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the interface value to create the request path
|
|
23
|
+
# @return [String] the interface of the request path
|
|
24
|
+
def interface
|
|
25
|
+
"ISteamUser/"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the API path value to create the request path
|
|
29
|
+
# @return [String] the API path of the request path
|
|
30
|
+
def path
|
|
31
|
+
"ResolveVanityURL/"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the query params needed for the HTTP request
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def query_params
|
|
37
|
+
{vanityurl: vanityurl}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Return the class attributes as a Hash
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
def body
|
|
43
|
+
{}
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
class GetPlayerSummaries < Abstract
|
|
5
|
+
attribute :steamids, Types::Array.of(Types::Coercible::Integer)
|
|
6
|
+
|
|
7
|
+
# Build the struct through the received params.
|
|
8
|
+
# @params [Hash] params The hash params.
|
|
9
|
+
# @return an instance of the Struct
|
|
10
|
+
def self.build_from_params(params)
|
|
11
|
+
raise StandardError, ":steamids are missing" unless params.key?(:steamids)
|
|
12
|
+
|
|
13
|
+
new(params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the version value to create the request path
|
|
17
|
+
# @return [String] the version of the request path
|
|
18
|
+
def version
|
|
19
|
+
"v0002/"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the interface value to create the request path
|
|
23
|
+
# @return [String] the interface of the request path
|
|
24
|
+
def interface
|
|
25
|
+
"ISteamUser/"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the API path value to create the request path
|
|
29
|
+
# @return [String] the API path of the request path
|
|
30
|
+
def path
|
|
31
|
+
"GetPlayerSummaries/"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the query params needed for the HTTP request
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def query_params
|
|
37
|
+
# I need to join the steamids because they wont accept
|
|
38
|
+
# multiple equal keys with different values on query params
|
|
39
|
+
{
|
|
40
|
+
steamids: steamids.join(",")
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Return the class attributes as a Hash
|
|
45
|
+
# @return [Hash]
|
|
46
|
+
def body
|
|
47
|
+
{}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
module Requests
|
|
4
|
+
# @abstract class for a Storefront Request's struct
|
|
5
|
+
class StorefrontAbstract < SteamApiClient::Structs::Base
|
|
6
|
+
# Returns the API path value to create the request path
|
|
7
|
+
# @abstract
|
|
8
|
+
# @return [String] the API path of the request path
|
|
9
|
+
def path
|
|
10
|
+
raise NoMethodError, "Override this method"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Returns the HTTP method used by the request.
|
|
14
|
+
# @return [Symbol]
|
|
15
|
+
def method
|
|
16
|
+
:get
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns the query params needed for the HTTP request.
|
|
20
|
+
# Here's a list taken from the steam website:
|
|
21
|
+
# cc (Optional)
|
|
22
|
+
# Country code for method to return appropriate currency values.
|
|
23
|
+
# l (Optional)
|
|
24
|
+
# For localized strings; takes English name of language (none of those fancy ISO distractions).
|
|
25
|
+
# v (Optional)
|
|
26
|
+
# Unknown.
|
|
27
|
+
# Given that information, I'm going to default the currency to 'USD' and locale to 'en'.
|
|
28
|
+
#
|
|
29
|
+
# @see https://wiki.teamfortress.com/wiki/User:RJackson/StorefrontAPI#Global_parameters
|
|
30
|
+
# @return [Hash]
|
|
31
|
+
def query_params
|
|
32
|
+
{
|
|
33
|
+
cc: "US",
|
|
34
|
+
l: "en"
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Return the class attributes as a Hash
|
|
39
|
+
# @return [Hash]
|
|
40
|
+
def body
|
|
41
|
+
to_h
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Tells if the request require the api_token in the query params
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
def needs_authorization?
|
|
47
|
+
true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Tells the URL builder which format to choose from
|
|
51
|
+
# @return [Symbol]
|
|
52
|
+
def endpoint_kind
|
|
53
|
+
:storefront_endpoint
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module SteamApiClient
|
|
2
|
+
module Structs
|
|
3
|
+
# Wrapper module to help use the dry types and easily extend them
|
|
4
|
+
# when necessary
|
|
5
|
+
module Types
|
|
6
|
+
include ::Dry.Types(default: :nominal)
|
|
7
|
+
|
|
8
|
+
module Optional
|
|
9
|
+
String = ::Dry.Types::String.optional.default(nil)
|
|
10
|
+
Integer = ::Dry.Types::Integer.optional.default(nil)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|