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,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class Champions < Hextech::BaseStruct
7
+
8
+ attribute :version, Types::String
9
+ attribute :id, Types::String
10
+ attribute :key, Types::String
11
+ attribute :name, Types::String
12
+ attribute :title, Types::String
13
+ attribute :blurb, Types::String
14
+
15
+ attribute :info do
16
+ attribute :attack, Types::Integer
17
+ attribute :defense, Types::Integer
18
+ attribute :magic, Types::Integer
19
+ attribute :difficulty, Types::Integer
20
+ end
21
+
22
+ attribute :image do
23
+ attribute :full, Types::String
24
+ attribute :sprite, Types::String
25
+ attribute :group, Types::String
26
+ attribute :x, Types::Integer
27
+ attribute :y, Types::Integer
28
+ attribute :w, Types::Integer
29
+ attribute :h, Types::Integer
30
+ end
31
+
32
+ attribute :tags, Types::Array
33
+ attribute :partype, Types::String
34
+
35
+ attribute :stats do
36
+ attribute :hp, Types::Coercible::Float
37
+ attribute :hpperlevel, Types::Coercible::Float
38
+ attribute :mp, Types::Coercible::Float
39
+ attribute :mpperlevel, Types::Coercible::Float
40
+ attribute :movespeed, Types::Coercible::Float
41
+ attribute :armor, Types::Coercible::Float
42
+ attribute :armorperlevel, Types::Coercible::Float
43
+ attribute :spellblock, Types::Coercible::Float
44
+ attribute :spellblockperlevel, Types::Coercible::Float
45
+ attribute :attackrange, Types::Coercible::Float
46
+ attribute :hpregen, Types::Coercible::Float
47
+ attribute :hpregenperlevel, Types::Coercible::Float
48
+ attribute :mpregen, Types::Coercible::Float
49
+ attribute :mpregenperlevel, Types::Coercible::Float
50
+ attribute :crit, Types::Coercible::Float
51
+ attribute :critperlevel, Types::Coercible::Float
52
+ attribute :attackdamage, Types::Coercible::Float
53
+ attribute :attackdamageperlevel, Types::Coercible::Float
54
+ attribute :attackspeedperlevel, Types::Coercible::Float
55
+ attribute :attackspeed, Types::Coercible::Float
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ module Clash
7
+ class Player < Hextech::BaseStruct
8
+
9
+ attribute :position, Types::String
10
+ attribute :role, Types::String
11
+ attribute :summoner_id, Types::Integer
12
+ attribute :team_id, Types::Integer
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ module Clash
7
+ class Team < Hextech::BaseStruct
8
+
9
+ attribute :id, Types::String
10
+ attribute :tournament_id, Types::Integer
11
+ attribute :name, Types::String
12
+ attribute :icon_id, Types::Integer
13
+ attribute :tier, Types::Integer
14
+ attribute :captain, Types::String
15
+ attribute :abbreviation, Types::String
16
+
17
+ attribute :players, Types::Array do
18
+ attribute :summoner_id, Types::String
19
+ attribute :position, Types::String
20
+ attribute :role, Types::String
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ module Clash
7
+ class Tournament < Hextech::BaseStruct
8
+
9
+ attribute :id, Types::Integer
10
+ attribute :theme_id, Types::Integer
11
+ attribute :name_key, Types::String
12
+ attribute :name_key_secondary, Types::String
13
+
14
+ attribute :schedule, Types::Array do
15
+ attribute :id, Types::Integer
16
+ attribute :registration_time, CallableTime
17
+ attribute :start_time, CallableTime
18
+ attribute :cancelled, Types::Bool
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class FeaturedGames < Hextech::BaseStruct
7
+
8
+ attribute :game_list, Types::Array do
9
+ attribute :game_mode, Types::String
10
+ attribute :game_length, Types::Integer
11
+ attribute :map_id, Types::Integer
12
+ attribute :game_type, Types::String
13
+
14
+ attribute :banned_champions, Types::Array do
15
+ attribute :pick_turn, Types::Integer
16
+ attribute :champion_id, Types::Integer
17
+ attribute :team_id, Types::Integer
18
+ end
19
+
20
+ attribute :game_id, Types::Integer
21
+
22
+ attribute :observers do
23
+ attribute :encryption_key, Types::String
24
+ end
25
+
26
+ attribute :game_queue_config_id, Types::Integer
27
+ attribute :game_start_time, Types::Integer
28
+
29
+ attribute :participants, Types::Array do
30
+ attribute :bot, Types::Bool
31
+ attribute :spell2_id, Types::Integer
32
+ attribute :profile_icon_id, Types::Integer
33
+ attribute :summoner_name, Types::String
34
+ attribute :champion_id, Types::Integer
35
+ attribute :team_id, Types::Integer
36
+ attribute :spell1_id, Types::Integer
37
+ end
38
+
39
+ attribute :platform_id, Types::String
40
+ end
41
+
42
+ attribute :client_refresh_interval, Types::Integer
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class Mastery < Hextech::BaseStruct
7
+
8
+ attribute :champion_id, Types::Integer
9
+ attribute :champion_level, Types::Integer
10
+ attribute :champion_points, Types::Integer
11
+ attribute :champion_points_since_last_level, Types::Integer
12
+ attribute :champion_points_until_next_level, Types::Integer
13
+ attribute :chest_granted, Types::Bool
14
+ attribute :last_play_time, CallableTime
15
+ attribute :summoner_id, Types::String
16
+ attribute :tokens_earned, Types::Integer
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class Status < Hextech::BaseStruct
7
+
8
+ attribute :id, Types::String
9
+ attribute :incidents, Types::Array
10
+ attribute :locales, Types::Array
11
+ attribute :maintenances, Types::Array
12
+ attribute :name, Types::String
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Response
6
+ class Summoner < Hextech::BaseStruct
7
+
8
+ attribute :account_id, Types::String
9
+ attribute :id, Types::String
10
+ attribute :name, Types::String
11
+ attribute :profile_icon_id, Types::Integer
12
+ attribute :puuid, Types::String
13
+ attribute :revision_date, CallableTime
14
+ attribute :summoner_level, Types::Integer
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Spectator
6
+ class ActiveGames < Hextech::League::Spectator::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/spectator/v4/active-games/by-summoner/#{summoner_id}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::League::Response::ActiveGames
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 Spectator
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,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Spectator
6
+ class FeaturedGames < Hextech::League::Spectator::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/spectator/v4/featured-games'
20
+ end
21
+
22
+ def response_class
23
+ Hextech::League::Response::FeaturedGames
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'spectator/base'
4
+ require_relative 'spectator/active_games'
5
+ require_relative 'spectator/featured_games'
6
+
7
+ module Hextech
8
+ module League
9
+ module Spectator
10
+ class << self
11
+
12
+ def active_games(summoner_id:, region: 'euw1')
13
+ Spectator::ActiveGames.call(summoner_id: summoner_id, region: region)
14
+ end
15
+
16
+ def featured_games(region: 'euw1')
17
+ Spectator::FeaturedGames.call(region: region)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ class Status < 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/status/v4/platform-data'
31
+ end
32
+
33
+ def response_class
34
+ Hextech::League::Response::Status
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Summoner
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
+ def response_class
23
+ Hextech::League::Response::Summoner
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Summoner
6
+ class ByAccountId < Hextech::League::Summoner::Base
7
+
8
+ def initialize(account_id:, region:)
9
+ @account_id = account_id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :account_id, :region
18
+
19
+ def path
20
+ "/lol/summoner/v4/summoners/by-account/#{account_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 Summoner
6
+ class ByPuuid < Hextech::League::Summoner::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/summoner/v4/summoners/by-puuid/#{puuid}"
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 Summoner
6
+ class BySummonerId < Hextech::League::Summoner::Base
7
+
8
+ def initialize(id:, region:)
9
+ @id = id
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :id, :region
18
+
19
+ def path
20
+ "/lol/summoner/v4/summoners/#{id}"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ module Summoner
6
+ class BySummonerName < Hextech::League::Summoner::Base
7
+
8
+ def initialize(name:, region:)
9
+ @name = name
10
+ @region = region
11
+
12
+ super()
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :name, :region
18
+
19
+ def path
20
+ "/lol/summoner/v4/summoners/by-name/#{clean_name}"
21
+ end
22
+
23
+ def clean_name
24
+ ERB::Util.url_encode(name)
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'summoner/base'
4
+ require_relative 'summoner/by_account_id'
5
+ require_relative 'summoner/by_summoner_name'
6
+ require_relative 'summoner/by_puuid'
7
+ require_relative 'summoner/by_summoner_id'
8
+
9
+ module Hextech
10
+ module League
11
+ module Summoner
12
+ class << self
13
+
14
+ def by_account_id(account_id:, region: 'euw1')
15
+ Summoner::ByAccountId.call(account_id: account_id, region: region)
16
+ end
17
+
18
+ def by_id(id:, region: 'euw1')
19
+ Summoner::BySummonerId.call(id: id, region: region)
20
+ end
21
+
22
+ def by_name(name:, region: 'euw1')
23
+ Summoner::BySummonerName.call(name: name, region: region)
24
+ end
25
+
26
+ def by_puuid(puuid:, region: 'euw1')
27
+ Summoner::ByPuuid.call(puuid: puuid, region: region)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module League
5
+ class ThirdPartyCode < Hextech::Adapter
6
+
7
+ REGIONS = %w[euw1 eun1 na1 oc1 kr br1 tr1 la2 la1 ru jp1].freeze
8
+
9
+ def initialize(summoner_id:, region: 'euw1')
10
+ @summoner_id = summoner_id
11
+ @region = region
12
+
13
+ super()
14
+ end
15
+
16
+ def call
17
+ validate_collection_for(collection: REGIONS, option: region)
18
+
19
+ super
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :summoner_id, :region
25
+
26
+ def host
27
+ "https://#{region}.api.riotgames.com"
28
+ end
29
+
30
+ def path
31
+ "/lol/platform/v4/third-party-code/by-summoner/#{summoner_id}"
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'league/response/champion_rotation'
4
+ require_relative 'league/response/champions'
5
+
6
+ require_relative 'league/response/clash/player'
7
+ require_relative 'league/response/clash/team'
8
+ require_relative 'league/response/clash/tournament'
9
+
10
+ require_relative 'league/response/mastery'
11
+ require_relative 'league/response/status'
12
+
13
+ require_relative 'league/response/active_games'
14
+ require_relative 'league/response/featured_games'
15
+
16
+ require_relative 'league/response/summoner'
17
+
18
+ require_relative 'league/champion_rotation'
19
+ require_relative 'league/champions'
20
+ require_relative 'league/clash'
21
+ require_relative 'league/mastery'
22
+ require_relative 'league/match'
23
+ require_relative 'league/patches'
24
+ require_relative 'league/status'
25
+ require_relative 'league/summoner'
26
+ require_relative 'league/spectator'
27
+ require_relative 'league/third_party_code'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Mixins
5
+ module ArgumentChecks
6
+ def validate_collection_for(collection:, option:)
7
+ return if collection.empty? || collection.include?(option)
8
+
9
+ raise Hextech::InvalidArgument, "Invalid argument: must be one of #{collection.join(', ')}."
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Mixins
5
+ module Callable
6
+ def self.included(klass)
7
+ klass.extend(ClassMethods)
8
+ end
9
+
10
+ module ClassMethods
11
+ def call(...)
12
+ new(...).call
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end