playstationnetwork-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b200498d44cfa623da83873e41dfff9940c7b00
4
+ data.tar.gz: c92e1b10117b7f293e4a0ec8c59f28da4a72b760
5
+ SHA512:
6
+ metadata.gz: a552ef56dd945afa4c915503cd95071193ead38ad7267a39fb1083b9a114a825c1262b2ca1c82ba0743f20ff1b38a0c8d4e277772f09cc4e0f6e5ddf8ac937ca
7
+ data.tar.gz: 20469b4951fdedf602d08316b513aa76b0dae4540a5eff7bc89b9539b71ba0dad389082baa36ba5a0f71e3120b3be9f211d853d229f1aaecb3f80d81b9970b8a
@@ -0,0 +1,5 @@
1
+ # Ignore Gemfile.lock
2
+ *.lock
3
+
4
+ # Ignore generated .gem files
5
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'httparty'
4
+ # Specify your gem's dependencies in playstationnetwork-api.gemspec
5
+ gemspec
@@ -0,0 +1,41 @@
1
+ # Playstationnetwork::Api
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/playstationnetwork/api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'playstationnetwork-api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install playstationnetwork-api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/playstationnetwork-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ # You can add fixtures and/or initialization code here to make experimenting
6
+ # with your gem easier. You can also use a different console, if you like.
7
+
8
+ # (If you use this, don't forget to add pry to your Gemfile!)
9
+ # require 'pry'
10
+ # Pry.start
11
+
12
+ require 'irb'
13
+ require 'irb/completion'
14
+ require 'playstationnetwork-api'
15
+
16
+ def reload!
17
+ files = $LOADED_FEATURES.select { |feat| feat =~ /\/playstationnetwork\// }
18
+ files.each { |file| load file }
19
+ end
20
+
21
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ require 'playstationnetwork/version'
2
+ require 'httparty'
3
+
4
+ module PlayStationNetwork
5
+
6
+ Dir[File.dirname(__FILE__) + '/playstationnetwork/*.rb'].each do |file|
7
+ require file
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module PlayStationNetwork
2
+ module API
3
+ include HTTParty
4
+
5
+ base_uri 'http://psnapi-studio51.rhcloud.com/PSN/'
6
+
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'
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
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)
13
+ response = PSN::API.get("/#{username}/trophies")
14
+
15
+ if response.success?
16
+ self.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
@@ -0,0 +1,39 @@
1
+ module PlayStationNetwork
2
+ class Profile
3
+ attr_accessor :avatar,
4
+ :username,
5
+ :about,
6
+ :membership,
7
+ :level,
8
+ :progress,
9
+ :trophies
10
+
11
+ def initialize(avatar, username, about, membership, level, progress, trophies)
12
+ self.avatar = avatar
13
+ self.username = username
14
+ self.about = about
15
+ self.membership = membership
16
+ self.level = level
17
+ self.progress = progress
18
+ self.trophies = trophies
19
+ end
20
+
21
+ def self.find(username)
22
+ response = PlayStationNetwork::API.get("/#{username}")
23
+
24
+ if response.success?
25
+ self.new(
26
+ response['avatarUrl'],
27
+ response['onlineId'],
28
+ response['aboutMe'],
29
+ response['plus'],
30
+ response['trophySummary']['level'],
31
+ response['trophySummary']['progress'],
32
+ response['trophySummary']['earnedTrophies']
33
+ )
34
+ else
35
+ raise response.response
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ module PlayStationNetwork
2
+
3
+ class Trophy
4
+
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module PlayStationNetwork
2
+
3
+ class TrophyGroup
4
+
5
+
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module PlayStationNetwork
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ require './lib/playstationnetwork/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "playstationnetwork-api"
6
+ spec.version = PlayStationNetwork::VERSION
7
+ spec.authors = ["Vlad Radulescu"]
8
+ spec.email = ["pacMakaveli90@gmail.co.uk"]
9
+
10
+ spec.summary = %q{A ruby wrapper for PSN API}
11
+ spec.description = %q{A ruby wrapper for PSN API}
12
+ spec.homepage = ''
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split("\n")
16
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'httparty'
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
1
+ require './lib/playstationnetwork/api'
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: playstationnetwork-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vlad Radulescu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.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.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.0'
69
+ description: A ruby wrapper for PSN API
70
+ email:
71
+ - pacMakaveli90@gmail.co.uk
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/playstationnetwork-api.rb
86
+ - lib/playstationnetwork/api.rb
87
+ - lib/playstationnetwork/games.rb
88
+ - lib/playstationnetwork/profile.rb
89
+ - lib/playstationnetwork/trophy.rb
90
+ - lib/playstationnetwork/trophy_group.rb
91
+ - lib/playstationnetwork/version.rb
92
+ - playstationnetwork-api.gemspec
93
+ - spec/playstationnetwork/api_spec.rb
94
+ - spec/spec_helper.rb
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.5.1
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: A ruby wrapper for PSN API
119
+ test_files:
120
+ - spec/playstationnetwork/api_spec.rb
121
+ - spec/spec_helper.rb