pubg-rb 0.1.0

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: 404b970804250c2138b8a0f103f61108db4dfedc
4
+ data.tar.gz: '0798e8231f91bb5c1d20b4503a92b9ca5c2bb6ea'
5
+ SHA512:
6
+ metadata.gz: c7a76b5875f90cefee2018184c354b451d039c92396c1ea37bb50cea3265c62cb1d4a750941706089ef6cb7fe9c324efa7a5a8d00ff93b974c04aed1f9d3d430
7
+ data.tar.gz: 525152229c88fc134261745bacefbe6d167f1dc15a9e08bd34d42fd5afe55315d7d6a014d76a0b315af66b2805955174e0e500c80e09cffbbf26976000cf73e7
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
13
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at arubinofaux@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pubg-rb.gemspec
6
+ gemspec
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pubg-rb (0.1.0)
5
+ oj (~> 3.5.1)
6
+ typhoeus (~> 1.3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ byebug (10.0.2)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ ethon (0.11.0)
15
+ ffi (>= 1.3.0)
16
+ ffi (1.9.23)
17
+ method_source (0.9.0)
18
+ oj (3.5.1)
19
+ pry (0.11.3)
20
+ coderay (~> 1.1.0)
21
+ method_source (~> 0.9.0)
22
+ pry-byebug (3.6.0)
23
+ byebug (~> 10.0)
24
+ pry (~> 0.10)
25
+ rake (10.5.0)
26
+ rspec (3.7.0)
27
+ rspec-core (~> 3.7.0)
28
+ rspec-expectations (~> 3.7.0)
29
+ rspec-mocks (~> 3.7.0)
30
+ rspec-core (3.7.1)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-expectations (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-mocks (3.7.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.7.0)
38
+ rspec-support (3.7.1)
39
+ typhoeus (1.3.0)
40
+ ethon (>= 0.9.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.16)
47
+ pry (~> 0.11.3)
48
+ pry-byebug (~> 3.6.0)
49
+ pubg-rb!
50
+ rake (~> 10.0)
51
+ rspec (~> 3.0)
52
+
53
+ BUNDLED WITH
54
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Dan Vera
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ build:
2
+ rm -rf *.gem
3
+ gem build *.gemspec
4
+
5
+ install: build
6
+ gem install ./*.gem
7
+
8
+ console:
9
+ ./bin/console
10
+
11
+ setup:
12
+ ./bin/setup
13
+
14
+ test:
15
+ rake spec
@@ -0,0 +1,134 @@
1
+ # Pubg-rb
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/pubg`. 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
+ To install using [Bundler](https://bundler.io/) grab the latest stable version:
9
+
10
+ ```ruby
11
+ gem 'pubg-rb'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```
17
+ bundle install
18
+ ```
19
+ To manually install `pubg-rb` via [Rubygems](https://rubygems.org/) simply gem install:
20
+
21
+ ```
22
+ gem install pubg-rb
23
+ ```
24
+
25
+ To build and install the development branch yourself from latest source:
26
+
27
+ ```
28
+ git@github.com:pubstatsg/pubg-rb.git
29
+ cd pubg-rb
30
+ make install
31
+ ```
32
+
33
+ ## Battlegrounds API Documenation
34
+ [API Documentation Here](https://documentation.playbattlegrounds.com/en/introduction.html)
35
+
36
+ ## Getting Started
37
+ ### Setup Work
38
+ ```
39
+ require "pubg-rb"
40
+
41
+ # put your own credentials here
42
+ api_key = "xxxxxxxxxxxxxxxxxxxxxxxxx"
43
+ platform_region = "xbox-na"
44
+
45
+ @pubg = PUBG::Client.new(api_key, platform_region)
46
+
47
+ ```
48
+
49
+ ### Make a Call
50
+
51
+ ```
52
+ @pubg.seasons
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Usage
58
+
59
+ ### -CLIENT
60
+ Set up a client to talk to the PUBG API
61
+
62
+ ```
63
+ @pubg = PUBG::Client.new("api_key", "platform_region")
64
+ ```
65
+ - note if platform_region is set on the client it does not need to be set elsewhere
66
+
67
+ ### -PLAYERS
68
+ ##### /players
69
+ Get a collection of players by name's
70
+
71
+ ```
72
+ players = @pubg.players("acidtib,ImAverageSniper")
73
+ ```
74
+
75
+ Get a collection of players by player_id's
76
+
77
+ ```
78
+ players = @pubg.players("account.c975e15685614c5f9da44f25598f7670,account.c6d7393a0fed4613973e3d89582f23fc")
79
+ ```
80
+
81
+ ##### /players/{player_id}
82
+ Get a single player by the `player_id`
83
+
84
+ ```
85
+ player = @pubg.player("account.c975e15685614c5f9da44f25598f7670")
86
+ ```
87
+
88
+ ##### /players/{player_id}/seasons/{season_id}
89
+ Get season information for a single player
90
+
91
+ ```
92
+ season = player.season("xbox-na", "division.bro.official.xb-pre1")
93
+ ```
94
+
95
+ ### -MATCHES
96
+ #### /matches/{match_id}
97
+
98
+ ```
99
+ match = @pubg.match("895e77a8-0efa-492b-b256-3e9bf79097e6")
100
+ ```
101
+
102
+ ### -STATUS
103
+ ##### /status
104
+ Check the status of the API
105
+
106
+ ```
107
+ status = @pubg.status
108
+ ```
109
+
110
+ ### -SEASONS
111
+ ##### /seasons
112
+ Get a list of available seasons.
113
+
114
+ ```
115
+ seasons = @pubg.seasons
116
+ ```
117
+
118
+ ## Development
119
+
120
+ After checking out the repo, run `make setup` to install dependencies. Then, run `make test` to run the tests. You can also run `make console` for an interactive prompt that will allow you to experiment.
121
+
122
+ To install this gem onto your local machine, run `make 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).
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pubstatsg/pubg-rb. 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.
127
+
128
+ ## License
129
+
130
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
131
+
132
+ ## Code of Conduct
133
+
134
+ Everyone interacting in the Pubg project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pubg/blob/master/CODE_OF_CONDUCT.md).
@@ -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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pubg-rb"
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__)
@@ -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,13 @@
1
+ require "pubg/version"
2
+ require "pubg/pub_error"
3
+ require "pubg/client"
4
+ require "pubg/status"
5
+ require "pubg/player"
6
+ require "pubg/players"
7
+ require "pubg/match"
8
+ require "pubg/telemetry"
9
+ require "pubg/seasons"
10
+
11
+ module PUBG
12
+ $base_url = "https://api.playbattlegrounds.com"
13
+ end
@@ -0,0 +1,87 @@
1
+ module PUBG
2
+ require "typhoeus"
3
+ require "oj"
4
+
5
+ class Client
6
+ def initialize(api_key=nil, platform_region="xbox-na")
7
+ # TODO: raise error if api_key nil
8
+ $api_key = api_key || ENV["PUBG_API_KEY"]
9
+ $platform_region = platform_region || ENV["PUBG_PLATFORM_REGION"]
10
+ end
11
+
12
+ def player(platform_region=$platform_region, player_id)
13
+ path = "/shards/#{platform_region}/players/#{player_id}"
14
+ PUBG::Player.new(Client.request(path))
15
+ end
16
+
17
+ def players(platform_region=$platform_region, items)
18
+ if items.include?("account.")
19
+ params = "?filter[playerIds]=#{items}"
20
+ else
21
+ params = "?filter[playerNames]=#{items}"
22
+ end
23
+ path = "/shards/#{platform_region}/players#{params}"
24
+ PUBG::Players.new(request(path))
25
+ end
26
+
27
+ def match(platform_region=$platform_region, match_id)
28
+ path = "/shards/#{platform_region}/matches/#{match_id}"
29
+ PUBG::Match.new(request(path))
30
+ end
31
+
32
+ def telemetry(url)
33
+ PUBG::Telemetry.new(telemetry_request(url))
34
+ end
35
+
36
+ def seasons(platform_region=$platform_region)
37
+ path = "/shards/#{platform_region}/seasons"
38
+ PUBG::Seasons.new(request(path))
39
+ end
40
+
41
+ def status
42
+ path = "/status"
43
+ PUBG::Status.new(Client.request(path))
44
+ end
45
+
46
+ def self.request(path)
47
+ request = Typhoeus.get(
48
+ [$base_url, path].join(""),
49
+ headers: {
50
+ Accept: "application/vnd.api+json",
51
+ Authorization: "Bearer #{$api_key}"
52
+ }
53
+ )
54
+
55
+ response = Oj.load(request.body)
56
+
57
+ case request.code
58
+ when 404
59
+ raise PUBError.new(response["errors"][0]["title"])
60
+ when 429
61
+ raise PUBError.new("RateLimit-Limit reached")
62
+ end
63
+
64
+ return response
65
+ end
66
+
67
+ def telemetry_request(url)
68
+ request = Typhoeus.get(
69
+ url,
70
+ headers: {
71
+ Accept: "application/vnd.api+json"
72
+ }
73
+ )
74
+
75
+ response = Oj.load(request.body)
76
+
77
+ case request.code
78
+ when 404, 403
79
+ raise PUBError.new("Cant find telemetry file")
80
+ when 500
81
+ raise PUBError.new("Server error")
82
+ end
83
+
84
+ return response
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,32 @@
1
+ module PUBG
2
+ class Match
3
+ require "pubg/match/participants"
4
+ require "pubg/match/telemetry"
5
+ require "pubg/match/roster"
6
+
7
+ attr_reader :data, :included, :links, :meta, :telemetry, :participants, :roster
8
+
9
+ def initialize(args)
10
+ @data = args["data"]
11
+ @included = args["included"]
12
+ @links = args["links"]
13
+ @meta = args["meta"]
14
+ @participants = []
15
+ @roster = []
16
+ @telemetry = Telemetry.new(@included.select {|data| data["type"] == "asset" }.first)
17
+ included_apart
18
+ end
19
+
20
+ def included_apart
21
+ participants = @included.select {|data| data["type"] == "participant" }
22
+ participants.each do |participant|
23
+ @participants << Participants.new(participant)
24
+ end
25
+
26
+ rosters = @included.select {|data| data["type"] == "roster" }
27
+ rosters.each do |roster|
28
+ @roster << Roster.new(roster)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module PUBG
2
+ class Match
3
+ class Participants
4
+ require "pubg/match/participants/attributes"
5
+
6
+ attr_reader :type, :id, :attributes, :actor, :sharId
7
+
8
+ def initialize(args)
9
+ @type = args["type"]
10
+ @id = args["id"]
11
+ @attributes = Attributes.new(args["attributes"])
12
+ @actor = args["attributes"]["actor"]
13
+ @shardId = args["attributes"]["shardId"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ module PUBG
2
+ class Match
3
+ class Participants
4
+ class Attributes
5
+ attr_reader :DBNOs, :assists, :boosts, :damageDealt, :deathType, :headshotKills, :heals, :killPlace,
6
+ :killPoints, :killPointsDelta, :killStreaks, :kills, :lastKillPoints, :lastWinPoints,
7
+ :longestKill, :mostDamage, :name, :playerId, :revives, :rideDistance, :roadKills,
8
+ :teamKills, :timeSurvived, :vehicleDestroys, :walkDistance, :weaponsAcquired,
9
+ :winPlace, :winPoints, :winPointsDelta
10
+
11
+ def initialize(args)
12
+ @DBNOs = args["stats"]["DBNOs"]
13
+ @assists = args["stats"]["assists"]
14
+ @boosts = args["stats"]["boosts"]
15
+ @damageDealt = args["stats"]["damageDealt"]
16
+ @deathType = args["stats"]["deathType"]
17
+ @headshotKills = args["stats"]["headshotKills"]
18
+ @heals = args["stats"]["heals"]
19
+ @killPlace = args["stats"]["killPlace"]
20
+ @killPoints = args["stats"]["killPoints"]
21
+ @killPointsDelta = args["stats"]["killPointsDelta"]
22
+ @killStreaks = args["stats"]["killStreaks"]
23
+ @kills = args["stats"]["kills"]
24
+ @lastKillPoints = args["stats"]["lastKillPoints"]
25
+ @lastWinPoints = args["stats"]["lastWinPoints"]
26
+ @longestKill = args["stats"]["longestKill"]
27
+ @mostDamage = args["stats"]["mostDamage"]
28
+ @name = args["stats"]["name"]
29
+ @playerId = args["stats"]["playerId"]
30
+ @revives = args["stats"]["revives"]
31
+ @rideDistance = args["stats"]["rideDistance"]
32
+ @roadKills = args["stats"]["roadKills"]
33
+ @teamKills = args["stats"]["teamKills"]
34
+ @timeSurvived = args["stats"]["timeSurvived"]
35
+ @vehicleDestroys = args["stats"]["vehicleDestroys"]
36
+ @walkDistance = args["stats"]["walkDistance"]
37
+ @weaponsAcquired = args["stats"]["weaponsAcquired"]
38
+ @winPlace = args["stats"]["winPlace"]
39
+ @winPoints = args["stats"]["winPoints"]
40
+ @winPointsDelta = args["stats"]["winPointsDelta"]
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ module PUBG
2
+ class Match
3
+ class Roster
4
+ require "pubg/match/roster/attributes"
5
+ require "pubg/match/roster/relationships"
6
+
7
+ attr_reader :type, :id, :attributes, :relationships
8
+
9
+ def initialize(args)
10
+ @type = args["type"]
11
+ @id = args["id"]
12
+ @attributes = Attributes.new(args["attributes"])
13
+ @relationships = Relationships.new(args["relationships"])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module PUBG
2
+ class Match
3
+ class Roster
4
+ class Attributes
5
+ attr_reader :stats, :won, :shardId
6
+
7
+ def initialize(args)
8
+ @stats = Stats.new(args["stats"])
9
+ @won = args["won"]
10
+ @shardId = args["shardId"]
11
+ end
12
+
13
+ # ----------------
14
+ class Stats
15
+ attr_reader :rank, :teamId
16
+
17
+ def initialize(args)
18
+ @rank = args["rank"]
19
+ @teamId = args["teamId"]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ module PUBG
2
+ class Match
3
+ class Roster
4
+ class Relationships
5
+ attr_reader :team, :participants
6
+
7
+ def initialize(args)
8
+ @args = args
9
+ @team = args["team"]["data"]
10
+ @participants = Array.new
11
+ get_participants
12
+ end
13
+
14
+ def get_participants
15
+ @args["participants"]["data"].each do |participant|
16
+ @participants << Participants.new(participant)
17
+ end
18
+ end
19
+
20
+ # -----------------
21
+ class Participants
22
+ attr_reader :type, :id
23
+
24
+ def initialize(args)
25
+ @type = args["type"]
26
+ @id = args["id"]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ module PUBG
2
+ class Match
3
+ class Telemetry
4
+ attr_reader :name, :description, :createdAt, :URL
5
+
6
+ def initialize(args)
7
+ @name = args["attributes"]["name"]
8
+ @description = args["attributes"]["description"]
9
+ @createdAt = args["attributes"]["createdAt"]
10
+ @URL = args["attributes"]["URL"]
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ module PUBG
2
+ class Player
3
+ require "pubg/player/matches"
4
+ require "pubg/player/player"
5
+ require "pubg/player/season"
6
+
7
+ attr_reader :data, :links, :meta, :player, :matches, :season
8
+
9
+ def initialize(args)
10
+ if args["data"]
11
+ args = args["data"]
12
+ end
13
+
14
+ @data = args
15
+ @links = args["links"]
16
+ @meta = args["meta"]
17
+ @player = Player.new(@data["attributes"])
18
+ @matches = get_matches
19
+ @player_id = @data["id"]
20
+ @season = nil
21
+ end
22
+
23
+ def get_matches
24
+ matches = []
25
+ @data["relationships"]["matches"]["data"].each do |match|
26
+ matches << Matches.new(match)
27
+ end
28
+ return matches
29
+ end
30
+
31
+ def season(platform_region=$platform_region, season_id=nil)
32
+ Season.new(platform_region, @player_id, season_id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ module PUBG
2
+ class Player
3
+ class Matches
4
+ attr_reader :type, :id
5
+
6
+ def initialize(args)
7
+ @type = args["type"]
8
+ @id = args["id"]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module PUBG
2
+ class Player
3
+ class Player
4
+ attr_reader :name, :stats, :titleId, :shardId, :createdAt, :updatedAt, :patchVersion
5
+
6
+ def initialize(args)
7
+ @name = args["name"]
8
+ @stats = args["stats"]
9
+ @titleId = args["titleId"]
10
+ @shardId = args["shardId"]
11
+ @createdAt = args["createdAt"]
12
+ @updatedAt = args["updatedAt"]
13
+ @patchVersion = args["patchVersion"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module PUBG
2
+ class Player
3
+ class Season
4
+ attr_reader :data, :links, :meta
5
+
6
+ def initialize(platform_region=$platform_region, player_id, season_id)
7
+ @platform_region = platform_region
8
+ @player_id = player_id
9
+ @season_id = season_id
10
+
11
+ @data = nil
12
+ @links = nil
13
+ @meta = nil
14
+
15
+ get_season
16
+ end
17
+
18
+ def get_season
19
+ path = "/shards/#{@platform_region}/players/#{@player_id}/seasons/#{@season_id}"
20
+ season = Client.request(path)
21
+ @data = season["data"]
22
+ @links = season["links"]
23
+ @meta = season["meta"]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module PUBG
2
+ class Players
3
+ attr_reader :data, :links, :meta
4
+
5
+ def initialize(args)
6
+ @data = args["data"]
7
+ @links = args["links"]
8
+ @meta = args["meta"]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class PUBError < StandardError
2
+ def initialize(msg="Opps something happened")
3
+ super(msg)
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module PUBG
2
+ class Seasons
3
+ attr_reader :data, :links, :meta
4
+
5
+ def initialize(args)
6
+ @data = args["data"]
7
+ @links = args["links"]
8
+ @meta = args["meta"]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module PUBG
2
+ class Status
3
+ require "pubg/status/attributes"
4
+
5
+ attr_reader :data, :attributes
6
+
7
+ def initialize(args)
8
+ @data = args["data"]
9
+ @attributes = Attributes.new(@data["attributes"])
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module PUBG
2
+ class Status
3
+ class Attributes
4
+ attr_reader :version, :releasedAt
5
+
6
+ def initialize(args)
7
+ @version = args["version"]
8
+ @releasedAt = args["releasedAt"]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,56 @@
1
+ module PUBG
2
+ class Telemetry
3
+ require "pubg/telemetry/LogPlayerLogin"
4
+ require "pubg/telemetry/LogPlayerCreate"
5
+ require "pubg/telemetry/LogPlayerPosition"
6
+ require "pubg/telemetry/LogPlayerAttack"
7
+
8
+ attr_reader :events
9
+
10
+ def initialize(args)
11
+ @args = args
12
+ @events = Array.new
13
+ @LogPlayerLogin = nil
14
+ @LogPlayerCreate = nil
15
+ @LogPlayerPosition = nil
16
+ @LogPlayerAttack = nil
17
+
18
+ @LogItemPickup = nil
19
+ @LogItemEquip = nil
20
+ @LogItemUnequip = nil
21
+ @LogVehicleRide = nil
22
+ @LogMatchDefinition = nil
23
+ @LogMatchStart = nil
24
+ @LogGameStatePeriodic = nil
25
+ @LogVehicleLeave = nil
26
+ @LogPlayerTakeDamage = nil
27
+ @LogPlayerLogout = nil
28
+ @LogItemAttach = nil
29
+ @LogItemDrop = nil
30
+ @LogPlayerKill = nil
31
+ @LogItemDetach = nil
32
+ @LogItemUse = nil
33
+ @LogCarePackageSpawn = nil
34
+ @LogVehicleDestroy = nil
35
+ @LogCarePackageLand = nil
36
+ @LogMatchEnd = nil
37
+
38
+ process_telemetry
39
+ end
40
+
41
+ def process_telemetry
42
+ @args.each do |event|
43
+ case event["_T"]
44
+ when "LogPlayerLogin"
45
+ @events << LogPlayerLogin.new(event)
46
+ when "LogPlayerCreate"
47
+ @events << LogPlayerCreate.new(event)
48
+ when "LogPlayerPosition"
49
+ @events << LogPlayerPosition.new(event)
50
+ when "LogPlayerAttack"
51
+ @events << LogPlayerAttack.new(event)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,19 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class LogPlayerAttack
4
+ require "pry"
5
+
6
+ # attr_reader :character, :elapsedtime, :numaliveplayers, :_V, :_D, :_T
7
+
8
+ def initialize(args)
9
+ binding.pry
10
+ @character = Character.new(args["Character"])
11
+ @elapsedtime = args["ElapsedTime"]
12
+ @numaliveplayers = args["NumAlivePlayers"]
13
+ @_V = args["_V"]
14
+ @_D = args["_D"]
15
+ @_T = args["_T"]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class LogPlayerCreate
4
+ require "pubg/telemetry/events/shared/character"
5
+
6
+ attr_reader :character, :_V, :_D, :_T
7
+
8
+ def initialize(args)
9
+ @character = Character.new(args["Character"])
10
+ @_V = args["_V"]
11
+ @_D = args["_D"]
12
+ @_T = args["_T"]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class LogPlayerLogin
4
+ attr_reader :Result, :ErrorMessage, :AccountId, :_V, :_D, :_T
5
+
6
+ def initialize(args)
7
+ @Result = args["Result"]
8
+ @ErrorMessage = args["ErrorMessage"]
9
+ @AccountId = args["AccountId"]
10
+ @_V = args["_V"]
11
+ @_D = args["_D"]
12
+ @_T = args["_T"]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class LogPlayerPosition
4
+ require "pubg/telemetry/events/shared/character"
5
+
6
+ attr_reader :character, :elapsedtime, :numaliveplayers, :_V, :_D, :_T
7
+
8
+ def initialize(args)
9
+ @character = Character.new(args["Character"])
10
+ @elapsedtime = args["ElapsedTime"]
11
+ @numaliveplayers = args["NumAlivePlayers"]
12
+ @_V = args["_V"]
13
+ @_D = args["_D"]
14
+ @_T = args["_T"]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class Character
4
+ require "pubg/telemetry/events/shared/location"
5
+
6
+ attr_reader :name, :teamId, :health, :location, :ranking, :accountId
7
+
8
+ def initialize(args)
9
+ @name = args["Name"]
10
+ @teamId = args["TeamId"]
11
+ @health = args["Health"]
12
+ @location = Location.new(args["Location"])
13
+ @ranking = args["Ranking"]
14
+ @accountId = args["AccountId"]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module PUBG
2
+ class Telemetry
3
+ class Character
4
+ class Location
5
+ attr_reader :x, :y, :z
6
+
7
+ def initialize(args)
8
+ @x = args["X"]
9
+ @y = args["Y"]
10
+ @z = args["Z"]
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module PUBG
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "pubg/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pubg-rb"
8
+ spec.version = PUBG::VERSION
9
+ spec.authors = ["Dainel Vera"]
10
+ spec.email = ["arubinofaux@gmail.com"]
11
+
12
+ spec.summary = %q{An open-source wrapper for the official PlayerUnknown's Battleground API}
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/pubstatsg/pubg-rb"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "pry", "~> 0.11.3"
28
+ spec.add_development_dependency "pry-byebug", "~> 3.6.0"
29
+
30
+ spec.add_dependency "typhoeus", "~> 1.3.0"
31
+ spec.add_dependency "oj", "~> 3.5.1"
32
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pubg-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dainel Vera
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-01 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: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.11.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.11.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.6.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: typhoeus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: oj
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.5.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.5.1
111
+ description:
112
+ email:
113
+ - arubinofaux@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".DS_Store"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - Makefile
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - lib/.DS_Store
132
+ - lib/pubg-rb.rb
133
+ - lib/pubg/client.rb
134
+ - lib/pubg/match.rb
135
+ - lib/pubg/match/participants.rb
136
+ - lib/pubg/match/participants/attributes.rb
137
+ - lib/pubg/match/roster.rb
138
+ - lib/pubg/match/roster/attributes.rb
139
+ - lib/pubg/match/roster/relationships.rb
140
+ - lib/pubg/match/telemetry.rb
141
+ - lib/pubg/player.rb
142
+ - lib/pubg/player/matches.rb
143
+ - lib/pubg/player/player.rb
144
+ - lib/pubg/player/season.rb
145
+ - lib/pubg/players.rb
146
+ - lib/pubg/pub_error.rb
147
+ - lib/pubg/seasons.rb
148
+ - lib/pubg/status.rb
149
+ - lib/pubg/status/attributes.rb
150
+ - lib/pubg/telemetry.rb
151
+ - lib/pubg/telemetry/.DS_Store
152
+ - lib/pubg/telemetry/LogPlayerAttack.rb
153
+ - lib/pubg/telemetry/LogPlayerCreate.rb
154
+ - lib/pubg/telemetry/LogPlayerLogin.rb
155
+ - lib/pubg/telemetry/LogPlayerPosition.rb
156
+ - lib/pubg/telemetry/events/shared/character.rb
157
+ - lib/pubg/telemetry/events/shared/location.rb
158
+ - lib/pubg/version.rb
159
+ - pubg-rb.gemspec
160
+ homepage: https://github.com/pubstatsg/pubg-rb
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.6.11
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: An open-source wrapper for the official PlayerUnknown's Battleground API
184
+ test_files: []