steam_web_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2152db28abcc8beeb04ee596c89d9034d8b669e4
4
- data.tar.gz: 396443261d6f46784c15c23fd1ca976a8d6e45ee
3
+ metadata.gz: 189b15cbe0cb2a32627c045807bf384d66933d8a
4
+ data.tar.gz: 84dd51f2962a72599773d7695d49f34f3f518096
5
5
  SHA512:
6
- metadata.gz: 05945716b534ad69cf40cce8633295a406c54fcbac7cc8109e4a050971f88227993dddccd33ee5e6ec1458b27664cd436cbc310657c33e5b49fdee3a989ef833
7
- data.tar.gz: d922428501be8a23baad1e6ff5584b225e7b99407f000579df3ce06d5652a72d96f197a02629d5970d7700f6e86bd9fca513b220cba67277675379e79ebb1c20
6
+ metadata.gz: f3eff608899c3262d0d1285c3388f9244c978ca103fe63ddb2b0516167217eb5109552676db87bdfecd4b32eaf235d8fe651993c4b9d7144fca90d1536b674a5
7
+ data.tar.gz: aa400deb17136ffdea271f775a68185dac440fe0e67a866c322a47b0750f17a612530eee262402d5be3f57bc40634cd1124884d8053e652b0123a60c0204fc81
data/README.md CHANGED
@@ -48,7 +48,7 @@ This is better not to include API key as plain text in you repository. For bette
48
48
 
49
49
  ```ruby
50
50
  # player_steam_id - this is a Steam identifier for user
51
- player = SteamWebApi::Player(player_steam_id)
51
+ player = SteamWebApi::Player.new(player_steam_id)
52
52
  data = player.owned_games
53
53
  data.count # how many games user posses (integer)
54
54
  data.games # list of user's games
@@ -77,7 +77,7 @@ game['has_community_visible_stats'] # indicates there is a stats page with achie
77
77
  (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetUserStatsForGame_.28v0002.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
78
78
 
79
79
  ```ruby
80
- player = SteamWebApi::Player(player_steam_id)
80
+ player = SteamWebApi::Player.new(player_steam_id)
81
81
  data = player.stats_for_game(game_id)
82
82
 
83
83
  data.steam_id # user steam identifier
