hextech 1.0.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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +17 -0
  5. data/CHANGELOG.md +54 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +134 -0
  8. data/LICENSE.md +21 -0
  9. data/README.md +50 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/docs/logo.png +0 -0
  13. data/hextech.gemspec +41 -0
  14. data/lib/hextech/adapter.rb +46 -0
  15. data/lib/hextech/base_struct.rb +13 -0
  16. data/lib/hextech/errors.rb +26 -0
  17. data/lib/hextech/global/account/base.rb +25 -0
  18. data/lib/hextech/global/account/by_puuid.rb +30 -0
  19. data/lib/hextech/global/account/by_riot_id.rb +35 -0
  20. data/lib/hextech/global/account.rb +23 -0
  21. data/lib/hextech/global/active_shard.rb +43 -0
  22. data/lib/hextech/global/response/account/by_puuid.rb +17 -0
  23. data/lib/hextech/global/response/account/by_riot_id.rb +17 -0
  24. data/lib/hextech/global/response/active_shard.rb +15 -0
  25. data/lib/hextech/global.rb +8 -0
  26. data/lib/hextech/league/champion_rotation.rb +39 -0
  27. data/lib/hextech/league/champions.rb +35 -0
  28. data/lib/hextech/league/clash/all_tournaments.rb +29 -0
  29. data/lib/hextech/league/clash/base.rb +25 -0
  30. data/lib/hextech/league/clash/by_summoner_id.rb +30 -0
  31. data/lib/hextech/league/clash/by_tournament_id.rb +30 -0
  32. data/lib/hextech/league/clash/team_by_team_id.rb +30 -0
  33. data/lib/hextech/league/clash/tournament_by_team_id.rb +30 -0
  34. data/lib/hextech/league/clash.rb +38 -0
  35. data/lib/hextech/league/mastery/all_champions.rb +30 -0
  36. data/lib/hextech/league/mastery/base.rb +25 -0
  37. data/lib/hextech/league/mastery/by_champion.rb +31 -0
  38. data/lib/hextech/league/mastery/total_score.rb +26 -0
  39. data/lib/hextech/league/mastery.rb +28 -0
  40. data/lib/hextech/league/match/base.rb +25 -0
  41. data/lib/hextech/league/match/by_match_id.rb +26 -0
  42. data/lib/hextech/league/match/by_puuid.rb +26 -0
  43. data/lib/hextech/league/match/timeline.rb +26 -0
  44. data/lib/hextech/league/match.rb +28 -0
  45. data/lib/hextech/league/patches.rb +23 -0
  46. data/lib/hextech/league/response/active_games.rb +43 -0
  47. data/lib/hextech/league/response/champion_rotation.rb +15 -0
  48. data/lib/hextech/league/response/champions.rb +60 -0
  49. data/lib/hextech/league/response/clash/player.rb +18 -0
  50. data/lib/hextech/league/response/clash/team.rb +27 -0
  51. data/lib/hextech/league/response/clash/tournament.rb +25 -0
  52. data/lib/hextech/league/response/featured_games.rb +47 -0
  53. data/lib/hextech/league/response/mastery.rb +21 -0
  54. data/lib/hextech/league/response/status.rb +17 -0
  55. data/lib/hextech/league/response/summoner.rb +19 -0
  56. data/lib/hextech/league/spectator/active_games.rb +30 -0
  57. data/lib/hextech/league/spectator/base.rb +25 -0
  58. data/lib/hextech/league/spectator/featured_games.rb +29 -0
  59. data/lib/hextech/league/spectator.rb +23 -0
  60. data/lib/hextech/league/status.rb +39 -0
  61. data/lib/hextech/league/summoner/base.rb +29 -0
  62. data/lib/hextech/league/summoner/by_account_id.rb +26 -0
  63. data/lib/hextech/league/summoner/by_puuid.rb +26 -0
  64. data/lib/hextech/league/summoner/by_summoner_id.rb +26 -0
  65. data/lib/hextech/league/summoner/by_summoner_name.rb +30 -0
  66. data/lib/hextech/league/summoner.rb +33 -0
  67. data/lib/hextech/league/third_party_code.rb +36 -0
  68. data/lib/hextech/league.rb +27 -0
  69. data/lib/hextech/mixins/argument_checks.rb +13 -0
  70. data/lib/hextech/mixins/callable.rb +17 -0
  71. data/lib/hextech/mixins/transform_keys.rb +63 -0
  72. data/lib/hextech/response.rb +43 -0
  73. data/lib/hextech/send_request.rb +43 -0
  74. data/lib/hextech/valorant/response/status.rb +67 -0
  75. data/lib/hextech/valorant/status.rb +38 -0
  76. data/lib/hextech/valorant.rb +4 -0
  77. data/lib/hextech/version.rb +5 -0
  78. data/lib/hextech.rb +19 -0
  79. metadata +265 -0
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'global/response/active_shard'
4
+ require_relative 'global/response/account/by_puuid'
5
+ require_relative 'global/response/account/by_riot_id'
6
+
7
+ require_relative 'global/account'
8
+ require_relative 'global/active_shard'
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ class ChampionRotation < Hextech::Adapter
6
+
7
+ REGIONS = %w[euw1 eun1 na1 oc1 kr br1 tr1 la2 la1 ru jp1].freeze
8
+
9
+ def initialize(region: 'euw1')
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ def call
16
+ validate_collection_for(collection: REGIONS, option: region)
17
+
18
+ super
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :region
24
+
25
+ def host
26
+ "https://#{region}.api.riotgames.com"
27
+ end
28
+
29
+ def path
30
+ '/lol/platform/v3/champion-rotations'
31
+ end
32
+
33
+ def response_class
34
+ Hextech::League::Response::ChampionRotation
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ class Champions < Hextech::Adapter
6
+
7
+ def initialize
8
+ @latest_patch = Hextech::League::Patches.new.latest
9
+
10
+ super()
11
+ end
12
+
13
+ def call
14
+ response = super
15
+
16
+ response[:data].each_with_object({}) do |(champion, data), hash|
17
+ hash[champion] = Hextech::League::Response::Champions.new(data)
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :latest_patch
24
+
25
+ def host
26
+ 'https://ddragon.leagueoflegends.com'
27
+ end
28
+
29
+ def path
30
+ "/cdn/#{latest_patch}/data/en_US/champion.json"
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class AllTournaments < Hextech::League::Clash::Base
7
+
8
+ def initialize(region:)
9
+ @region = region
10
+
11
+ super()
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :region
17
+
18
+ def path
19
+ '/lol/clash/v1/tournaments'
20
+ end
21
+
22
+ def response_class
23
+ Hextech::League::Response::Clash::Tournament
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class Base < Hextech::Adapter
7
+
8
+ REGIONS = %w[euw1 eun1 na1 oc1 kr br1 tr1 la2 la1 ru jp1].freeze
9
+
10
+ def call
11
+ validate_collection_for(collection: REGIONS, option: region)
12
+
13
+ super
14
+ end
15
+
16
+ private
17
+
18
+ def host
19
+ "https://#{region}.api.riotgames.com"
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class BySummonerId < Hextech::League::Clash::Base
7
+
8
+ def initialize(summoner_id:, region:)
9
+ @summoner_id = summoner_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :summoner_id, :region
18
+
19
+ def path
20
+ "/lol/clash/v1/players/by-summoner/#{summoner_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::Clash::Player
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class ByTournamentId < Hextech::League::Clash::Base
7
+
8
+ def initialize(tournament_id:, region:)
9
+ @tournament_id = tournament_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :tournament_id, :region
18
+
19
+ def path
20
+ "/lol/clash/v1/tournaments/#{tournament_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::Clash::Tournament
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class TeamByTeamId < Hextech::League::Clash::Base
7
+
8
+ def initialize(team_id:, region:)
9
+ @team_id = team_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :team_id, :region
18
+
19
+ def path
20
+ "/lol/clash/v1/teams/#{team_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::Clash::Team
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Clash
6
+ class TournamentByTeamId < Hextech::League::Clash::Base
7
+
8
+ def initialize(team_id:, region:)
9
+ @team_id = team_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :team_id, :region
18
+
19
+ def path
20
+ "/lol/clash/v1/tournaments/by-team/#{team_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::Clash::Tournament
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'clash/base'
4
+ require_relative 'clash/all_tournaments'
5
+ require_relative 'clash/by_summoner_id'
6
+ require_relative 'clash/by_tournament_id'
7
+ require_relative 'clash/team_by_team_id'
8
+ require_relative 'clash/tournament_by_team_id'
9
+
10
+ module Hextech
11
+ module League
12
+ module Clash
13
+ class << self
14
+
15
+ def all_tournaments(region: 'euw1')
16
+ Clash::AllTournaments.call(region: region)
17
+ end
18
+
19
+ def by_summoner_id(summoner_id:, region: 'euw1')
20
+ Clash::BySummonerId.call(summoner_id: summoner_id, region: region)
21
+ end
22
+
23
+ def by_tournament_id(tournament_id:, region: 'euw1')
24
+ Clash::ByTournamentId.call(tournament_id: tournament_id, region: region)
25
+ end
26
+
27
+ def team_by_team_id(team_id:, region: 'euw1')
28
+ Clash::TeamByTeamId.call(team_id: team_id, region: region)
29
+ end
30
+
31
+ def tournament_by_team_id(team_id:, region: 'euw1')
32
+ Clash::TournamentByTeamId.call(team_id: team_id, region: region)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Mastery
6
+ class AllChampions < Hextech::League::Mastery::Base
7
+
8
+ def initialize(summoner_id:, region:)
9
+ @summoner_id = summoner_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :summoner_id, :region
18
+
19
+ def path
20
+ "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{summoner_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::Mastery
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Mastery
6
+ class Base < Hextech::Adapter
7
+
8
+ REGIONS = %w[euw1 eun1 na1 oc1 kr br1 tr1 la2 la1 ru jp1].freeze
9
+
10
+ def call
11
+ validate_collection_for(collection: REGIONS, option: region)
12
+
13
+ super
14
+ end
15
+
16
+ private
17
+
18
+ def host
19
+ "https://#{region}.api.riotgames.com"
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Mastery
6
+ class ByChampion < Hextech::League::Mastery::Base
7
+
8
+ def initialize(summoner_id:, champion_id:, region:)
9
+ @summoner_id = summoner_id
10
+ @champion_id = champion_id
11
+ @region = region
12
+
13
+ super()
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :summoner_id, :champion_id, :region
19
+
20
+ def path
21
+ "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{summoner_id}/by-champion/#{champion_id}"
22
+ end
23
+
24
+ def response_class
25
+ Hextech::League::Response::Mastery
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Mastery
6
+ class TotalScore < Hextech::League::Mastery::Base
7
+
8
+ def initialize(summoner_id:, region:)
9
+ @summoner_id = summoner_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :summoner_id, :region
18
+
19
+ def path
20
+ "/lol/champion-mastery/v4/scores/by-summoner/#{summoner_id}"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mastery/base'
4
+ require_relative 'mastery/all_champions'
5
+ require_relative 'mastery/by_champion'
6
+ require_relative 'mastery/total_score'
7
+
8
+ module Hextech
9
+ module League
10
+ module Mastery
11
+ class << self
12
+
13
+ def all_champions(summoner_id:, region: 'euw1')
14
+ Mastery::AllChampions.call(summoner_id: summoner_id, region: region)
15
+ end
16
+
17
+ def by_champion(summoner_id:, champion_id:, region: 'euw1')
18
+ Mastery::ByChampion.call(summoner_id: summoner_id, champion_id: champion_id, region: region)
19
+ end
20
+
21
+ def total_score(summoner_id:, region: 'euw1')
22
+ Mastery::TotalScore.call(summoner_id: summoner_id, region: region)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Match
6
+ class Base < Hextech::Adapter
7
+
8
+ REGIONS = %w[AMERICAS ASIA EUROPE].freeze
9
+
10
+ def call
11
+ validate_collection_for(collection: REGIONS, option: region)
12
+
13
+ super
14
+ end
15
+
16
+ private
17
+
18
+ def host
19
+ "https://#{region}.api.riotgames.com"
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Match
6
+ class ByMatchId < Hextech::League::Match::Base
7
+
8
+ def initialize(match_id:, region:)
9
+ @match_id = match_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :match_id, :region
18
+
19
+ def path
20
+ "/lol/match/v5/matches/#{match_id}"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Match
6
+ class ByPuuid < Hextech::League::Match::Base
7
+
8
+ def initialize(puuid:, region:)
9
+ @puuid = puuid
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :puuid, :region
18
+
19
+ def path
20
+ "/lol/match/v5/matches/by-puuid/#{puuid}/ids"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Match
6
+ class Timeline < Hextech::League::Match::Base
7
+
8
+ def initialize(match_id:, region:)
9
+ @match_id = match_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :match_id, :region
18
+
19
+ def path
20
+ "/lol/match/v5/matches/#{match_id}/timeline"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'match/base'
4
+ require_relative 'match/by_puuid'
5
+ require_relative 'match/by_match_id'
6
+ require_relative 'match/timeline'
7
+
8
+ module Hextech
9
+ module League
10
+ module Match
11
+ class << self
12
+
13
+ def by_match_id(match_id:, region: 'EUROPE')
14
+ Match::ByMatchId.call(match_id: match_id, region: region)
15
+ end
16
+
17
+ def by_puuid(puuid:, region: 'EUROPE')
18
+ Match::ByPuuid.call(puuid: puuid, region: region)
19
+ end
20
+
21
+ def timeline(match_id:, region: 'EUROPE')
22
+ Match::Timeline.call(match_id: match_id, region: region)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ class Patches < Hextech::Adapter
6
+
7
+ def latest
8
+ call.first
9
+ end
10
+
11
+ private
12
+
13
+ def host
14
+ 'https://ddragon.leagueoflegends.com'
15
+ end
16
+
17
+ def path
18
+ '/api/versions.json'
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class ActiveGames < Hextech::BaseStruct
7
+
8
+ attribute :game_mode, Types::String
9
+ attribute :game_length, Types::Integer
10
+ attribute :map_id, Types::Integer
11
+ attribute :game_type, Types::String
12
+
13
+ attribute :banned_champions, Types::Array do
14
+ attribute :pick_turn, Types::Integer
15
+ attribute :champion_id, Types::Integer
16
+ attribute :team_id, Types::Integer
17
+ end
18
+
19
+ attribute :game_id, Types::Integer
20
+
21
+ attribute :observers do
22
+ attribute :encryption_key, Types::String
23
+ end
24
+
25
+ attribute :game_queue_config_id, Types::Integer
26
+ attribute :game_start_time, Types::Integer
27
+
28
+ attribute :participants, Types::Array do
29
+ attribute :bot, Types::Bool
30
+ attribute :spell2_id, Types::Integer
31
+ attribute :profile_icon_id, Types::Integer
32
+ attribute :summoner_name, Types::String
33
+ attribute :champion_id, Types::Integer
34
+ attribute :team_id, Types::Integer
35
+ attribute :spell1_id, Types::Integer
36
+ end
37
+
38
+ attribute :platform_id, Types::String
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class ChampionRotation < Hextech::BaseStruct
7
+
8
+ attribute :free_champion_ids, Types::Array
9
+ attribute :free_champion_ids_for_new_players, Types::Array
10
+ attribute :max_new_player_level, Types::Coercible::Integer
11
+
12
+ end
13
+ end
14
+ end
15
+ end