playstationnetwork-api 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b351e27faebd09b7f6bc892b4d1fc40695215fce
4
- data.tar.gz: a6ddc6114a636d2807d96046fd0f2f31a4ecd6d1
3
+ metadata.gz: 9f3c3689cc62489a651c56c93e9213e5a89a1524
4
+ data.tar.gz: 21817fc6629fd58cd1bfffe0efb2c80f19538081
5
5
  SHA512:
6
- metadata.gz: 50ddf55978fdac5795b0659dadef194ae8fa432f6eeef224b91d25591ee86108167be7dd6120c9ab1e3a36d76bbe6b4ec3b004aa8a42d59232d817dde1f5e93b
7
- data.tar.gz: 120f05a6ed7c9307a3d6cc89fbffba0fb8266a86626e4b7e7def000b67b09c9b506aeeb068199c03a79e1df225ca5685f6a8447aac15b24cc3f0b57c7f5f20cc
6
+ metadata.gz: 81387ed680b523227612b17f717648e24202ad112736bd999f296c472cd9515023ad4811532c5d8e66f6ff427bcba1ecfcebd4f0ac0f82df15ad9fdfea4ffb57
7
+ data.tar.gz: 46b4d4cce48795bf6e81b377f7074dcbfa4709b5c9248f79b37981efb77262047430c458a0f05d3c2d5e772693e9d082cd35f26cb083b7bd2e9a3b8220483c12
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'httparty'
4
- # Specify your gem's dependencies in playstationnetwork-api.gemspec
4
+ gem 'json'
5
+ gem 'activesupport'
6
+
5
7
  gemspec
@@ -3,7 +3,7 @@ require 'httparty'
3
3
 
4
4
  module PlayStationNetwork
5
5
 
6
- Dir[File.dirname(__FILE__) + '/playstationnetwork/*.rb'].each do |file|
6
+ Dir[File.dirname(__FILE__) + '/playstationnetwork/**/*.rb'].each do |file|
7
7
  require file
8
8
  end
9
9
  end
@@ -2,16 +2,15 @@ module PlayStationNetwork
2
2
  module API
3
3
  include HTTParty
4
4
 
5
- base_uri 'http://psnapi-studio51.rhcloud.com/PSN/'
5
+ base_uri 'https://www.happynation.co.uk/api'
6
6
 
7
7
  def self.config
