playstationnetwork-api 2.1.2 → 2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5b9b7df510bfc8a63fa11d22d7df2b71d4995a48
4
- data.tar.gz: bfaa01f192a7fa3947b970fc4be2200ef7c95359
2
+ SHA256:
3
+ metadata.gz: c8cde5f136529fe70ed2ff0ba248bb9bce19b3cd239fcba0447d3012c9f13c99
4
+ data.tar.gz: 69853132e57e9c6f9a78b16a268d37471c10da3ae4c9734ff8738762613b0778
5
5
  SHA512:
6
- metadata.gz: 21798f59011e728095efe55e76ce331d138a7f2f5c101f0c048791f72574599b5190b0606a9112a4439ba12aed8b8262081ebb205bf1cb3814d5cbcf59661424
7
- data.tar.gz: a54fe341db147350244270536b8a1d5a1068a514dc5da886462cf5916b97bfdaba2910411a9a5081c180f1e04c6641d412752b456e64ca12027e78f2918a6b3f
6
+ metadata.gz: 0c782e782b3f3b4216235f33e8901ed7e74f97ad200465ec7ef7e5f1db4aaa8a5ea0170dcd39412926892abf2c01c33eaa659ae2a7673477e5f7afe12d240b0a
7
+ data.tar.gz: 368acdefb82b2a0194c649a48c3b9251705b253e37d97f43a80daea6a72830db4bd9c1f9107970d16d97080cc1167a276d6a9c8060f4c5fa1cc0c5227cdc7a19
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
1
  # Ignore Gemfile.lock
2
+ #
2
3
  *.lock
3
4
 
4
5
  # Ignore generated .gem files
6
+ #
5
7
  *.gem
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ gemspec
data/README.md CHANGED
@@ -7,7 +7,7 @@ Retrieve User, Trophies and Game data from PlayStationNetwork.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'playstationnetwork-api', '~> 2.0'
10
+ gem 'playstationnetwork-api', '~> 2.1'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -40,7 +40,7 @@ Or install it yourself as:
40
40
 
41
41
 
42
42
  #### Get all Games
43
- `PlayStationNetwork::Game.new().all(platform: 'ps4') # you don't have to pass an argument. By default, it will get all games.`
43
+ `PlayStationNetwork::Game.new().all(platform: 'ps4') # you don't have to pass an argument. It will get all games by default.`
44
44
 
45
45
  #### Get Popular Games
46
46
  `PlayStationNetwork::Game.new().all(popular: true)`
@@ -54,10 +54,23 @@ PlayStationNetwork::API.configure do |config|
54
54
  config.key = '<API_KEY>',
55
55
  config.secret = '<API_SECRET>'
56
56
  config.url = '<API_URL>'
57
+ config.verify_ssl = boolean ( default is true )
57
58
  })
