valorant 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +18 -0
- data/README.md +29 -0
- data/Rakefile +29 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/valorant/account.rb +13 -0
- data/lib/valorant/match.rb +22 -0
- data/lib/valorant/misc.rb +27 -0
- data/lib/valorant/mmr.rb +27 -0
- data/lib/valorant/utils/article.rb +16 -0
- data/lib/valorant/utils/articles.rb +14 -0
- data/lib/valorant/utils/leader.rb +39 -0
- data/lib/valorant/utils/leader_board.rb +14 -0
- data/lib/valorant/utils/match.rb +97 -0
- data/lib/valorant/utils/matches_history.rb +21 -0
- data/lib/valorant/utils/mmr_history.rb +21 -0
- data/lib/valorant/utils/mmr_v1.rb +37 -0
- data/lib/valorant/utils/player.rb +87 -0
- data/lib/valorant/utils/user.rb +18 -0
- data/lib/valorant/utils/utilities.rb +39 -0
- data/lib/valorant/version.rb +7 -0
- data/lib/valorant.rb +9 -0
- data/valorant.gemspec +34 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a36f9f5ee4cd08482186eb82e1b4832f942c482d65ef3b3acb059d1377d1c96
|
4
|
+
data.tar.gz: 4ed8029b401abbfae509c107de62784083f4194b9c4da01808ae55f1c2b834dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b199bceb9378e2a15ab30e5400aa884a0fe709f44720a62367ea1f699d6344a6dfa87168bd5b7224d6d1f59c379459af3308d029f1b94674eb7ffc9e1923de29
|
7
|
+
data.tar.gz: e8da10bb9ec1cdfffd79ab75e4e91d3c0dc6a1dcaeccc820ef5681b08a3dc11ca5932e5f75cc1b50b10b17f965d5f3ff418441554814d6c7e93a37b76209fe69
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in valorant-api.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
|
+
|
12
|
+
gem 'rubocop', '~> 1.21'
|
13
|
+
|
14
|
+
gem 'fast_jsonparser'
|
15
|
+
|
16
|
+
gem 'rest-client'
|
17
|
+
|
18
|
+
gem 'date'
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Valorant
|
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/valorant`. 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
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add valorant
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install valorant
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
TODO: Write usage instructions here
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
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.
|
24
|
+
|
25
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/valorant.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
|
10
|
+
desc 'Look for style guide offenses in your code'
|
11
|
+
task :rubocop do
|
12
|
+
sh 'rubocop lib/ --format simple || true'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Look for style guide offenses in your code and fix them.'
|
16
|
+
task :rubofix do
|
17
|
+
sh 'rubocop lib/ --fix --format simple || true'
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Install required gems'
|
21
|
+
task :install do
|
22
|
+
sh 'bundle install'
|
23
|
+
end
|
24
|
+
|
25
|
+
task :console do
|
26
|
+
sh 'bin/console'
|
27
|
+
end
|
28
|
+
|
29
|
+
task default: %i[spec rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "valorant"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'utils/user'
|
4
|
+
require_relative 'utils/utilities'
|
5
|
+
|
6
|
+
module Valorant
|
7
|
+
# This class is used to fetch data from the Valorant API -> ENDPOINT: /account
|
8
|
+
class AccountStats
|
9
|
+
def self.account_data(name, tag)
|
10
|
+
User.new(fetch_resposne("v1/account/#{name}/#{tag}"))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'utils/match'
|
4
|
+
require_relative 'utils/matches_history'
|
5
|
+
require_relative 'utils/utilities'
|
6
|
+
|
7
|
+
module Valorant
|
8
|
+
# This class is used to fetch data from the Valorant API -> ENDPOINTS: /match, /matches
|
9
|
+
class MatchStats
|
10
|
+
def self.match_data(match_id)
|
11
|
+
Match.new(fetch_resposne("v2/match/#{match_id}"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.matches_history(name, tag, region = 'eu', filter: '')
|
15
|
+
MatcheshHistory.new(fetch_resposne("v3/matches/#{region}/#{name}/#{tag}?filter=#{validate_filter(filter)}"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.matches_history_by_puuid(puuid, region = 'eu', filter: '')
|
19
|
+
MatcheshHistory.new(fetch_resposne("v3/by-puuid/matches/#{region}/#{puuid}?filter=#{validate_filter(filter)}"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'utils/articles'
|
4
|
+
require_relative 'utils/leader_board'
|
5
|
+
require_relative 'utils/utilities'
|
6
|
+
|
7
|
+
module Valorant
|
8
|
+
# This class is used to fetch data from the Valorant API -> ENDPOINTS: /v1/website/, /v1/leaderboard/,
|
9
|
+
# v1/content/, v1/status/
|
10
|
+
class Misc
|
11
|
+
def self.articles(filter = '', locale = 'en-us')
|
12
|
+
Articles.new(fetch_resposne("v1/website/#{validate_locale(locale)}?filter=#{validate_filter(filter)}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.leader_board(region = 'eu', name = '', tag = '')
|
16
|
+
LeaderBoard.new(fetch_resposne("v1/leaderboard/#{region}?name=#{name}&tag=#{tag}", validate: false))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.content
|
20
|
+
fetch_resposne('v1/content')
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.server_status(region)
|
24
|
+
fetch_resposne("v1/status/#{region}")['data'].transform_keys(&:to_sym)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/valorant/mmr.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'utils/mmr_v1'
|
4
|
+
require_relative 'utils/mmr_history'
|
5
|
+
require_relative 'utils/utilities'
|
6
|
+
|
7
|
+
module Valorant
|
8
|
+
# This class is used to fetch data from the Valorant API -> ENDPOINTS: /mmr, /by-puuid/mmr/,
|
9
|
+
# v1/mmr-history/, v1/by-puuid/mmr-history/
|
10
|
+
class MMRStats
|
11
|
+
def self.mmr_data(name, tag, region = 'eu', version: 'v1')
|
12
|
+
MMRV1.new(fetch_resposne("#{version}/mmr/#{region}/#{name}/#{tag}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.mmr_data_by_puuid(puuid, region = 'eu', version: 'v1')
|
16
|
+
MMRV1.new(fetch_resposne("#{version}/by-puuid/mmr/#{region}/#{puuid}"))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.mmr_history(name, tag, region = 'eu')
|
20
|
+
MMRHistory.new(fetch_resposne("v1/mmr-history/#{region}/#{name}/#{tag}"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.mmr_history_by_puuid(puuid, region = 'eu')
|
24
|
+
MMRHistory.new(fetch_resposne("v1/by-puuid/mmr-history/#{region}/#{puuid}"))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
# This class is used to get the data for web articles.
|
5
|
+
class Article
|
6
|
+
attr_reader :banner_url, :category, :date, :external_link, :title, :url
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@banner_url = data['banner_url']
|
10
|
+
@category = data['category']
|
11
|
+
@date = Date.parse(data['date'])
|
12
|
+
@external_link = data['external_link']
|
13
|
+
@title = data['title']
|
14
|
+
@url = data['url']
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'article'
|
4
|
+
# This class is used to store the data for web articles.
|
5
|
+
class Articles
|
6
|
+
attr_reader :articles
|
7
|
+
|
8
|
+
def initialize(hash)
|
9
|
+
data = hash['data']
|
10
|
+
@articles = data.each_with_object([]) do |article, arr|
|
11
|
+
arr << Article.new(article)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Leader class
|
4
|
+
class Leader
|
5
|
+
attr_accessor :leader_board_rank, :ranked_rating, :number_of_wins, :comptetitive_tier, :puuid, :game_name,
|
6
|
+
:tag_line, :player_card_id, :title_id, :is_banned, :is_anonymized
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@leader_board_rank = data['leaderboardRank']
|
10
|
+
@ranked_rating = data['rankedRating']
|
11
|
+
@number_of_wins = data['numberOfWins']
|
12
|
+
@comptetitive_tier = data['competitiveTier']
|
13
|
+
fetch_player_data(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_player_data(data)
|
17
|
+
@puuid = data['puuid']
|
18
|
+
@game_name = data['gameName']
|
19
|
+
@tag_line = data['tagLine']
|
20
|
+
@player_card_id = data['PlayerCardID']
|
21
|
+
@title_id = data['TitleID']
|
22
|
+
@is_banned = data['IsBanned']
|
23
|
+
@is_anonymized = data['IsAnonymized']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# DOCUMENTATION
|
28
|
+
|
29
|
+
# @PlayerCardID
|
30
|
+
# @TitleID
|
31
|
+
# @IsBanned
|
32
|
+
# @IsAnonymized
|
33
|
+
# @puuid
|
34
|
+
# @gameName
|
35
|
+
# @tagLine
|
36
|
+
# @leaderboardRank
|
37
|
+
# @rankedRating
|
38
|
+
# @numberOfWins
|
39
|
+
# @competitiveTier
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'player'
|
4
|
+
|
5
|
+
# This class is used to get the data from a match
|
6
|
+
class Match
|
7
|
+
attr_reader :game_version, :game_start_patched, :season_id, :platform, :region,
|
8
|
+
:cluster, :map, :mode, :queue, :rounds_played, :matchid, :game_length,
|
9
|
+
:game_start, :winning_team, :red_rounds_won, :red_rounds_lost,
|
10
|
+
:blue_rounds_won, :blue_rounds_lost, :red_team, :blue_team, :all_players
|
11
|
+
|
12
|
+
def initialize(data)
|
13
|
+
@meta_data = data['data']['metadata']
|
14
|
+
@player_data = data['data']['players']
|
15
|
+
@team_data = data['data']['teams']
|
16
|
+
|
17
|
+
fetch_game_info
|
18
|
+
fetch_game_type
|
19
|
+
fetch_game_statistics
|
20
|
+
|
21
|
+
fetch_players
|
22
|
+
end
|
23
|
+
|
24
|
+
def mvp
|
25
|
+
@all_players.max_by(&:score)
|
26
|
+
end
|
27
|
+
|
28
|
+
def mvp_red
|
29
|
+
@red_team.max_by(&:score)
|
30
|
+
end
|
31
|
+
|
32
|
+
def mvp_blue
|
33
|
+
@blue_team.max_by(&:score)
|
34
|
+
end
|
35
|
+
|
36
|
+
def fetch_game_info
|
37
|
+
@game_version = @meta_data['game_version']
|
38
|
+
@game_start_patched = @meta_data['game_start_patched']
|
39
|
+
@season_id = @meta_data['season_id']
|
40
|
+
@platform = @meta_data['platform']
|
41
|
+
@region = @meta_data['region']
|
42
|
+
@cluster = @meta_data['cluster']
|
43
|
+
end
|
44
|
+
|
45
|
+
def fetch_game_type
|
46
|
+
@map = @meta_data['map']
|
47
|
+
@mode = @meta_data['mode']
|
48
|
+
@queue = @meta_data['queue']
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_game_statistics
|
52
|
+
@rounds_played = @meta_data['rounds_played']
|
53
|
+
@matchid = @meta_data['matchid']
|
54
|
+
@game_length = @meta_data['game_length']
|
55
|
+
@game_start = @meta_data['game_start']
|
56
|
+
end
|
57
|
+
|
58
|
+
def fetch_players
|
59
|
+
fetch_all_players
|
60
|
+
|
61
|
+
return if @queue == 'Deathmatch'
|
62
|
+
|
63
|
+
fetch_red_team
|
64
|
+
fetch_blue_team
|
65
|
+
fetch_team_stats
|
66
|
+
end
|
67
|
+
|
68
|
+
def fetch_team_stats
|
69
|
+
@winning_team = @team_data['red']['has_won'] ? 'red' : 'blue'
|
70
|
+
@red_rounds_won = @team_data['red']['rounds_won']
|
71
|
+
@red_rounds_lost = @team_data['red']['rounds_lost']
|
72
|
+
@blue_rounds_won = @team_data['blue']['rounds_won']
|
73
|
+
@blue_rounds_lost = @team_data['blue']['rounds_lost']
|
74
|
+
end
|
75
|
+
|
76
|
+
def fetch_red_team
|
77
|
+
red_team = @player_data['red']
|
78
|
+
@red_team = []
|
79
|
+
red_team.each do |player|
|
80
|
+
@red_team << Player.new(player)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def fetch_blue_team
|
85
|
+
blue_team = @player_data['blue']
|
86
|
+
@blue_team = []
|
87
|
+
blue_team.each do |player|
|
88
|
+
@blue_team << Player.new(player)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def fetch_all_players
|
93
|
+
@all_players = @player_data['all_players'].each_with_object([]) do |player, array|
|
94
|
+
array << Player.new(player)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'match'
|
4
|
+
|
5
|
+
# This class is used to get the data from the match history
|
6
|
+
class MatcheshHistory
|
7
|
+
attr_reader :matches
|
8
|
+
|
9
|
+
def initialize(hash)
|
10
|
+
@matches = fetch_matches(hash['data'])
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def fetch_matches(matches_json)
|
16
|
+
matches_json.each_with_object([]) do |match, arr|
|
17
|
+
reformated_data = { 'data' => match }
|
18
|
+
arr << Match.new(reformated_data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'mmr_v1'
|
4
|
+
|
5
|
+
# This class is used to get the data from the mmr history
|
6
|
+
class MMRHistory
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(hash)
|
10
|
+
@data = fetch_mmr_v1(hash['data'])
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def fetch_mmr_v1(mmr_v1_json)
|
16
|
+
mmr_v1_json.each_with_object([]) do |mmr_v1, arr|
|
17
|
+
reformated_data = { 'data' => mmr_v1 }
|
18
|
+
arr << MMRV1.new(reformated_data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# This class is used to get the @data from MMR
|
6
|
+
class MMRV1
|
7
|
+
attr_reader :currenttier, :currenttierpatched, :images, :ranking_in_tier, :mmr_change_to_last_game, :elo, :name,
|
8
|
+
:tag, :old, :date
|
9
|
+
|
10
|
+
def initialize(hash)
|
11
|
+
@data = hash['data']
|
12
|
+
@currenttier = @data['currenttier']
|
13
|
+
@currenttierpatched = @data['currenttierpatched']
|
14
|
+
@images = @data['images']
|
15
|
+
@ranking_in_tier = @data['ranking_in_tier']
|
16
|
+
@mmr_change_to_last_game = @data['mmr_change_to_last_game']
|
17
|
+
@elo = @data['elo']
|
18
|
+
@old = @data['old']
|
19
|
+
fetch_date
|
20
|
+
fetch_nametag
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def fetch_date
|
26
|
+
@date = if @data['date'].nil?
|
27
|
+
Time.now
|
28
|
+
else
|
29
|
+
Date.parse(@data['date'])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def fetch_nametag
|
34
|
+
@name = @data['name']
|
35
|
+
@tag = @data['tag']
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This class is used to get the data from the player
|
4
|
+
class Player
|
5
|
+
attr_reader :puuid, :name, :tag, :team, :level, :character, :currenttier, :currenttier_patched, :party_id,
|
6
|
+
:player_card, :player_title, :assets_card, :assets_agent, :session_playtime, :behavior, :ability_casts,
|
7
|
+
:score, :kills, :deaths, :assists, :bodyshots, :headshots, :legshots, :spent_overall, :spent_average,
|
8
|
+
:damage_made, :damage_received
|
9
|
+
|
10
|
+
def initialize(data)
|
11
|
+
@data = data
|
12
|
+
|
13
|
+
fetch_general_data
|
14
|
+
fetch_aesthetics_data
|
15
|
+
fetch_session_data
|
16
|
+
fetch_performance_data
|
17
|
+
fetch_economy_data
|
18
|
+
fetch_damage_data
|
19
|
+
end
|
20
|
+
|
21
|
+
def name_tag
|
22
|
+
"#{@name} ##{@tag}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def kd
|
26
|
+
(@kills.to_f / @deaths).round(2)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def fetch_general_data
|
32
|
+
@puuid = @data['puuid']
|
33
|
+
@name = @data['name']
|
34
|
+
@tag = @data['tag']
|
35
|
+
@team = @data['team']
|
36
|
+
@level = @data['level']
|
37
|
+
@character = @data['character']
|
38
|
+
@currenttier = @data['currenttier']
|
39
|
+
@currenttier_patched = @data['currenttier_patched']
|
40
|
+
@party_id = @data['party_id']
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch_aesthetics_data
|
44
|
+
@player_card = @data['player_card']
|
45
|
+
@player_title = @data['player_title']
|
46
|
+
@assets_card = keys_to_sim(@data['assets']['card']) # This is a hash
|
47
|
+
@assets_agent = keys_to_sim(@data['assets']['agent']) # This is a hash
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch_session_data
|
51
|
+
@session_playtime = @data['session_playtime']['seconds'].to_i
|
52
|
+
@behavior = keys_to_sim(@data['behavior']) # This is a hash
|
53
|
+
@ability_casts = keys_to_sim(@data['ability_casts']) # This is a hash
|
54
|
+
end
|
55
|
+
|
56
|
+
def fetch_performance_data
|
57
|
+
@score = @data['stats']['score']
|
58
|
+
@kills = @data['stats']['kills']
|
59
|
+
@deaths = @data['stats']['deaths']
|
60
|
+
@assists = @data['stats']['assists']
|
61
|
+
@bodyshots = @data['stats']['bodyshots']
|
62
|
+
@headshots = @data['stats']['headshots']
|
63
|
+
@legshots = @data['stats']['legshots']
|
64
|
+
end
|
65
|
+
|
66
|
+
def fetch_economy_data
|
67
|
+
@spent_overall = @data['economy']['spent']['overall'].to_i
|
68
|
+
@spent_average = @data['economy']['spent']['average'].to_i
|
69
|
+
end
|
70
|
+
|
71
|
+
def fetch_damage_data
|
72
|
+
@damage_made = @data['damage_made'].to_i
|
73
|
+
@damage_received = @data['damage_received'].to_i
|
74
|
+
return unless @damage_made.zero? || @damage_received.zero?
|
75
|
+
|
76
|
+
@damage_made = nil
|
77
|
+
@damage_received = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def session_platform_formatter(platform)
|
81
|
+
"#{platform['tpye']} #{platform['os'].values.join(' ')}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def keys_to_sim(hash)
|
85
|
+
hash.transform_keys(&:to_sym)
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This class is used to get the data from the User
|
4
|
+
class User
|
5
|
+
attr_reader :puuid, :region, :name, :tag, :account_level, :card, :last_update, :last_update_raw
|
6
|
+
|
7
|
+
def initialize(hash)
|
8
|
+
data = hash['data']
|
9
|
+
@puuid = data['puuid']
|
10
|
+
@region = data['region']
|
11
|
+
@name = data['name']
|
12
|
+
@tag = data['tag']
|
13
|
+
@account_level = data['account_level']
|
14
|
+
@card = data['card']
|
15
|
+
@last_update = data['last_update']
|
16
|
+
@last_update_raw = data['last_update_raw']
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'fast_jsonparser'
|
6
|
+
|
7
|
+
BASE_URL = 'https://api.henrikdev.xyz/valorant/'
|
8
|
+
|
9
|
+
def fetch_resposne(endpoint, validate: true)
|
10
|
+
response = RestClient.get(BASE_URL + endpoint)
|
11
|
+
return FastJsonparser.parse(validate_response(response), symbolize_keys: false) unless validate == false
|
12
|
+
|
13
|
+
FastJsonparser.parse(response, symbolize_keys: false)
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate_response(response)
|
17
|
+
return response.body if response.code == 200
|
18
|
+
|
19
|
+
raise "Error: #{response.code} - #{response['message']}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate_filter(filter)
|
23
|
+
return if filter.empty?
|
24
|
+
|
25
|
+
filters = %w[escalation spikerush deathmatch competitive unrated replication game_updates dev esports
|
26
|
+
announcments]
|
27
|
+
raise "Error: Invalid filter. Valid filters are: #{filters.join(', ')}" unless filters.include?(filter)
|
28
|
+
|
29
|
+
filter
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_locale(locale)
|
33
|
+
return if locale.empty?
|
34
|
+
|
35
|
+
locales = %w[en-us en-gb de-de es-es fr-fr it-it ru-ru tr-tr es-mx ja-jp ko-kr pt-br]
|
36
|
+
raise "Error: Invalid locale. Valid locales are: #{locales.join(', ')}" unless locales.include?(locale)
|
37
|
+
|
38
|
+
locale
|
39
|
+
end
|
data/lib/valorant.rb
ADDED
data/valorant.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/valorant/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "valorant"
|
7
|
+
spec.version = Valorant::Api::VERSION
|
8
|
+
spec.authors = ["Gerard Hernandez"]
|
9
|
+
spec.email = ["ger.almenara@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "An API wrapper for the Hendriks Valorant API 🍬"
|
12
|
+
spec.homepage = "https://github.com/jaredthejellyfish/ruby-hendriks-val"
|
13
|
+
spec.required_ruby_version = ">= 3.1.2"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/jaredthejellyfish/ruby-hendriks-val"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/jaredthejellyfish/ruby-hendriks-val"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
require 'rake'
|
22
|
+
spec.files = FileList['lib/**/*.rb',
|
23
|
+
'bin/*',
|
24
|
+
'[A-Z]*'].to_a
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
# Uncomment to register a new dependency of your gem
|
30
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
31
|
+
|
32
|
+
# For more information and examples about making a new gem, check out our
|
33
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: valorant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerard Hernandez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- ger.almenara@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- Gemfile
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- bin/console
|
25
|
+
- bin/setup
|
26
|
+
- lib/valorant.rb
|
27
|
+
- lib/valorant/account.rb
|
28
|
+
- lib/valorant/match.rb
|
29
|
+
- lib/valorant/misc.rb
|
30
|
+
- lib/valorant/mmr.rb
|
31
|
+
- lib/valorant/utils/article.rb
|
32
|
+
- lib/valorant/utils/articles.rb
|
33
|
+
- lib/valorant/utils/leader.rb
|
34
|
+
- lib/valorant/utils/leader_board.rb
|
35
|
+
- lib/valorant/utils/match.rb
|
36
|
+
- lib/valorant/utils/matches_history.rb
|
37
|
+
- lib/valorant/utils/mmr_history.rb
|
38
|
+
- lib/valorant/utils/mmr_v1.rb
|
39
|
+
- lib/valorant/utils/player.rb
|
40
|
+
- lib/valorant/utils/user.rb
|
41
|
+
- lib/valorant/utils/utilities.rb
|
42
|
+
- lib/valorant/version.rb
|
43
|
+
- valorant.gemspec
|
44
|
+
homepage: https://github.com/jaredthejellyfish/ruby-hendriks-val
|
45
|
+
licenses: []
|
46
|
+
metadata:
|
47
|
+
homepage_uri: https://github.com/jaredthejellyfish/ruby-hendriks-val
|
48
|
+
source_code_uri: https://github.com/jaredthejellyfish/ruby-hendriks-val
|
49
|
+
changelog_uri: https://github.com/jaredthejellyfish/ruby-hendriks-val
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 3.1.2
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubygems_version: 3.3.7
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: "An API wrapper for the Hendriks Valorant API \U0001F36C"
|
69
|
+
test_files: []
|