Class: PlayStationNetwork::Trophies

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(psn_id, group_id, trophies) ⇒ Trophies

trophy_id, hidden, type, name, description, cover, rarity, earned_rate)



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/playstationnetwork/trophies.rb', line 6

def initialize(psn_id, group_id, trophies)# trophy_id, hidden, type, name, description, cover, rarity, earned_rate)
  self.psn_id      = psn_id
  self.group_id    = group_id
  self.trophies    = trophies
  # self.trophy_id   = trophy_id
  # self.hidden      = hidden
  # self.type        = type
  # self.name        = name
  # self.description = description
  # self.cover       = cover
  # self.rarity      = rarity
  # self.earned_rate = earned_rate
end

Instance Attribute Details

#group_idObject

, :trophy_id, :hidden, :type, :name, :description, :cover, :rarity, :earned_rate



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

def group_id
  @group_id
end

#psn_idObject

, :trophy_id, :hidden, :type, :name, :description, :cover, :rarity, :earned_rate



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

def psn_id
  @psn_id
end

#trophiesObject

, :trophy_id, :hidden, :type, :name, :description, :cover, :rarity, :earned_rate



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

def trophies
  @trophies
end

Class Method Details

.all(username, game_id) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/playstationnetwork/trophies.rb', line 42

def self.all(username, game_id)
  response = PlayStationNetwork::API.get("/#{username}/trophies/#{game_id}")

  if response.success?
    new(
      game_id,
      nil,
      response['trophies']
      # response['trophyId'],
      # response['trophyHidden'],
      # response['trophyType'],
      # response['trophyName'],
      # response['trophyDetail'],
      # response['trophyIconUrl'],
      # response['trophyRare'],
      # response['trophyEarnedRate']
    )
  else
    raise response.response
  end
end

.find(username, game_id, group_id) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/playstationnetwork/trophies.rb', line 20

def self.find(username, game_id, group_id)
  response = PlayStationNetwork::API.get("/#{username}/trophies/#{game_id}/groups/#{group_id}")

  if response.success?
    new(
      game_id,
      group_id,
      response['trophies']
      # response['trophyId'],
      # response['trophyHidden'],
      # response['trophyType'],
      # response['trophyName'],
      # response['trophyDetail'],
      # response['trophyIconUrl'],
      # response['trophyRare'],
      # response['trophyEarnedRate']
    )
  else
    raise response.response
  end
end