59
+
60
+ # visit: http://www.psnleaderboard.com/ to get your key, secret and endpoint details
61
+ ```
62
+
63
+ `verify_ssl` was introduced in v2.1.0 in order to fix an error returned by the API when communicating through SSL.
64
+ If you get the following error when trying to access the API, set `verify_ssl` to `false`
65
+ ```
66
+ {
67
+ success: false,
68
+ code: 500,
69
+ message: #<OpenSSL::SSL::SSLError: hostname '<API_URL>' does not match the server certificate>
70
+ }
58
71
  ```
59
72
 
60
- Get Endpoint, your Key and Secret from: http://www.psnleaderboard.com/
73
+ Please note this option may be removed in a future release when a proper fix will be implemented.
61
74
 
62
75
  ## Development
63
76
 
@@ -29,15 +29,14 @@ module PlayStationNetwork
29
29
 
30
30
  module API
31
31
  include HTTParty
32
-
33
- # base_uri ""
34
-
35
32
  extend self
36
33
 
37
- MISSING_CONFIGURATION ||= "You must configure the PlayStationNetwork module before using this Gem. See the README.md for how to configure it"
38
- MISSING_URL ||= "You must pass the 'url' to the PlayStationNetwork module before using this Gem. See the README.md for how to configure it"
39
- MISSING_KEY ||= "You must pass your 'key' to the PlayStationNetwork module before using this Gem. See the README.md for how to configure it"
40
- MISSING_SECRET ||= "You must pass your 'secret' to the PlayStationNetwork module before using this Gem. See the README.md for how to configure it"
34
+ DEFAULT_MESSAGE ||= 'the PlayStationNetwork module before using this gem. See the README.md for how to configure it'
35
+
36
+ MISSING_CONFIGURATION ||= 'You must configure ' + DEFAULT_MESSAGE
37
+ MISSING_URL ||= "You must pass the 'url' to " + DEFAULT_MESSAGE
38
+ MISSING_KEY ||= "You must pass your 'key' to " + DEFAULT_MESSAGE
39
+ MISSING_SECRET ||= "You must pass your 'secret' to " + DEFAULT_MESSAGE
41
40
 
42
41
  def request
43
42
  handle_response do
@@ -78,7 +77,7 @@ module PlayStationNetwork
78
77
  JSON.parse(request)[reduce_to]
79
78
  end
80
79
  rescue
81
- raise "There was a problem parsing the JSON. Most likely an API problem."
80
+ raise 'There was a problem parsing the JSON. Most likely an API problem.'
82
81
  end
83
82
  else
84
83
  raise request.response
@@ -9,7 +9,7 @@ module PlayStationNetwork
9
9
  INVALID_PLATFORM_PARAM ||= "'platform' needs to be one of #{ GAMES_PARAMETERS_TYPES.join(', ') }"
10
10
  INVALID_POPULAR_TYPE ||= "'popular' parameter needs to be a Boolean"
11
11
 
12
- def initialize(npcommid = "")
12
+ def initialize(npcommid = '')
13
13
  PlayStationNetwork::API.handle_response do
14
14
  raise INVALID_NPCOMMID_TYPE unless npcommid.is_a?(String)
15
15
 
@@ -52,7 +52,7 @@ module PlayStationNetwork
52
52
  begin
53
53
  parse_xml(request)['psn_api']
54
54
  rescue
55
- raise "There was a problem parsing the XML response"
55
+ raise 'There was a problem parsing the XML response'
56
56
  end
57
57
  else
58
58
  raise request.response
@@ -0,0 +1,83 @@
1
+ module PlayStationNetwork
2
+ class Store
3
+ include HTTParty
4
+ base_uri "https://store.playstation.com"
5
+
6
+ attr_reader :args, :region, :language
7
+
8
+ def initialize(args, region: 'GB', language: 'en')
9
+ @args = args
10
+ @region = region
11
+ @language = language
12
+ end
13
+
14
+ def search(game_type = 'Full Game')
15
+ raise '' unless game_type != 'Full Game' || game_type != 'Bundle'
16
+
17
+ options = {
18
+ headers: {
19
+ "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
20
+ "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
21
+ "Authority" => "store.playstation.com"
22
+ },
23
+
24
+ query: {
25
+ suggested_size: 5,
26
+ mode: 'game'
27
+ }
28
+ }
29
+
30
+ request = self.class.get(search_url(args), options)
31
+
32
+ if request.success?
33
+ response = []
34
+
35
+ results = request.parsed_response['included'].select do |result|
36
+ result['attributes']['game-content-type'] == game_type
37
+ end
38
+
39
+ results.each do |result|
40
+ response << {
41
+ store_id: result['id'],
42
+ name: result['attributes']['name'],
43
+ description: result['attributes']['long-description'],
44
+ type: result['type'],
45
+ raw: result
46
+ }
47
+ end
48
+
49
+ return response
50
+ else
51
+ raise request.response
52
+ end
53
+ end
54
+
55
+ def details
56
+ options = {
57
+ headers: {
58
+ "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
59
+ "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
60
+ "Authority" => "store.playstation.com"
61
+ }
62
+ }
63
+
64
+ request = self.class.get(details_url(args), options)
65
+
66
+ if request.success?
67
+ return request.parsed_response
68
+ else
69
+ raise request.response
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def search_url(query)
76
+ "/valkyrie-api/#{ language }/#{ region }/19/tumbler-search/#{ URI.encode(query) }"
77
+ end
78
+
79
+ def details_url(identifier)
80
+ "/store/api/chihiro/00_09_000/container/#{ region }/#{ language }/19/#{ identifier }"
81
+ end
82
+ end
83
+ end
@@ -1,5 +1,5 @@
1
1
  module PlayStationNetwork
2
- VERSION ||= '2.1.2'
2
+ VERSION ||= '2.2'
3
3
 
4
4
  def self.changelog
5
5
  puts "
@@ -50,6 +50,9 @@ module PlayStationNetwork
50
50
 
51
51
  v2.1.2
52
52
  - Added 'verify: false' option introduced in v2.1.0 as a configurable option in the initializer
53
+
54
+ v2.2
55
+ - Added experimental PlayStation Store endpoint
53
56
  "
54
57
  end
55
58
  end
@@ -5,20 +5,20 @@ Gem::Specification.new do |spec|
5
5
  spec.name = 'playstationnetwork-api'
6
6
  spec.version = PlayStationNetwork::VERSION
7
7
  spec.authors = ['Vlad Radulescu']
8
- spec.email = ['vlad@games.directory']
8
+ spec.email = ['oss@games.directory']
9
9
 
10
- spec.summary = %q{ A Ruby wrapper for PSN Leaderboard API }
11
- spec.description = %q{ A Ruby wrapper around PSN Leaderboard's API for grabbing Users, Games and Trophies }
10
+ spec.summary = %q{ A Ruby wrapper around PSN Leaderboard's API }
11
+ spec.description = %q{ Allows your app to communicate with the PlayStation Network API and retrieve your, or a given user, Games, Trophies and Achievements. API is provided by psnloaderboard.com . }
12
12
  spec.homepage = ''
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split("\n")
16
16
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'httparty', '~> 0.15.6'
21
- spec.add_development_dependency 'bundler', '~> 1.15.3'
22
- spec.add_development_dependency 'rake', '~> 12.0.0'
23
- spec.add_development_dependency 'rspec', '~> 3.6.0'
20
+ spec.add_dependency 'httparty', '~> 0.16.2'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.16'
23
+ spec.add_development_dependency 'rake', '~> 12.3'
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playstationnetwork-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Radulescu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-14 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,60 +16,47 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.15.6
19
+ version: 0.16.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.15.6
26
+ version: 0.16.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.15.3
33
+ version: '1.16'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.15.3
40
+ version: '1.16'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 12.0.0
47
+ version: '12.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 12.0.0
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 3.6.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 3.6.0
69
- description: " A Ruby wrapper around PSN Leaderboard's API for grabbing Users, Games
70
- and Trophies "
54
+ version: '12.3'
55
+ description: " Allows your app to communicate with the PlayStation Network API and
56
+ retrieve your, or a given user, Games, Trophies and Achievements. API is provided
57
+ by psnloaderboard.com . "
71
58
  email:
72
- - vlad@games.directory
59
+ - oss@games.directory
73
60
  executables:
74
61
  - console
75
62
  - setup
@@ -77,20 +64,17 @@ extensions: []
77
64
  extra_rdoc_files: []
78
65
  files:
79
66
  - ".gitignore"
80
- - ".rspec"
81
67
  - Gemfile
82
68
  - README.md
83
- - Rakefile
84
69
  - bin/console
85
70
  - bin/setup
86
71
  - lib/playstationnetwork-api.rb
87
72
  - lib/playstationnetwork/api.rb
88
73
  - lib/playstationnetwork/game.rb
74
+ - lib/playstationnetwork/store.rb
89
75
  - lib/playstationnetwork/user.rb
90
76
  - lib/playstationnetwork/version.rb
91
77
  - playstationnetwork-api.gemspec
92
- - spec/playstationnetwork/api_spec.rb
93
- - spec/spec_helper.rb
94
78
  homepage: ''
95
79
  licenses:
96
80
  - MIT
@@ -111,11 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
95
  version: '0'
112
96
  requirements: []
113
97
  rubyforge_project:
114
- rubygems_version: 2.6.12
98
+ rubygems_version: 2.7.6
115
99
  signing_key:
116
100
  specification_version: 4
117
- summary: A Ruby wrapper for PSN Leaderboard API
118
- test_files:
119
- - spec/playstationnetwork/api_spec.rb
120
- - spec/spec_helper.rb
121
- has_rdoc:
101
+ summary: A Ruby wrapper around PSN Leaderboard's API
102
+ test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PlayStationNetwork do
4
- it 'has a version number' do
5
- expect(PlayStationNetwork::VERSION).not_to be nil
6
- end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
- end
@@ -1 +0,0 @@
1
- require './lib/playstationnetwork/api'