Class: PlayStationNetwork::User

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity) ⇒ User

Returns a new instance of User.



8
9
10
11
12
13
14
# File 'lib/playstationnetwork/user.rb', line 8

def initialize(identity)
  PlayStationNetwork::API.handle_response do
    raise ArgumentError, INVALID_IDENTITY_TYPE unless identity.is_a?(String)
    
    @options = PlayStationNetwork::API.request.merge(user_id: identity)
  end
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/playstationnetwork/user.rb', line 3

def options
  @options
end

Instance Method Details

#gamesObject



22
23
24
25
26
# File 'lib/playstationnetwork/user.rb', line 22

def games
  PlayStationNetwork::API.handle_response do
    PlayStationNetwork::API.parse_response('/psnGetUserGames', options, 'games')
  end
end

#profileObject



16
17
18
19
20
# File 'lib/playstationnetwork/user.rb', line 16

def profile
  PlayStationNetwork::API.handle_response do
    PlayStationNetwork::API.parse_response('/psnGetUser', options)
  end
end

#trophies(npcommid) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/playstationnetwork/user.rb', line 28

def trophies(npcommid)
  PlayStationNetwork::API.handle_response do
    raise INVALID_NPCOMMID_TYPE unless npcommid.is_a?(String)

    @options = options.merge(npcommid: npcommid)
    PlayStationNetwork::API.parse_response('/psnGetUserTrophies', options)
  end
end