Class: PlayStationNetwork::Game

Inherits:
API
  • Object
show all
Defined in:
lib/playstationnetwork/game.rb

Instance Attribute Summary

Attributes inherited from API

#config, #options

Instance Method Summary collapse

Methods inherited from API

#post

Constructor Details

#initialize(npcommid = '') ⇒ Game

Returns a new instance of Game.

Raises:

  • (INVALID_NPCOMMID_TYPE)


9
10
11
12
13
14
15
16
# File 'lib/playstationnetwork/game.rb', line 9

def initialize(npcommid = '')
  raise INVALID_NPCOMMID_TYPE unless npcommid.is_a?(String)

  super
  unless npcommid.empty?
    options[:npcommid] = npcommid
  end
end

Instance Method Details

#all(platform: 'all', popular: false) ⇒ Object

Raises:

  • (INVALID_PLATFORM_TYPE)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/playstationnetwork/game.rb', line 26

def all(platform: 'all', popular: false)
  raise INVALID_PLATFORM_TYPE unless platform.is_a?(String)
  raise INVALID_PLATFORM_TYPE unless GAMES_PARAMETERS_TYPES.include?(platform)
  raise INVALID_POPULAR_TYPE unless popular.is_a?(FalseClass) || popular.is_a?(TrueClass)

  if popular
    options[:list] = platform
    url = '/psnPopularThisWeek'
  else
    options[:platform] = platform
    url = '/psnListGames'
  end

  post(url, dig_to: ['psn_api', 'game'], xml: true)
end

#detailsObject



18
19
20
# File 'lib/playstationnetwork/game.rb', line 18

def details
  post('/psnGetGame')
end

#trophiesObject



22
23
24
# File 'lib/playstationnetwork/game.rb', line 22

def trophies
  post('/psnGetTrophies')
end