Class: PlayStationNetwork::G::Trophies

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(psn_id, image_prefix, trophies, groups) ⇒ Trophies

Returns a new instance of Trophies.



7
8
9
10
11
12
# File 'lib/playstationnetwork/g/trophies.rb', line 7

def initialize(psn_id, image_prefix, trophies, groups)
  self.psn_id       = psn_id
  self.image_prefix = image_prefix
  self.trophies     = trophies
  self.groups       = groups
end

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



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

def groups
  @groups
end

#image_prefixObject

Returns the value of attribute image_prefix.



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

def image_prefix
  @image_prefix
end

#psn_idObject

Returns the value of attribute psn_id.



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

def psn_id
  @psn_id
end

#trophiesObject

Returns the value of attribute trophies.



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

def trophies
  @trophies
end

Class Method Details

.all(psn_game_id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/playstationnetwork/g/trophies.rb', line 14

def self.all(psn_game_id)
  options  = PlayStationNetwork::API.config.merge({ npcommid: psn_game_id })
  response = PlayStationNetwork::API.post('/psnGetTrophies', body: options)

  if response.success?
    parsed = JSON.parse(response)

    new(
      parsed['npcommid'],
      parsed['image_prefix'],
      parsed['trophies'],
      parsed['groups']
    )
  else
    raise response.response
  end
end