8
- @@config
9
- end
10
-
11
- def self.key(api_key)
12
- @@config = {
13
- api_key: api_key,
14
- format: 'json'
8
+ {
9
+ body: {
10
+ api_key: '4047cc6b66393a82a0c7d90844cf0d88b14e0c3a',
11
+ api_secret: 'pacMakaveli90',
12
+ response_type: 'json'
13
+ }
15
14
  }
16
15
  end
17
16
  end
@@ -0,0 +1,97 @@
1
+ module PlayStationNetwork
2
+ module G
3
+
4
+ class Game
5
+ attr_accessor :media, :updates, :trophies, :stats,
6
+ :psn_id, :psn_hash, :psn_type, :psn_slug, :name, :cover, :platforms,
7
+ :updated, :checked,
8
+ :total, :platinum, :gold, :silver, :bronze,
9
+ :points, :points_platinum, :average_percentage, :owners, :completers, :completers_platinum, :trophies_earned, :played_this_week
10
+
11
+ def initialize(
12
+ psn_id, psn_hash, psn_type, psn_slug, name, cover, platforms,
13
+ updated, checked,
14
+ artworks, videos,
15
+ total, platinum, gold, silver, bronze,
16
+ points, points_platinum, average_percentage, owners, completers, completers_platinum, trophies_earned, played_this_week
17
+ )
18
+
19
+ game_updates = Hash.new
20
+ game_updates[:last_updated] = updated
21
+ game_updates[:last_checked] = checked
22
+
23
+ game_media = Hash.new
24
+ game_media[:artworks] = artworks
25
+ game_media[:videos] = videos
26
+
27
+ game_trophies = Hash.new
28
+ game_trophies[:total] = total
29
+ game_trophies[:platinum] = platinum
30
+ game_trophies[:gold] = gold
31
+ game_trophies[:silver] = silver
32
+ game_trophies[:bronze] = bronze
33
+
34
+ game_stats = Hash.new
35
+ game_stats[:points] = points
36
+ game_stats[:points_platinum] = points_platinum
37
+ game_stats[:average_percentage] = "#{average_percentage}%"
38
+ game_stats[:owners] = owners
39
+ game_stats[:completers] = completers
40
+ game_stats[:completers_platinum] = completers_platinum
41
+ game_stats[:trophies_earned] = trophies_earned
42
+ game_stats[:played_this_week] = played_this_week
43
+
44
+ self.psn_id = psn_id
45
+ self.psn_hash = psn_hash
46
+ self.psn_type = psn_type
47
+ self.psn_slug = psn_slug
48
+ self.name = name
49
+ self.cover = cover
50
+ self.platforms = platforms.split(',')
51
+ self.media = game_media
52
+ self.updates = game_updates
53
+ self.trophies = game_trophies
54
+ self.stats = game_stats
55
+ end
56
+
57
+ def self.find(psn_game_id)
58
+ response = PlayStationNetwork::API.post("/psnGetGame",
59
+ PlayStationNetwork::API.config[:body].merge({ npcommid: psn_game_id }))
60
+
61
+ if response.success?
62
+ parsed = JSON.parse(response)
63
+
64
+ new(
65
+ parsed['npcommid'],
66
+ parsed['game_hash'],
67
+ parsed['content_Type'],
68
+ parsed['unique_url'],
69
+ parsed['title'],
70
+ parsed['image'],
71
+ parsed['pf'],
72
+ parsed['updated'].to_i,
73
+ parsed['meta_check'].to_i,
74
+ parsed['screenshots'],
75
+ parsed['videos'],
76
+ parsed['total'].to_i,
77
+ parsed['platinum'].to_i,
78
+ parsed['gold'].to_i,
79
+ parsed['silver'].to_i,
80
+ parsed['bronze'].to_i,
81
+ parsed['total_points'].to_i,
82
+ parsed['total_points_plat'].to_i,
83
+ parsed['average_perc'].to_f,
84
+ parsed['owners'].to_i,
85
+ parsed['completers'].to_i,
86
+ parsed['platters'].to_i,
87
+ parsed['trophies_earned'].to_i,
88
+ parsed['played_this_week'].to_i
89
+ )
90
+ else
91
+ raise response.response
92
+ end
93
+ end
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,61 @@
1
+ require 'json'
2
+ require 'active_support/core_ext/hash'
3
+ require 'pp'
4
+
5
+ module PlayStationNetwork
6
+ module G
7
+
8
+ class Games
9
+ attr_accessor :success, :total_games, :games
10
+
11
+ def initialize(success, total_games, games)
12
+ self.success = success
13
+ self.total_games = total_games
14
+ self.games = games
15
+ end
16
+
17
+ # Available platform options
18
+ #
19
+ # => all returns all PlayStation Network games
20
+ # => psp2 returns all PSP games
21
+ # => ps3 returns all PS3 games
22
+ # => ps4 returns all PS4 games
23
+ #
24
+ def self.all(psn_platform = 'all')
25
+ response = PlayStationNetwork::API.post('/psnListGames',
26
+ PlayStationNetwork::API.config[:body].merge({ platform: psn_platform }))
27
+
28
+ sanitized_response = response.gsub('<?xml version=\"1.0\"?>', '').gsub('<\/', '</').tr('"', '')
29
+ parsed_response = Hash.from_xml(sanitized_response)
30
+
31
+ if response.success?
32
+ new(
33
+ (parsed_response['psn_api']['success'].to_i == 1 ? true : false),
34
+ parsed_response['psn_api']['game'].size,
35
+ parsed_response['psn_api']['game']
36
+ )
37
+ else
38
+ raise response.response
39
+ end
40
+ end
41
+
42
+ def self.popular
43
+ response = PlayStationNetwork::API.post('/psnPopularThisWeek')
44
+
45
+ sanitized_response = response.gsub('<?xml version=\"1.0\"?>', '').gsub('<\/', '</').tr('"', '')
46
+ parsed_response = Hash.from_xml(sanitized_response)
47
+
48
+ if response.success?
49
+ new(
50
+ (parsed_response['psn_api']['success'].to_i == 1 ? true : false),
51
+ parsed_response['psn_api']['game'].size,
52
+ parsed_response['psn_api']['game']
53
+ )
54
+ else
55
+ raise response.response
56
+ end
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,34 @@
1
+ module PlayStationNetwork
2
+ module G
3
+
4
+ class Trophies
5
+ attr_accessor :psn_id, :image_prefix, :trophies, :groups
6
+
7
+ def initialize(psn_id, image_prefix, trophies, groups)
8
+ self.psn_id = psn_id
9
+ self.image_prefix = image_prefix
10
+ self.trophies = trophies
11
+ self.groups = groups
12
+ end
13
+
14
+ def self.all(psn_game_id)
15
+ response = PlayStationNetwork::API.post('/psnGetTrophies',
16
+ PlayStationNetwork::API.config[:body].merge({ npcommid: psn_game_id }))
17
+
18
+ if response.success?
19
+ parsed = JSON.parse(response)
20
+
21
+ new(
22
+ parsed['npcommid'],
23
+ parsed['image_prefix'],
24
+ parsed['trophies'],
25
+ parsed['groups']
26
+ )
27
+ else
28
+ raise response.response
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ module PlayStationNetwork
2
+ module U
3
+
4
+ class Games
5
+ attr_accessor :total_games, :games
6
+
7
+ def initialize(total_games, games)
8
+ self.total_games = total_games
9
+ self.games = games
10
+ end
11
+
12
+ def self.all(psn_user_id)
13
+ response = PlayStationNetwork::API.post('/psnGetUserGames',
14
+ PlayStationNetwork::API.config[:body].merge({ user_id: psn_user_id }))
15
+
16
+ if response.success?
17
+ parsed = JSON.parse(response)
18
+
19
+ new(
20
+ parsed['games'].size,
21
+ parsed['games']
22
+ )
23
+ else
24
+ raise response.response
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ module PlayStationNetwork
2
+ module U
3
+
4
+ class Trophies
5
+ attr_accessor :trophies
6
+
7
+ def initialize(trophies)
8
+ self.trophies = trophies
9
+ end
10
+
11
+ def self.all(psn_user_id, psn_game_id)
12
+ response = PlayStationNetwork::API.post('/psnGetUserTrophies',
13
+ PlayStationNetwork::API.config[:body].merge({ user_id: psn_user_id, npcommid: psn_game_id }))
14
+
15
+ if response.success?
16
+ parsed = JSON.parse(response)
17
+
18
+ new(
19
+ parsed['trophies']
20
+ )
21
+ else
22
+ raise response.response
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,121 @@
1
+ module PlayStationNetwork
2
+ module U
3
+
4
+ class User
5
+ attr_accessor :profile, :trophies, :points, :level, :stats,
6
+ :membership, :avatar, :username, :about, :country, :region,
7
+ :total, :platinum, :gold, :silver, :bronze, :total_possible,
8
+ :points_base, :points, :points_next,
9
+ :level, :projected_level, :progress, :projected_progress,
10
+ :total_games, :completed_games, :completion_percentage, :world_rank, :region_rank, :hardcore_rank
11
+
12
+ def initialize(
13
+ membership, avatar, username, about, country, region,
14
+ total, platinum, gold, silver, bronze, total_possible,
15
+ points_base, points, points_next,
16
+ level, projected_level, progress, projected_progress,
17
+ total_games, completed_games, completion_percentage, world_rank, region_rank, hardcore_rank
18
+ )
19
+
20
+ # Build the Profile Hash
21
+ #
22
+ psn_profile = Hash.new
23
+ psn_profile[:membership] = membership.to_i
24
+ psn_profile[:avatar] = avatar
25
+ psn_profile[:username] = username
26
+ psn_profile[:about] = about
27
+ psn_profile[:location] = Hash.new
28
+ psn_profile[:location][:country] = country
29
+ psn_profile[:location][:region] = region
30
+
31
+ # Build the Trophies hash
32
+ #
33
+ psn_profile_trophies = Hash.new
34
+ psn_profile_trophies[:total] = total.to_i
35
+ psn_profile_trophies[:platinum] = platinum.to_i
36
+ psn_profile_trophies[:gold] = gold.to_i
37
+ psn_profile_trophies[:silver] = silver.to_i
38
+ psn_profile_trophies[:bronze] = bronze.to_i
39
+ psn_profile_trophies[:total_possible] = total_possible.to_i
40
+
41
+ # Build the Points hash
42
+ #
43
+ psn_profile_points = Hash.new
44
+ psn_profile_points[:base] = points_base.to_i
45
+ psn_profile_points[:actual] = points.to_i
46
+ psn_profile_points[:next] = points_next.to_i
47
+
48
+ # Build the Level hash
49
+ #
50
+ psn_profile_level = Hash.new
51
+ psn_profile_level[:level] = level.to_i
52
+ psn_profile_level[:projected_level] = projected_level.to_i
53
+ psn_profile_level[:progress] = progress.to_f
54
+ psn_profile_level[:projected_progress] = projected_progress.to_f
55
+
56
+ # Build the Points hash
57
+ #
58
+ psn_profile_stats = Hash.new
59
+ psn_profile_stats[:games] = total_games.to_i
60
+ psn_profile_stats[:completed_games] = completed_games.to_i
61
+ psn_profile_stats[:completion_percentage] = completion_percentage.to_f
62
+ psn_profile_stats[:rank] = Hash.new
63
+ psn_profile_stats[:rank][:world_rank] = world_rank.to_i
64
+ psn_profile_stats[:rank][:region_rank] = region_rank.to_i
65
+ psn_profile_stats[:rank][:hardcore_rank] = hardcore_rank.to_i
66
+
67
+ self.profile = psn_profile
68
+ self.trophies = psn_profile_trophies
69
+ self.level = psn_profile_level
70
+ self.points = psn_profile_points
71
+ self.stats = psn_profile_stats
72
+
73
+ end
74
+
75
+ def self.profile(psn_user_id)
76
+ response = PlayStationNetwork::API.post('/psnGetUser',
77
+ PlayStationNetwork::API.config[:body].merge({ user_id: psn_user_id }))
78
+
79
+ if response.success?
80
+ parsed = JSON.parse(response)
81
+
82
+ self.new(
83
+ parsed['psnplus'],
84
+ parsed['avatar'],
85
+ parsed['psn_id'],
86
+ parsed['about_me'],
87
+ parsed['country'],
88
+ parsed['region'],
89
+
90
+ parsed['total'],
91
+ parsed['platinum'],
92
+ parsed['gold'],
93
+ parsed['silver'],
94
+ parsed['bronze'],
95
+ parsed['total_possible_trophies'],
96
+
97
+ parsed['base'],
98
+ parsed['points'],
99
+ parsed['next'],
100
+
101
+ parsed['level'],
102
+ parsed['projected_level'],
103
+ parsed['progress'],
104
+ parsed['projected_progress'],
105
+
106
+ parsed['total_games'],
107
+ parsed['games_complete'],
108
+ parsed['completion_percentage'],
109
+ parsed['worldrank'],
110
+ parsed['regionrank'],
111
+ parsed['hardcore_rank']
112
+
113
+ )
114
+ else
115
+ raise response.response
116
+ end
117
+ end
118
+ end
119
+
120
+ end
121
+ end
@@ -1,7 +1,9 @@
1
1
  module PlayStationNetwork
2
- VERSION = '0.1.1'
2
+ VERSION = '1.0.0'
3
3
 
4
4
  # Changelog
5
+ #
6
+
5
7
  #
6
8
  # v0.0.1 - Initial
7
9
  # v0.0.2 - Added Trophy Information
@@ -10,4 +12,8 @@ module PlayStationNetwork
10
12
  # v0.1.1 - Added a convenient method 'all' on Trophies, without having to pass
11
13
  # the group id as an argument
12
14
 
15
+ #
16
+ # v1.0.0 - Introduces a new API, new endpoints and new format for requesting data
17
+ # it's basically a new gem
18
+
13
19
  end
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.authors = ["Vlad Radulescu"]
8
8
  spec.email = ["pacMakaveli90@gmail.co.uk"]
9
9
 
10
- spec.summary = %q{A ruby wrapper for PSN API}
11
- spec.description = %q{A ruby wrapper for PSN API}
10
+ spec.summary = %q{A Ruby wrapper for Studio51's PlayStation Network API}
11
+ spec.description = %q{A Ruby wrapper for Studio51's PlayStation Network API for grabbing User profiles, Games and Trophies}
12
12
  spec.homepage = ''
13
13
  spec.license = "MIT"
14
14
 
@@ -17,7 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency 'httparty'
20
+ spec.add_dependency 'httparty', '~> 0'
21
+ spec.add_dependency 'json', '~> 0'
22
+ spec.add_dependency 'activesupport', '~> 0'
21
23
  spec.add_development_dependency "bundler", "~> 1.11"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,27 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playstationnetwork-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Radulescu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  - !ruby/object:Gem::Dependency
@@ -66,7 +94,8 @@ dependencies:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
96
  version: '3.0'
69
- description: A ruby wrapper for PSN API
97
+ description: A Ruby wrapper for Studio51's PlayStation Network API for grabbing User
98
+ profiles, Games and Trophies
70
99
  email:
71
100
  - pacMakaveli90@gmail.co.uk
72
101
  executables:
@@ -84,10 +113,12 @@ files:
84
113
  - bin/setup
85
114
  - lib/playstationnetwork-api.rb
86
115
  - lib/playstationnetwork/api.rb
87
- - lib/playstationnetwork/games.rb
88
- - lib/playstationnetwork/profile.rb
89
- - lib/playstationnetwork/trophies.rb
90
- - lib/playstationnetwork/trophy_groups.rb
116
+ - lib/playstationnetwork/g/game.rb
117
+ - lib/playstationnetwork/g/games.rb
118
+ - lib/playstationnetwork/g/trophies.rb
119
+ - lib/playstationnetwork/u/games.rb
120
+ - lib/playstationnetwork/u/trophies.rb
121
+ - lib/playstationnetwork/u/user.rb
91
122
  - lib/playstationnetwork/version.rb
92
123
  - playstationnetwork-api.gemspec
93
124
  - spec/playstationnetwork/api_spec.rb
@@ -115,7 +146,7 @@ rubyforge_project:
115
146
  rubygems_version: 2.5.1
116
147
  signing_key:
117
148
  specification_version: 4
118
- summary: A ruby wrapper for PSN API
149
+ summary: A Ruby wrapper for Studio51's PlayStation Network API
119
150
  test_files:
120
151
  - spec/playstationnetwork/api_spec.rb
121
152
  - spec/spec_helper.rb
@@ -1,27 +0,0 @@
1
- module PlayStationNetwork
2
- class Games
3
- attr_accessor :total_games, :offset, :limit, :games
4
-
5
- def initialize(total_games, offset, limit, games)
6
- self.total_games = total_games
7
- self.offset = offset
8
- self.limit = limit
9
- self.games = games
10
- end
11
-
12
- def self.find(username, offset = 0)
13
- response = PlayStationNetwork::API.get("/#{username}/trophies/o/#{offset}")
14
-
15
- if response.success?
16
- new(
17
- response['totalResults'],
18
- response['offset'],
19
- response['limit'],
20
- response['trophyTitles']
21
- )
22
- else
23
- raise response.response
24
- end
25
- end
26
- end
27
- end
@@ -1,42 +0,0 @@
1
- module PlayStationNetwork
2
- class Profile
3
- attr_accessor :id,
4
- :avatar,
5
- :username,
6
- :about,
7
- :membership,
8
- :level,
9
- :progress,
10
- :trophies
11
-
12
- def initialize(id, avatar, username, about, membership, level, progress, trophies)
13
- self.id = id
14
- self.avatar = avatar
15
- self.username = username
16
- self.about = about
17
- self.membership = membership
18
- self.level = level
19
- self.progress = progress
20
- self.trophies = trophies
21
- end
22
-
23
- def self.find(username)
24
- response = PlayStationNetwork::API.get("/#{username}")
25
-
26
- if response.success?
27
- self.new(
28
- response['npId'],
29
- response['avatarUrl'],
30
- response['onlineId'],
31
- response['aboutMe'],
32
- response['plus'],
33
- response['trophySummary']['level'],
34
- response['trophySummary']['progress'],
35
- response['trophySummary']['earnedTrophies']
36
- )
37
- else
38
- raise response.response
39
- end
40
- end
41
- end
42
- end
@@ -1,64 +0,0 @@
1
- module PlayStationNetwork
2
-
3
- class Trophies
4
- attr_accessor :psn_id, :group_id, :trophies #, :trophy_id, :hidden, :type, :name, :description, :cover, :rarity, :earned_rate
5
-
6
- def initialize(psn_id, group_id, trophies)# trophy_id, hidden, type, name, description, cover, rarity, earned_rate)
7
- self.psn_id = psn_id
8
- self.group_id = group_id
9
- self.trophies = trophies
10
- # self.trophy_id = trophy_id
11
- # self.hidden = hidden
12
- # self.type = type
13
- # self.name = name
14
- # self.description = description
15
- # self.cover = cover
16
- # self.rarity = rarity
17
- # self.earned_rate = earned_rate
18
- end
19
-
20
- def self.find(username, game_id, group_id)
21
- response = PlayStationNetwork::API.get("/#{username}/trophies/#{game_id}/groups/#{group_id}")
22
-
23
- if response.success?
24
- new(
25
- game_id,
26
- group_id,
27
- response['trophies']
28
- # response['trophyId'],
29
- # response['trophyHidden'],
30
- # response['trophyType'],
31
- # response['trophyName'],
32
- # response['trophyDetail'],
33
- # response['trophyIconUrl'],
34
- # response['trophyRare'],
35
- # response['trophyEarnedRate']
36
- )
37
- else
38
- raise response.response
39
- end
40
- end
41
-
42
- def self.all(username, game_id)
43
- response = PlayStationNetwork::API.get("/#{username}/trophies/#{game_id}")
44
-
45
- if response.success?
46
- new(
47
- game_id,
48
- nil,
49
- response['trophies']
50
- # response['trophyId'],
51
- # response['trophyHidden'],
52
- # response['trophyType'],
53
- # response['trophyName'],
54
- # response['trophyDetail'],
55
- # response['trophyIconUrl'],
56
- # response['trophyRare'],
57
- # response['trophyEarnedRate']
58
- )
59
- else
60
- raise response.response
61
- end
62
- end
63
- end
64
- end
@@ -1,30 +0,0 @@
1
- module PlayStationNetwork
2
-
3
- class TrophyGroups
4
- attr_accessor :psn_id, :groups #:group_id, :name, :description, :cover, :defined_trophies
5
-
6
- def initialize(psn_id, groups) # group_id, name, description, cover, defined_trophies)
7
-
8
- self.psn_id = psn_id
9
- self.groups = groups
10
- # self.group_id = group_id
11
- # self.name = name
12
- # self.description = description
13
- # self.cover = cover
14
- # self.defined_trophies = defined_trophies
15
- end
16
-
17
- def self.find(username, game_id)
18
- response = PlayStationNetwork::API.get("/#{username}/trophies/#{game_id}/groups")
19
-
20
- if response.success?
21
- new(
22
- game_id,
23
- response['trophyGroups']
24
- )
25
- else
26
- raise response.response
27
- end
28
- end
29
- end
30
- end