@@ -99,7 +99,7 @@ stat['value'] # integer
99
99
  (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerAchievements_.28v0001.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
100
100
 
101
101
  ```ruby
102
- player = SteamWebApi::Player(player_steam_id)
102
+ player = SteamWebApi::Player.new(player_steam_id)
103
103
  data = player.achievements(game_id)
104
104
 
105
105
  data.steam_id # user steam identifier
@@ -198,7 +198,8 @@ friend['friend_since'] # integer
198
198
  player.friends('friend')
199
199
  ```
200
200
 
201
- **Get list of recently played games** (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetRecentlyPlayedGames_.28v0001.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
201
+ #### Get list of recently played games
202
+ (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetRecentlyPlayedGames_.28v0001.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
202
203
 
203
204
  ```ruby
204
205
  player = SteamWebApi::Player.new(steam_id)
@@ -220,7 +221,8 @@ game['img_logo_url']
220
221
  player.recently_played_games(2)
221
222
  ```
222
223
 
223
- **Check if player is playing shared game** (https://developer.valvesoftware.com/wiki/Steam_Web_API#IsPlayingSharedGame_.28v0001.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
224
+ #### Check if player is playing shared game
225
+ (https://developer.valvesoftware.com/wiki/Steam_Web_API#IsPlayingSharedGame_.28v0001.29). To make this API call, you need to have API key for your app and steam identifier of the Steam user.
224
226
 
225
227
  ```ruby
226
228
  player = SteamWebApi::Player.new(steam_id)
@@ -282,7 +284,7 @@ game['name']
282
284
  (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetSchemaForGame_.28v2.29). To make this API call, you need to have API key for your app.
283
285
 
284
286
  ```ruby
285
- game = SteamWebApi::Game(game_id)
287
+ game = SteamWebApi::Game.new(game_id)
286
288
  schema = game.schema
287
289
 
288
290
  schema.name # game name
@@ -310,7 +312,7 @@ stats['displayName']
310
312
  (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetGlobalAchievementPercentagesForApp_.28v0002.29)
311
313
 
312
314
  ```ruby
313
- game = SteamWebApi::Game(game_id)
315
+ game = SteamWebApi::Game.new(game_id)
314
316
  data = game.achievement_percentages
315
317
 
316
318
  data.achievements # list of achievements
@@ -325,7 +327,7 @@ achievement['percent']
325
327
  (https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29)
326
328
 
327
329
  ```ruby
328
- game = SteamWebApi::Game(game_id)
330
+ game = SteamWebApi::Game.new(game_id)
329
331
  news = game.news
330
332
 
331
333
  news.app_id # game id
@@ -19,7 +19,7 @@ module SteamWebApi
19
19
 
20
20
  def schema
21
21
  @response = get('/ISteamUserStats/GetSchemaForGame/v2', appid: game_id, key: SteamWebApi.config.api_key)
22
- build_response('game') { |data| { name: data['gameName'], version: data['gameVersion'], achievements: data['availableGameStats']['achievements'], stats: data['availableGameStats']['stats'] } }
22
+ build_response('game') { |data| { name: data['gameName'], version: data['gameVersion'], achievements: data.fetch('availableGameStats') { {} }.fetch('achievements') { [] }, stats: data.fetch('availableGameStats') { {} }.fetch('stats') { [] } } }
23
23
  end
24
24
 
25
25
  def achievement_percentages
@@ -1,3 +1,3 @@
1
1
  module SteamWebApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2?appid=4760&format=json&key=<API_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Sat, 24 Jan 2015 09:51:38 GMT
23
+ Expires:
24
+ - Sat, 24 Jan 2015 09:51:38 GMT
25
+ Content-Type:
26
+ - application/json; charset=UTF-8
27
+ Content-Length:
28
+ - '18'
29
+ body:
30
+ encoding: UTF-8
31
+ string: "{\n\t\"game\": {\n\n\t}\n}"
32
+ http_version:
33
+ recorded_at: Sat, 24 Jan 2015 09:51:38 GMT
34
+ recorded_with: VCR 2.9.3
@@ -47,33 +47,53 @@ RSpec.describe SteamWebApi::Game do
47
47
  end
48
48
 
49
49
  describe '#schema' do
50
-
51
- it 'returns game schema' do
52
- VCR.use_cassette('game_schema') do
53
- schema = game.schema
54
- expect(schema.name).to eq 'ValveTestApp8930'
55
- expect(schema.version).to eq '108'
56
- expect(schema.achievements.first).to eq(
57
- {
58
- "name" => "ACHIEVEMENT_WIN_WASHINGTON",
50
+
51
+ context 'when game has schema' do
52
+
53
+ it 'returns game schema' do
54
+ VCR.use_cassette('game_schema') do
55
+ schema = game.schema
56
+ expect(schema.name).to eq 'ValveTestApp8930'
57
+ expect(schema.version).to eq '108'
58
+ expect(schema.achievements.first).to eq(
59
+ {
60
+ "name" => "ACHIEVEMENT_WIN_WASHINGTON",
61
+ "defaultvalue" => 0,
62
+ "displayName" => "First in the Hearts of Your Countrymen",
63
+ "hidden" => 0,
64
+ "description" => "Beat the game on any difficulty setting as Washington.",
65
+ "icon" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/8930/4cf17a59d70b2decfd4369de8a7429e7b00f5ab8.jpg",
66
+ "icongray" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/8930/2ce109f9be6cb3193a385444b9b0b0ffcc7b2219.jpg"
67
+ }
68
+ )
69
+ expect(schema.stats.first).to eq(
70
+ {
71
+ "name" => "ESTEAMSTAT_TOTAL_WINS",
59
72
  "defaultvalue" => 0,
60
- "displayName" => "First in the Hearts of Your Countrymen",
61
- "hidden" => 0,
62
- "description" => "Beat the game on any difficulty setting as Washington.",
63
- "icon" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/8930/4cf17a59d70b2decfd4369de8a7429e7b00f5ab8.jpg",
64
- "icongray" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/8930/2ce109f9be6cb3193a385444b9b0b0ffcc7b2219.jpg"
65
- }
66
- )
67
- expect(schema.stats.first).to eq(
68
- {
69
- "name" => "ESTEAMSTAT_TOTAL_WINS",
70
- "defaultvalue" => 0,
71
- "displayName" => "Total Games Won."
72
- }
73
- )
74
- expect(schema.success).to be true
75
- end
73
+ "displayName" => "Total Games Won."
74
+ }
75
+ )
76
+ expect(schema.success).to be true
77
+ end
78
+ end
79
+
76
80
  end
81
+
82
+ context 'when game does not have schema' do
83
+
84
+ it 'returns object with empty values' do
85
+ VCR.use_cassette('game_schema_no_schema') do
86
+ schema = SteamWebApi::Game.new(4760).schema
87
+ expect(schema.name).to be_nil
88
+ expect(schema.version).to be_nil
89
+ expect(schema.achievements).to eq []
90
+ expect(schema.stats).to eq []
91
+ expect(schema.success).to be true
92
+ end
93
+ end
94
+
95
+ end
96
+
77
97
 
78
98
  end
79
99
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steam_web_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olga Grabek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,6 +148,7 @@ files:
148
148
  - spec/fixtures/vcr/game_news_error.yml
149
149
  - spec/fixtures/vcr/game_news_success.yml
150
150
  - spec/fixtures/vcr/game_schema.yml
151
+ - spec/fixtures/vcr/game_schema_no_schema.yml
151
152
  - spec/fixtures/vcr/player_achievements.yml
152
153
  - spec/fixtures/vcr/player_achievements_empty.yml
153
154
  - spec/fixtures/vcr/player_bans.yml
@@ -206,6 +207,7 @@ test_files:
206
207
  - spec/fixtures/vcr/game_news_error.yml
207
208
  - spec/fixtures/vcr/game_news_success.yml
208
209
  - spec/fixtures/vcr/game_schema.yml
210
+ - spec/fixtures/vcr/game_schema_no_schema.yml
209
211
  - spec/fixtures/vcr/player_achievements.yml
210
212
  - spec/fixtures/vcr/player_achievements_empty.yml
211
213
  - spec/fixtures/vcr/player_bans.yml