fortnite_api 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cca6d1bb30e0b2a5858ef40307a0b7a0f2716eb
4
- data.tar.gz: 353c9de03d6290c71a5d5ea3832ae22a16b86d22
3
+ metadata.gz: 8126fed6c807c55fdc434c56319ee885b061bc41
4
+ data.tar.gz: f4e0af71bd38c502079afbcc472464c7ce199dd9
5
5
  SHA512:
6
- metadata.gz: d562344bca6b3cba21bedba5ef7820f3437bcdf0eab209dde57122e31b92293284d924ba9ea81659cd585e21ec080c4c899f383c7e6af63a1b102d655497eb96
7
- data.tar.gz: 50518c28b4774e2151b3a88699e7f966e1dc619f1c05f6808edefab19a46952d002aa1c18a7bf3b589e51328c686ccbdc44c3233dde6b91a890088aa4610474b
6
+ metadata.gz: aaf47148440b762bd8e101b6409fda39cb4d9e10c58a2b7dab7802983a175e5e4c67fc6811da99b6ccdc40f3372592d90bbff666ed8517146f646c5019ad88eb
7
+ data.tar.gz: f9c9ac98792e6cb4b8e53a8706592f6f32e9100cfe0f9ba15e6eb92222e75a5c2dbdefec2d8774fb2a99a5231224c525d53f26e356df3f68f7ca5d3e3dc89131
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FortniteApi [![Build Status](https://travis-ci.org/romainr88/fortnite_api.svg?branch=master)](https://travis-ci.org/romainr88/fortnite_api)
2
2
 
3
- fortnite_api allow you to retrieve information from Fortnite in an easy way through fortnitetracker.com API.
3
+ fortnite_api allow you to retrieve informations from Fortnite in an easy way through fortnitetracker.com API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,12 +25,12 @@ Initialize the API with your fortnitetracker.com API key's:
25
25
  fortnite = FortniteApi::Api.new('Enter your API Key here')
26
26
  ```
27
27
 
28
- Enter the player's profile and the platform which you want to retrieve the information (for the platform you have the choice between 'pc' for PC, 'xbl' for Xbox and 'psn' for Playstation):
28
+ Enter the player's profile and the platform which you want to retrieve the informations (for the platform you have the choice between 'pc' for PC, 'xbl' for Xbox and 'psn' for Playstation):
29
29
  ```ruby
30
30
  player = fortnite.get_json('pc','Ninja')
31
31
  ```
32
32
 
33
- Now you have a player object with the following information:
33
+ Now you have a player object with the following informations:
34
34
 
35
35
  **Return the username:**
36
36
  ```ruby
@@ -44,28 +44,49 @@ player.platformnamelong # return the platform as a string
44
44
  => "PC"
45
45
  ```
46
46
 
47
- **Return the stats (solo, duo and squad stats):**
47
+ **Return global and current season stats (solo, duo and squad stats):**
48
+
49
+ For returning stats you have the choice between ('globalsolo', 'globalduo', 'globalsquad', 'currentsolo', 'currentduo' and 'currentsquad') and after you can get the following informations ('trnrating', 'score', 'scorepermatch', 'top1', 'top10', 'top25', 'winratio', 'kills', 'kd' and 'kpg').
48
50
  ```ruby
49
- player.stats # return the stats as a hash
50
- => {"p2"=>{"trnRating"=>{"label"=>"TRN Rating", "field"=>"TRNRating", "category"=>"Rating", "valueInt"=>4543, "value"=>"4543", "rank"=>2080,..., "value"=>"392.45", "percentile"=>0.6, "displayValue"=>"392.45"}}}
51
+ player.globalsolo.top1 # return top 1 global solo information as a hash
52
+ => {"label"=>"Wins", "field"=>"Top1", "category"=>"Tops", "valueInt"=>1843, "value"=>"1843", "percentile"=>0.1, "displayValue"=>"1,843"}
51
53
  ```
52
-
53
- **Return the lifetime stats:**
54
54
  ```ruby
55
- player.lifetimestats # return the lifetime stats as an array
56
- => [{"key"=>"Top 3", "value"=>"1518"}, {"key"=>"Top 5s", "value"=>"1318"}, {"key"=>"Top 3s", "value"=>"387"}, {"key"=>"Top 6s", "value"=>"477"},..., "value"=>"54518"}, {"key"=>"K/d", "value"=>"11.05"}]
55
+ player.globalduo.score # return score global duo stats as a hash
56
+ => {"label"=>"Score", "field"=>"Score", "category"=>"General", "valueInt"=>1780621, "value"=>"1780621", "percentile"=>0.1, "displayValue"=>"1,780,621"}
57
+ ```
58
+ ```ruby
59
+ player.globalsquad.kills # return kills global squad stats as a hash
60
+ => {"label"=>"Kills", "field"=>"Kills", "category"=>"General", "valueInt"=>27656, "value"=>"27656", "percentile"=>0.1, "displayValue"=>"27,656"}
61
+ ```
62
+ ```ruby
63
+ player.currentsolo.winratio # return winratio current solo stats as a hash
64
+ => {"label"=>"Win %", "field"=>"WinRatio", "category"=>"General", "valueDec"=>25.0, "value"=>"25", "percentile"=>0.7, "displayValue"=>"25.00"}
65
+ ```
66
+ ```ruby
67
+ player.currentduo.kpg # return kills per match current duo stats as a hash
68
+ => {"label"=>"Kills Per Match", "field"=>"KPG", "category"=>"General", "valueDec"=>5.76, "value"=>"5.76", "percentile"=>0.1, "displayValue"=>"5.76"}
69
+ ```
70
+ ```ruby
71
+ player.currentsquad.trnrating # return TRN Rating current squad stats as a hash
72
+ => {"label"=>"TRN Rating", "field"=>"TRNRating", "category"=>"Rating", "valueInt"=>4868, "value"=>"4868", "percentile"=>0.1, "displayValue"=>"4,868"}
73
+ ```
74
+ You can also custom the informations you want to get (you can retrieve all the informations of the stats, e.g., 'player.globalsolo.custom'):
75
+ ```ruby
76
+ player.globalsolo.custom['top5'] # return top 5 global solo information as a hash
77
+ => {"label"=>"Top 5", "field"=>"Top5", "category"=>"Tops", "valueInt"=>0, "value"=>"0", "displayValue"=>"0"}
57
78
  ```
58
79
 
59
- **Return the recent matches:**
80
+ **Return lifetime stats:**
60
81
  ```ruby
61
- player.recentmatches # return the recent matches as an array
62
- => [{"id"=>210645397, "accountId"=>"4735ce91-3292-4caf-8a5b-17789b40f79c", "playlist"=>"p10", "kills"=>10, "minutesPlayed"=>0, "top1"=>1, "top5"=>1,..., "trnRating"=>4472.8, "trnRatingChange"=>-12.857500000000005}]
82
+ player.lifetimestats # return lifetime stats as an array
83
+ => [{"key"=>"Top 3", "value"=>"1518"}, {"key"=>"Top 5s", "value"=>"1318"}, {"key"=>"Top 3s", "value"=>"387"}, {"key"=>"Top 6s", "value"=>"477"},..., "value"=>"54518"}, {"key"=>"K/d", "value"=>"11.05"}]
63
84
  ```
64
85
 
65
- Example:
86
+ **Return recent matches:**
66
87
  ```ruby
