pubg-api 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a377758b6f090dad9e977de35b6cd37313f1539c
4
+ data.tar.gz: 1cd53585b194e829df6df47997980b80e50de1e9
5
+ SHA512:
6
+ metadata.gz: ba0a92066018c989d8dcf43691a6cbdead339ef7b79253a0459fef3a3f7ad5bbff934ec4eb7e30b9249ba4a09408e55f53cabb6307be49e051f4ce2883acdb60
7
+ data.tar.gz: a3f0400e7b7f1c34bf5b2000a639525d1526ede88a2c978dbdbe630f3b411e27758d6b56fa398135c9f87bf82c37aa1d45871b743798dc4c4213cca0e497d860
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16
6
+ cache: bundler
7
+ script:
8
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby-pubg-api.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2018 Vinicius Zago
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # PubgApi
2
+ This is a simple ruby wrapper for https://pubgtracker.com/site-api
3
+
4
+ ## Installation
5
+
6
+ Add to `Gemfile`
7
+
8
+ ```ruby
9
+ gem 'pubg-api'
10
+ ```
11
+
12
+ ## Configuration
13
+
14
+ The following configuration need to be setup to your code.
15
+
16
+ ```ruby
17
+ Pubg.configure do |c|
18
+ c.trn_api_key = 'trn_api_key'
19
+ end
20
+ ```
21
+
22
+ If you are using rails, you can create a file in `config/initializers`.
23
+
24
+ ## Usage Examples
25
+
26
+ **Retrieve a player status by nickname.**
27
+
28
+ ```ruby
29
+ Pubg::Player.find('playername')
30
+ ```
31
+ Open [here](https://github.com/viniciuszago/ruby-pubg-api/blob/master/spec/fixtures/player/player_data.json) an example of response for this request.
32
+
33
+ **This will get all the stats for the current season.**
34
+ **You may get more data by using filters. season, mode, region**
35
+
36
+ ```ruby
37
+ Pubg::Player.find('playername', {
38
+ mode: 'solo',
39
+ season: '2018-01',
40
+ region: 'sa'
41
+ })
42
+ ```
43
+
44
+
45
+ ----------
46
+
47
+
48
+ **Matches status for a given player account**
49
+
50
+ ```ruby
51
+ Pubg::Matches.find('account.9e915505fad245f696944e4b108986fa')
52
+ ```
53
+ Open [here](https://github.com/viniciuszago/ruby-pubg-api/blob/master/spec/fixtures/matches/all_matches.json) an example of response for this request.
54
+
55
+ ## Running the tests
56
+
57
+ Spec files are located under `/spec` directory. You can run them using `rspec` command.
58
+
59
+ ## License
60
+
61
+ This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/viniciuszago/ruby-pubg-api/blob/master/LICENSE.md) file for details
62
+
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pubg/api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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
data/lib/pubg.rb ADDED
@@ -0,0 +1,16 @@
1
+ module Pubg
2
+ def self.configure
3
+ yield @config ||= Pubg::Config.new
4
+ end
5
+
6
+ def self.config
7
+ @config
8
+ end
9
+ end
10
+
11
+ require 'pubg/config'
12
+
13
+ require 'pubg/base_connection'
14
+ require 'pubg/player'
15
+ require 'pubg/matches'
16
+ require 'pubg/version'
@@ -0,0 +1,21 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module Pubg
5
+ class BaseConnection
6
+ PUBG_API_VERSION = "v2".freeze
7
+ BASE_URL = "https://api.pubgtracker.com/#{PUBG_API_VERSION}/".freeze
8
+
9
+ def call(service)
10
+ uri = URI(BASE_URL + service)
11
+ req = Net::HTTP::Get.new(uri)
12
+ req["TRN-Api-Key"] = Pubg.config.trn_api_key
13
+
14
+ res = Net::HTTP.start(uri.hostname) {|http|
15
+ http.request(req)
16
+ }
17
+
18
+ JSON.parse res.body, symbolize_names: true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Pubg
2
+ class Config
3
+ attr_accessor :trn_api_key
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Pubg
2
+ class Matches
3
+ def self.find(account_id)
4
+ Pubg::BaseConnection.new.call("matches/pc/#{account_id}")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Pubg
2
+ class Player
3
+ def self.find(player_name, filters = {})
4
+ filters = URI.encode_www_form(filters)
5
+
6
+ Pubg::BaseConnection.new.call("profile/pc/#{player_name}?#{filters}")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Pubg
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require "pubg/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "pubg-api"
9
+ spec.version = Pubg::VERSION
10
+ spec.authors = ["Vinicius Zago"]
11
+ spec.email = ["mvinicius.zago@gmail.com"]
12
+
13
+ spec.summary = "A Ruby wrapper for https://pubgtracker.com/site-api"
14
+ spec.description = ""
15
+ spec.homepage = "https://github.com/viniciuszago/ruby-pubg-api"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
22
+ # else
23
+ # raise "RubyGems 2.0 or newer is required to protect against " \
24
+ # "public gem pushes."
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.16"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "webmock", "~> 3.3"
38
+ spec.add_development_dependency "pry"
39
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pubg-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vinicius Zago
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ''
84
+ email:
85
+ - mvinicius.zago@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.md
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/pubg.rb
100
+ - lib/pubg/base_connection.rb
101
+ - lib/pubg/config.rb
102
+ - lib/pubg/matches.rb
103
+ - lib/pubg/player.rb
104
+ - lib/pubg/version.rb
105
+ - ruby-pubg-api.gemspec
106
+ homepage: https://github.com/viniciuszago/ruby-pubg-api
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A Ruby wrapper for https://pubgtracker.com/site-api
130
+ test_files: []