Class: PlayStationNetwork::U::Trophies

Inherits:
Object
  • Object
show all
Defined in:
lib/playstationnetwork/u/trophies.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trophies) ⇒ Trophies

Returns a new instance of Trophies.



7
8
9
# File 'lib/playstationnetwork/u/trophies.rb', line 7

def initialize(trophies)
  self.trophies = trophies
end

Instance Attribute Details

#trophiesObject

Returns the value of attribute trophies.



5
6
7
# File 'lib/playstationnetwork/u/trophies.rb', line 5

def trophies
  @trophies
end

Class Method Details

.all(psn_user_id, psn_game_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/playstationnetwork/u/trophies.rb', line 11

def self.all(psn_user_id, psn_game_id)
  options  = PlayStationNetwork::API.config.merge({ user_id: psn_user_id, npcommid: psn_game_id })
  response = PlayStationNetwork::API.post('/psnGetUserTrophies', body: options)
  
  if response.success?
    parsed = JSON.parse(response)

    new(
      parsed['trophies']
    )
  else
    raise response.response
  end
end