67
- player.stats['curr_p2']['top10'] # return the current solo top10 information
68
- => {"label"=>"Top 10", "field"=>"Top10", "category"=>"Tops", "valueInt"=>49, "value"=>"49", "rank"=>9512, "percentile"=>0.2, "displayValue"=>"49"}
88
+ player.recentmatches # return recent matches as an array
89
+ => [{"id"=>210645397, "accountId"=>"4735ce91-3292-4caf-8a5b-17789b40f79c", "playlist"=>"p10", "kills"=>10, "minutesPlayed"=>0, "top1"=>1, "top5"=>1,..., "trnRating"=>4472.8, "trnRatingChange"=>-12.857500000000005}]
69
90
  ```
70
91
 
71
92
  ## Development
data/fortnite_api.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["romainr88"]
9
9
  spec.email = ["romainr88dev@gmail.com"]
10
10
 
11
- spec.summary = "Retrieve information from Fortnite with fortnitetracker.com API"
12
- spec.description = "Retrieve information from Fortnite with fortnitetracker.com API"
11
+ spec.summary = "Retrieve informations from Fortnite with fortnitetracker.com API"
12
+ spec.description = "Retrieve informations from Fortnite with fortnitetracker.com API"
13
13
  spec.homepage = "https://github.com/romainr88/fortnite_api"
14
14
  spec.license = "MIT"
15
15
 
data/lib/fortnite_api.rb CHANGED
@@ -3,6 +3,12 @@ require 'net/http'
3
3
  require 'uri'
4
4
  require 'json'
5
5
  require 'fortnite_api/player'
6
+ require 'fortnite_api/global_solo'
7
+ require 'fortnite_api/global_duo'
8
+ require 'fortnite_api/global_squad'
9
+ require 'fortnite_api/current_solo'
10
+ require 'fortnite_api/current_duo'
11
+ require 'fortnite_api/current_squad'
6
12
 
7
13
  module FortniteApi
8
14
  class Api
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class CurrentDuo
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['curr_p10']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['curr_p10']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['curr_p10']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['curr_p10']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['curr_p10']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['curr_p10']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['curr_p10']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['curr_p10']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['curr_p10']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['curr_p10']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['curr_p10']['kpg']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class CurrentSolo
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['curr_p2']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['curr_p2']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['curr_p2']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['curr_p2']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['curr_p2']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['curr_p2']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['curr_p2']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['curr_p2']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['curr_p2']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['curr_p2']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['curr_p2']['kpg']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class CurrentSquad
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['curr_p9']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['curr_p9']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['curr_p9']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['curr_p9']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['curr_p9']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['curr_p9']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['curr_p9']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['curr_p9']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['curr_p9']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['curr_p9']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['curr_p9']['kpg']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class GlobalDuo
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['p10']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['p10']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['p10']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['p10']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['p10']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['p10']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['p10']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['p10']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['p10']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['p10']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['p10']['kpg']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class GlobalSolo
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['p2']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['p2']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['p2']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['p2']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['p2']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['p2']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['p2']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['p2']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['p2']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['p2']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['p2']['kpg']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module FortniteApi
2
+ class GlobalSquad
3
+ attr_reader :values
4
+
5
+ def initialize(hash={})
6
+ @values = hash
7
+ end
8
+
9
+ def custom
10
+ self.values['p9']
11
+ end
12
+
13
+ def trnrating
14
+ self.values['p9']['trnRating']
15
+ end
16
+
17
+ def score
18
+ self.values['p9']['score']
19
+ end
20
+
21
+ def scorepermatch
22
+ self.values['p9']['scorePerMatch']
23
+ end
24
+
25
+ def top1
26
+ self.values['p9']['top1']
27
+ end
28
+
29
+ def top10
30
+ self.values['p9']['top10']
31
+ end
32
+
33
+ def top25
34
+ self.values['p9']['top25']
35
+ end
36
+
37
+ def winratio
38
+ self.values['p9']['winRatio']
39
+ end
40
+
41
+ def kills
42
+ self.values['p9']['kills']
43
+ end
44
+
45
+ def kd
46
+ self.values['p9']['kd']
47
+ end
48
+
49
+ def kpg
50
+ self.values['p9']['kpg']
51
+ end
52
+ end
53
+ end
@@ -1,8 +1,33 @@
1
1
  module FortniteApi
2
2
  class Player
3
3
  attr_reader :epicuserhandle, :platformnamelong, :stats, :lifetimestats, :recentmatches
4
+
4
5
  def initialize(opts={})
5
6
  opts.each { |k,v| instance_variable_set("@#{k.downcase}", v) }
6
7
  end
8
+
9
+ def globalsolo
10
+ GlobalSolo.new(self.stats)
11
+ end
12
+
13
+ def globalduo
14
+ GlobalDuo.new(self.stats)
15
+ end
16
+
17
+ def globalsquad
18
+ GlobalSquad.new(self.stats)
19
+ end
20
+
21
+ def currentsolo
22
+ CurrentSolo.new(self.stats)
23
+ end
24
+
25
+ def currentduo
26
+ CurrentDuo.new(self.stats)
27
+ end
28
+
29
+ def currentsquad
30
+ CurrentSquad.new(self.stats)
31
+ end
7
32
  end
8
33
  end
@@ -1,3 +1,3 @@
1
1
  module FortniteApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortnite_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - romainr88
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-10 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Retrieve information from Fortnite with fortnitetracker.com API
55
+ description: Retrieve informations from Fortnite with fortnitetracker.com API
56
56
  email:
57
57
  - romainr88dev@gmail.com
58
58
  executables: []
@@ -72,6 +72,12 @@ files:
72
72
  - bin/setup
73
73
  - fortnite_api.gemspec
74
74
  - lib/fortnite_api.rb
75
+ - lib/fortnite_api/current_duo.rb
76
+ - lib/fortnite_api/current_solo.rb
77
+ - lib/fortnite_api/current_squad.rb
78
+ - lib/fortnite_api/global_duo.rb
79
+ - lib/fortnite_api/global_solo.rb
80
+ - lib/fortnite_api/global_squad.rb
75
81
  - lib/fortnite_api/player.rb
76
82
  - lib/fortnite_api/version.rb
77
83
  homepage: https://github.com/romainr88/fortnite_api
@@ -97,5 +103,5 @@ rubyforge_project:
97
103
  rubygems_version: 2.6.14
98
104
  signing_key:
99
105
  specification_version: 4
100
- summary: Retrieve information from Fortnite with fortnitetracker.com API
106
+ summary: Retrieve informations from Fortnite with fortnitetracker.com API
101
107
  test_files: []