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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34bec97e74db0a93f11d679b5f381dab953483940358944db61c8d283e4a4ef9
4
+ data.tar.gz: e91bbb519ecc5df86e4e64d98ca3b070f26c4dfddf11774223cec8b37202795e
5
+ SHA512:
6
+ metadata.gz: 7a1abf2f60038adbaa89424aecbe4e4552b4dd5f6116802fe6e7956b4074f09396c67949fbb075b202333caf8179e8a2539e04329ad791a6ec20eecdf324edf4
7
+ data.tar.gz: 9bd07444a7d38d5a9caf32933f522fbadc3fa140a93d086536bc4750a451cba41b6f898af3c3dba34a7dca40d95f2a78c6b474435d0eb4e3987588cd2e2058aa
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7.2
3
+ DisplayCopNames: true
4
+ StyleGuideCopsOnly: false
5
+ Style/Documentation:
6
+ Enabled: false
7
+ Layout/EmptyLinesAroundClassBody:
8
+ Enabled: true
9
+ EnforcedStyle: empty_lines
10
+ Supportedstyles:
11
+ - empty_lines
12
+ - no_empty_lines
13
+ Metrics/BlockLength:
14
+ Exclude:
15
+ - 'spec/**/*'
16
+ - 'hextech.gemspec'
17
+ - 'lib/hextech/**/response/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.0.0] - 2021-08-24
6
+
7
+ ### Added
8
+
9
+ - Global endpoints
10
+ - API
11
+ - ACCOUNT-V1
12
+ - `ByPuuid`
13
+ - `ByRiotId`
14
+ - `ActiveShard`
15
+
16
+ - League endpoints
17
+ - API
18
+ - CHAMPION-MASTERY-V4
19
+ - `AllChampions`
20
+ - `ByChampion`
21
+ - `TotalScore`
22
+ - CHAMPION-V3
23
+ - `ChampionRotation`
24
+ - CLASH-V1
25
+ - `AllTournaments`
26
+ - `BySummonerId`
27
+ - `ByTournamentId`
28
+ - `TeamByTeamId`
29
+ - `TournamentByTeamId`
30
+ - LOL-STATUS-V4
31
+ - `Status`
32
+ - MATCH-V5
33
+ - `ByPuuid`
34
+ - `ByMatchId`
35
+ - `MatchTimeline`
36
+ - SPECTATOR-V4
37
+ - `ActiveGames`
38
+ - `FeaturedGames`
39
+ - SUMMONER-V4
40
+ - `ByAccountId`
41
+ - `ByPUUID`
42
+ - `BySummonerId`
43
+ - `BySummonerName`
44
+ - THIRD-PARTY-CODE-V4
45
+ - CDN
46
+ - Champion Information
47
+ - Patch Information
48
+
49
+ - Valorant endpoints
50
+ - API
51
+ - VAL-STATUS-V1
52
+ - `Status`
53
+
54
+ [1.0.0]: https://github.com/lilystoney/hextech/releases/tag/v1.0.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in hextech.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,134 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hextech (1.0.0)
5
+ dry-struct (~> 1.4.0)
6
+ faraday (~> 1.8.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ climate_control (1.0.1)
15
+ coderay (1.1.3)
16
+ concurrent-ruby (1.1.9)
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.4.4)
20
+ docile (1.4.0)
21
+ dry-configurable (0.13.0)
22
+ concurrent-ruby (~> 1.0)
23
+ dry-core (~> 0.6)
24
+ dry-container (0.9.0)
25
+ concurrent-ruby (~> 1.0)
26
+ dry-configurable (~> 0.13, >= 0.13.0)
27
+ dry-core (0.7.1)
28
+ concurrent-ruby (~> 1.0)
29
+ dry-inflector (0.2.1)
30
+ dry-logic (1.2.0)
31
+ concurrent-ruby (~> 1.0)
32
+ dry-core (~> 0.5, >= 0.5)
33
+ dry-struct (1.4.0)
34
+ dry-core (~> 0.5, >= 0.5)
35
+ dry-types (~> 1.5)
36
+ ice_nine (~> 0.11)
37
+ dry-types (1.5.1)
38
+ concurrent-ruby (~> 1.0)
39
+ dry-container (~> 0.3)
40
+ dry-core (~> 0.5, >= 0.5)
41
+ dry-inflector (~> 0.1, >= 0.1.2)
42
+ dry-logic (~> 1.0, >= 1.0.2)
43
+ faraday (1.8.0)
44
+ faraday-em_http (~> 1.0)
45
+ faraday-em_synchrony (~> 1.0)
46
+ faraday-excon (~> 1.1)
47
+ faraday-httpclient (~> 1.0.1)
48
+ faraday-net_http (~> 1.0)
49
+ faraday-net_http_persistent (~> 1.1)
50
+ faraday-patron (~> 1.0)
51
+ faraday-rack (~> 1.0)
52
+ multipart-post (>= 1.2, < 3)
53
+ ruby2_keywords (>= 0.0.4)
54
+ faraday-em_http (1.0.0)
55
+ faraday-em_synchrony (1.0.0)
56
+ faraday-excon (1.1.0)
57
+ faraday-httpclient (1.0.1)
58
+ faraday-net_http (1.0.1)
59
+ faraday-net_http_persistent (1.2.0)
60
+ faraday-patron (1.0.0)
61
+ faraday-rack (1.0.0)
62
+ hashdiff (1.0.1)
63
+ ice_nine (0.11.2)
64
+ method_source (1.0.0)
65
+ multipart-post (2.1.1)
66
+ parallel (1.20.1)
67
+ parser (3.0.2.0)
68
+ ast (~> 2.4.1)
69
+ pry (0.13.1)
70
+ coderay (~> 1.1)
71
+ method_source (~> 1.0)
72
+ public_suffix (4.0.6)
73
+ rainbow (3.0.0)
74
+ rake (13.0.6)
75
+ regexp_parser (2.1.1)
76
+ rexml (3.2.5)
77
+ rspec (3.9.0)
78
+ rspec-core (~> 3.9.0)
79
+ rspec-expectations (~> 3.9.0)
80
+ rspec-mocks (~> 3.9.0)
81
+ rspec-core (3.9.3)
82
+ rspec-support (~> 3.9.3)
83
+ rspec-expectations (3.9.4)
84
+ diff-lcs (>= 1.2.0, < 2.0)
85
+ rspec-support (~> 3.9.0)
86
+ rspec-mocks (3.9.1)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.9.0)
89
+ rspec-support (3.9.4)
90
+ rubocop (0.93.1)
91
+ parallel (~> 1.10)
92
+ parser (>= 2.7.1.5)
93
+ rainbow (>= 2.2.2, < 4.0)
94
+ regexp_parser (>= 1.8)
95
+ rexml
96
+ rubocop-ast (>= 0.6.0)
97
+ ruby-progressbar (~> 1.7)
98
+ unicode-display_width (>= 1.4.0, < 2.0)
99
+ rubocop-ast (1.10.0)
100
+ parser (>= 3.0.1.1)
101
+ rubocop-rspec (1.43.2)
102
+ rubocop (~> 0.87)
103
+ ruby-progressbar (1.11.0)
104
+ ruby2_keywords (0.0.5)
105
+ simplecov (0.21.2)
106
+ docile (~> 1.1)
107
+ simplecov-html (~> 0.11)
108
+ simplecov_json_formatter (~> 0.1)
109
+ simplecov-html (0.12.3)
110
+ simplecov_json_formatter (0.1.3)
111
+ unicode-display_width (1.7.0)
112
+ vcr (6.0.0)
113
+ webmock (3.14.0)
114
+ addressable (>= 2.8.0)
115
+ crack (>= 0.3.2)
116
+ hashdiff (>= 0.4.0, < 2.0.0)
117
+
118
+ PLATFORMS
119
+ x86_64-darwin-20
120
+
121
+ DEPENDENCIES
122
+ climate_control (~> 1.0.1)
123
+ hextech!
124
+ pry (~> 0.13.1)
125
+ rake (~> 13.0)
126
+ rspec (~> 3.9.0)
127
+ rubocop (~> 0.93.1)
128
+ rubocop-rspec (~> 1.43.2)
129
+ simplecov (~> 0.21.2)
130
+ vcr (~> 6.0.0)
131
+ webmock (~> 3.14.0)
132
+
133
+ BUNDLED WITH
134
+ 2.2.15
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Lily Stoney
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ ![Hextech Logo](./docs/logo.png)
2
+
3
+ Simply a Ruby wrapper for Riot Api endpoints.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'hextech'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+
18
+ ## Usage
19
+
20
+ You'll need the following environment variable:
21
+
22
+ ```
23
+ RIOT_API_KEY='code-goes-here'
24
+ ```
25
+
26
+ Each Riot API endpoint integrated into the gem has been namespaced by game, endpoint grouping, and (if present) specific endpoint. The responses to these endpoints will be wrapped in a `Dry::Struct` with keys that have been converted to snake case.
27
+
28
+ ```ruby
29
+ # Example:
30
+
31
+ summoner = Hextech::League::Summoner.by_name(name: 'Example Summoner', region: 'euw1')
32
+ # => #<Hextech::League::Response::Summoner account_id="1234" id="4321" name="Example Summoner" profile_icon_id=1234 puuid="2468" revision_date=2021-11-01 08:00:00 +0100 summoner_level=100>
33
+
34
+ summoner.name
35
+ # => "Example Summoner"
36
+ ```
37
+
38
+ ## API Logging
39
+
40
+ Whenever the API Key is logged to the console, it will be replaced with `[REPLACED]`.
41
+
42
+ Logging is suppressed by default. In order to increase the logging level to `DEBUG`, use the following environment variable:
43
+
44
+ ```
45
+ DEBUG_LOGGER=true
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lilystoney/hextech.
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 'hextech'
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,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
data/docs/logo.png ADDED
Binary file
data/hextech.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/hextech/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'hextech'
7
+ spec.version = Hextech::VERSION
8
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
9
+ spec.summary = 'Ruby Wrapper for the Riot API endpoints.'
10
+ spec.description = 'An easy to use ruby wrapper for Riot API endpoints for League, Valorant,' \
11
+ 'Legends of Runeterra, etc.'
12
+ spec.authors = ['Lily Stoney']
13
+ spec.email = ['lily@lilypad.info']
14
+ spec.homepage = 'https://github.com/LilyStoney/hextech'
15
+ spec.license = 'MIT'
16
+
17
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/lilystoney/hextech/issues'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/lilystoney/hextech/blob/master/CHANGELOG.md'
19
+ spec.metadata['github_repo'] = 'ssh://github.com/lilystoney/hextech'
20
+ spec.metadata['source_code_uri'] = 'https://github.com/lilystoney/hextech'
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'dry-struct', '~> 1.4.0'
31
+ spec.add_dependency 'faraday', '~> 1.8.0'
32
+
33
+ spec.add_development_dependency 'climate_control', '~> 1.0.1'
34
+ spec.add_development_dependency 'pry', '~> 0.13.1'
35
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
36
+ spec.add_development_dependency 'rubocop', '~> 0.93.1'
37
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.43.2'
38
+ spec.add_development_dependency 'simplecov', '~> 0.21.2'
39
+ spec.add_development_dependency 'vcr', '~> 6.0.0'
40
+ spec.add_development_dependency 'webmock', '~> 3.14.0'
41
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ class Adapter
5
+
6
+ include Hextech::Mixins::ArgumentChecks
7
+ include Hextech::Mixins::Callable
8
+
9
+ def initialize
10
+ @connection = Hextech::SendRequest.new(host: host, api_key: api_key)
11
+ end
12
+
13
+ def call
14
+ connection
15
+ .call(path)
16
+ .then { |response| wrap_response(response, response_class) }
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :connection
22
+
23
+ def wrap_response(response, response_class)
24
+ Hextech::Response.new(response.body, response_class).call
25
+ end
26
+
27
+ def response_class
28
+ return unless defined?(@response_class)
29
+
30
+ @response_class
31
+ end
32
+
33
+ def host
34
+ raise NotImplementedError, 'Missing host attribute'
35
+ end
36
+
37
+ def path
38
+ raise NotImplementedError, 'Missing path attribute'
39
+ end
40
+
41
+ def api_key
42
+ @api_key ||= ENV.fetch('RIOT_API_KEY')
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ class BaseStruct < Dry::Struct
5
+
6
+ module Types
7
+ include Dry.Types()
8
+ end
9
+
10
+ CallableTime = Types::Time.constructor { |value| Time.at(value / 1000) }
11
+
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ class Errors < Faraday::Response::Middleware
5
+
6
+ def on_complete(env)
7
+ case env[:status]
8
+ when 403
9
+ raise Hextech::Forbidden, 'You may not have the rights to perform this action or your API key may have expired.'
10
+ when 404
11
+ raise Hextech::NotFound, 'Resource not found.'
12
+ when 429
13
+ raise Hextech::RateLimitExceeded, 'Too many requests have exceeded your designated rate limit.'
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ class RateLimitExceeded < StandardError; end
20
+
21
+ class NotFound < StandardError; end
22
+
23
+ class Forbidden < StandardError; end
24
+
25
+ class InvalidArgument < StandardError; end
26
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ module Account
6
+ class Base < Hextech::Adapter
7
+
8
+ REGIONS = %w[europe americas asia esports].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 Global
5
+ module Account
6
+ class ByPuuid < Hextech::Global::Account::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
+ "/riot/account/v1/accounts/by-puuid/#{puuid}"
21
+ end
22
+
23
+ def response_class
24
+ Hextech::Global::Response::Account::ByPuuid
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ module Account
6
+ class ByRiotId < Hextech::Global::Account::Base
7
+
8
+ def initialize(game_name:, tag_line:, region:)
9
+ @game_name = game_name
10
+ @tag_line = tag_line
11
+ @region = region
12
+
13
+ super()
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :game_name, :tag_line, :region
19
+
20
+ def path
21
+ "/riot/account/v1/accounts/by-riot-id/#{clean_name}/#{tag_line}"
22
+ end
23
+
24
+ def clean_name
25
+ ERB::Util.url_encode(game_name)
26
+ end
27
+
28
+ def response_class
29
+ Hextech::Global::Response::Account::ByRiotId
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'account/base'
4
+ require_relative 'account/by_puuid'
5
+ require_relative 'account/by_riot_id'
6
+
7
+ module Hextech
8
+ module Global
9
+ module Account
10
+ class << self
11
+
12
+ def by_puuid(puuid:, region: 'europe')
13
+ Account::ByPuuid.call(puuid: puuid, region: region)
14
+ end
15
+
16
+ def by_riot_id(game_name:, tag_line:, region: 'europe')
17
+ Account::ByRiotId.call(game_name: game_name, tag_line: tag_line, region: region)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ class ActiveShard < Hextech::Adapter
6
+
7
+ GAMES = %w[lor val].freeze
8
+ REGIONS = %w[europe americas asia esports].freeze
9
+
10
+ def initialize(game:, puuid:, region: 'europe')
11
+ @game = game
12
+ @puuid = puuid
13
+ @region = region
14
+
15
+ super()
16
+ end
17
+
18
+ def call
19
+ validate_collection_for(collection: REGIONS, option: region)
20
+ validate_collection_for(collection: GAMES, option: game)
21
+
22
+ super
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :game, :puuid, :region
28
+
29
+ def path
30
+ "/riot/account/v1/active-shards/by-game/#{game}/by-puuid/#{puuid}"
31
+ end
32
+
33
+ def host
34
+ "https://#{region}.api.riotgames.com"
35
+ end
36
+
37
+ def response_class
38
+ Hextech::Global::Response::ActiveShard
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ module Response
6
+ module Account
7
+ class ByPuuid < Hextech::BaseStruct
8
+
9
+ attribute :puuid, Types::String
10
+ attribute :game_name, Types::String
11
+ attribute :tag_line, Types::String
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ module Response
6
+ module Account
7
+ class ByRiotId < Hextech::BaseStruct
8
+
9
+ attribute :puuid, Types::String
10
+ attribute :game_name, Types::String
11
+ attribute :tag_line, Types::String
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hextech
4
+ module Global
5
+ module Response
6
+ class ActiveShard < Hextech::BaseStruct
7
+
8
+ attribute :puuid, Types::String
9
+ attribute :game, Types::String
10
+ attribute :active_shard, Types::String
11
+
12
+ end
13
+ end
14
+ end
15
+ end