starcall 0.2.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 747f4858cbdbfc589afaea575efb50a1ab13cb6b17ea4c8a00e7d8531372ff45
4
- data.tar.gz: 7343bf8040d4a954f7f9c28724053bfad8d97ea4c145d1a028607b900d539bb3
3
+ metadata.gz: 29a7b323bcbf19c0a0fae436919ee5ec3d3698cc608090ef59f770dd0bef4fc1
4
+ data.tar.gz: 6ad054eb9ae3fa78169e56543753293802aca6d5f093787763ad6bd081d52e61
5
5
  SHA512:
6
- metadata.gz: 7d648c379749197d1c35f5a18ffffa6661741a12b704cb1ca10ab27df84c81640c2f56650ee7feb32363276beb222a0bedec5806702a5dc0b19d6c66dad64e7f
7
- data.tar.gz: cd19a5a3963fc1a6240877ebba5f2020c76165b56f12d9d887ee2d3a961c75ec70134252227626527b6b5be0844c951e037facf95a2ab92d5b44d22752db7d29
6
+ metadata.gz: '099f43356b97db57e5a99b2c861014468eb03f365524acdf80346f2069b772a5618e0da21966b8465b79861b8b1cb7f6edfe93312e11c7d8a09810959e661a72'
7
+ data.tar.gz: 765b7820ae2aa969981289540efece962e485e2756761967a83a193dc94d7c8179cacd75606f5feb75ccb147acfbe41151eb0f4bd06925c4fea8440be2162ad6
data/.rakeTasks CHANGED
@@ -4,4 +4,4 @@ You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build Starcall-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install Starcall-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install Starcall-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push Starcall-0.1.0.gem to TODO: Set to 'http://mygemserver.com'" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RuboCop" fullCmd="rubocop" taksId="rubocop" /><RakeGroup description="" fullCmd="" taksId="rubocop"><RakeTask description="Auto-correct RuboCop offenses" fullCmd="rubocop:auto_correct" taksId="auto_correct" /></RakeGroup><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeGroup description="" fullCmd="" taksId="travis"><RakeTask description="Run rubocop and rspec" fullCmd="travis:run" taksId="run" /></RakeGroup><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -13,8 +13,84 @@ None
13
13
 
14
14
  ---
15
15
 
16
+ ## v0.6.0 - Annie
17
+ ![Annie](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Annie.png)
18
+
19
+ ### New features
20
+ - Add Status V3 endpoint.
21
+ - Add third party code endpoint.
22
+ - Add Spectator endpoints.
23
+
24
+ ### Changes
25
+ None
26
+
27
+ ### Bug fixes
28
+ None
29
+
30
+ ---
31
+
32
+ ## v0.5.0 - Anivia
33
+ ![Anivia](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Anivia.png)
34
+
35
+ ### New features
36
+ - Add Clash V1 endpoint.
37
+ - Add the summoner endpoint.
38
+
39
+ ### Changes
40
+ None
41
+
42
+ ### Bug fixes
43
+ - Add Champion V3 to the endpoints file, making it accessible.
44
+
45
+ ---
46
+
47
+ ## v0.4.0 - Amumu
48
+ ![Amumu](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Amumu.png)
49
+
50
+ ### New features
51
+ - Added the champion endpoints.
52
+
53
+ ### Changes
54
+ None
55
+
56
+ ### Bug fixes
57
+ None
58
+
59
+ ---
60
+
61
+ ## v0.3.0 - Alistar
62
+ ![Alistar](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Alistar.png)
63
+
64
+ ### New features
65
+ - Added the 3 Champion Mastery Endpoints.
66
+ - `ApiRequests` now checks for an API key called `RIOT_API_KEY` and adds to the headers.
67
+ - Added a region parser as the API URLs require a region, but they are not the same as the normal regions.
68
+
69
+ ### Changes
70
+ - Move `ApiRequests` under the `Starcall` namespace.
71
+ - Move errors in to their own directory.
72
+
73
+ ### Bug fixes
74
+ None
75
+
76
+ ---
77
+
78
+ ## v0.2.1 - Akali
79
+ ![Akali](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Akali.png)
80
+
81
+ ### New features
82
+ None
83
+
84
+ ### Changes
85
+ None
86
+
87
+ ### Bug fixes
88
+ - The program now functions correctly with the details in the read me.
89
+
90
+ ---
91
+
16
92
  ## v0.2.0 - Ahri
17
- ![Aatrox](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Ahri.png)
93
+ ![Ahri](http://ddragon.leagueoflegends.com/cdn/10.12.1/img/champion/Ahri.png)
18
94
 
19
95
  ### New features
20
96
  - Regions
@@ -1,17 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starcall (0.2.0)
4
+ starcall (0.5.0)
5
5
  httparty (~> 0.17)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.1)
11
+ coderay (1.1.3)
11
12
  diff-lcs (1.3)
12
13
  httparty (0.18.1)
13
14
  mime-types (~> 3.0)
14
15
  multi_xml (>= 0.5.2)
16
+ method_source (1.0.0)
15
17
  mime-types (3.3.1)
16
18
  mime-types-data (~> 3.2015)
17
19
  mime-types-data (3.2020.0512)
@@ -19,6 +21,9 @@ GEM
19
21
  parallel (1.19.2)
20
22
  parser (2.7.1.4)
21
23
  ast (~> 2.4.1)
24
+ pry (0.13.1)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
22
27
  rainbow (3.0.0)
23
28
  rake (12.3.3)
24
29
  regexp_parser (1.7.1)
@@ -58,6 +63,7 @@ PLATFORMS
58
63
 
59
64
  DEPENDENCIES
60
65
  bundler (~> 2.0)
66
+ pry (~> 0.13)
61
67
  rake (~> 12.3)
62
68
  rspec (~> 3.0)
63
69
  rubocop (~> 0.86)
@@ -65,4 +71,4 @@ DEPENDENCIES
65
71
  starcall!
66
72
 
67
73
  BUNDLED WITH
68
- 2.0.2
74
+ 2.1.4
data/README.md CHANGED
@@ -119,6 +119,175 @@ Details about summoner spells.
119
119
 
120
120
  Details about profile icons and where they can be found on the sprite sheets.
121
121
 
122
+ ## Endpoints
123
+ The below commands require a Riot API key.
124
+ It needs to be saved as an ENV var and called `RIOT_API_KEY`
125
+ ### SummonerV4
126
+ #### `by_account_id`
127
+ [Riot API Documentation](https://developer.riotgames.com/apis#summoner-v4/GET_getByAccountId)
128
+
129
+ Required fields:
130
+ - `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
131
+ - `region` (The region that the summoner is in.)
132
+
133
+ Optional fields:
134
+ None
135
+
136
+ #### `by_summoner_name`
137
+ [Riot API Documentation](https://developer.riotgames.com/apis#summoner-v4/GET_getBySummonerName)
138
+
139
+ Required fields:
140
+ - `summoner_name` (The summoner name for the summoner you want to know about.)
141
+ - `region` (The region that the summoner is in.)
142
+
143
+ Optional fields:
144
+ None
145
+
146
+ #### `by_puuid`
147
+ [Riot API Documentation](https://developer.riotgames.com/apis#summoner-v4/GET_getByPUUID)
148
+
149
+ Required fields:
150
+ - `puuid` (The puuid for the summoner you want to know about.)
151
+ - `region` (The region that the summoner is in.)
152
+
153
+ Optional fields:
154
+ None
155
+
156
+ #### `by_summoner_id`
157
+ [Riot API Documentation](https://developer.riotgames.com/apis#summoner-v4/GET_getBySummonerId)
158
+
159
+ Required fields:
160
+ - `summoner_id` (The summoner id for the summoner you want to know about.)
161
+ - `region` (The region that the summoner is in.)
162
+
163
+ Optional fields:
164
+ None
165
+
166
+ ### Champion Mastery V4
167
+
168
+ #### `summoner`
169
+ [Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getAllChampionMasteries)
170
+
171
+ Required fields:
172
+ - `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
173
+ - `region` (The region that the summoner is in.)
174
+
175
+ #### `summoner_on_champion`
176
+ [Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getChampionMastery)
177
+
178
+ Required fields:
179
+ - `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
180
+ - `champion_id` (The ID number of the champion that you want to know about.)
181
+ - `region` (The region that the summoner is in.)
182
+
183
+ #### `summoner_total_mastery`
184
+ [Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getChampionMasteryScore)
185
+
186
+ Required fields:
187
+ - `encrypted_summoner_id` (the encrypted summoner ID for the summoner you want to know about.)
188
+ - `region` (The region that the summoner is in.)
189
+
190
+ ### Champion V3
191
+ #### `champion_rotations`
192
+ [Riot API Documentation](https://developer.riotgames.com/apis#champion-v3/GET_getChampionInfo)
193
+
194
+ Required fields:
195
+ - None
196
+
197
+ Optional fields:
198
+ - `region` (By default it will assume `euw`, if you want to know for a specific region, you can pass that in.)
199
+
200
+ ### Clash V3
201
+ #### `clash_by_summoner_id`
202
+ [Riot API Documentation](https://developer.riotgames.com/apis#clash-v1/GET_getPlayersBySummoner)
203
+
204
+ Required fields:
205
+ - `encrypted_summoner_id` (the encrypted summoner ID for the summoner you want to know about.)
206
+ - `region` (The region that the summoner is in.)
207
+
208
+ Optional fields:
209
+ - None
210
+
211
+ #### `clash_by_team_id`
212
+ [Riot API Documentation](https://developer.riotgames.com/apis#clash-v1/GET_getTeamById)
213
+
214
+ Required fields:
215
+ - `team_id` (the team ID for the team you want to know about.)
216
+ - `region` (The region that the team is in.)
217
+
218
+ Optional fields:
219
+ - None
220
+
221
+ #### `clash_tournaments`
222
+ [Riot API Documentation](https://developer.riotgames.com/apis#clash-v1/GET_getTournaments)
223
+
224
+ Required fields:
225
+ - `region` (The region that you want to know about.)
226
+
227
+ Optional fields:
228
+ - None
229
+
230
+ #### `clash_tournaments_by_team_id`
231
+ [Riot API Documentation](https://developer.riotgames.com/apis#clash-v1/GET_getTournaments)
232
+
233
+ Required fields:
234
+ - `team_id` (the team ID for the team you want to know about.)
235
+ - `region` (The region that the team is in.)
236
+
237
+ Optional fields:
238
+ - None
239
+
240
+ #### `clash_tournaments_by_tournament_id`
241
+ [Riot API Documentation](https://developer.riotgames.com/apis#clash-v1/GET_getTournaments)
242
+
243
+ Required fields:
244
+ - `tournament_id` (the tournament ID for the tournament you want to know about.)
245
+ - `region` (The region that the tournament is in.)
246
+
247
+ Optional fields:
248
+ - None
249
+
250
+ ### SpectatorV4
251
+ #### `summoner_game_info`
252
+ [Riot API Documentation](https://developer.riotgames.com/apis#spectator-v4/GET_getCurrentGameInfoBySummoner)
253
+
254
+ Required fields:
255
+ - `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
256
+ - `region` (The region that the summoner is in.)
257
+
258
+ Optional fields:
259
+ None
260
+
261
+ #### `featured_games`
262
+ [Riot API Documentation](https://developer.riotgames.com/apis#spectator-v4/GET_getFeaturedGames)
263
+
264
+ Required fields:
265
+ None
266
+
267
+ Optional fields:
268
+ - `region` (By default it will assume `euw`, if you want to know for a specific region, you can pass that in.)
269
+
270
+ ### Status V3
271
+ #### `status_data`
272
+ [Riot API Documentation](https://developer.riotgames.com/apis#lol-status-v3/GET_getShardData)
273
+
274
+ Required fields:
275
+ - None
276
+
277
+ Optional fields:
278
+ - `region` (By default it will assume `euw`, if you want to know for a specific region, you can pass that in.)
279
+
280
+ ### ThirdPartyCodeV4
281
+ #### `check_for_summoner`
282
+ [Riot API Documentation](https://developer.riotgames.com/apis#third-party-code-v4)
283
+
284
+ Required fields:
285
+ - `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
286
+ - `region` (The region that the summoner is in.)
287
+
288
+ Optional fields:
289
+ None
290
+
122
291
  ## Development
123
292
 
124
293
  After checking out the repo, run `bundle install` to install dependencies.
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'starcall/endpoints/endpoints'
4
+ require 'starcall/errors/errors'
5
+ require 'starcall/languages'
6
+ require 'starcall/regions'
7
+ require 'starcall/static_data'
3
8
  require 'starcall/version'
4
9
 
10
+ # The root of it all
5
11
  module Starcall
6
- class Error < StandardError; end
7
12
  end
@@ -2,9 +2,12 @@
2
2
 
3
3
  require 'httparty'
4
4
 
5
- # A small class to make a HTTP get request using the passed in URL
6
- class ApiRequests
7
- def self.make_request(url:)
8
- HTTParty.get(url).parsed_response
5
+ module Starcall
6
+ # A small class to make a HTTP get request using the passed in URL
7
+ # Intened to only be used my internal Gem classes and not be called directly.
8
+ class ApiRequests
9
+ def self.make_request(url:)
10
+ HTTParty.get(url, { headers: { 'X-Riot-Token' => ENV['RIOT_API_KEY'] } }).parsed_response
11
+ end
9
12
  end
10
13
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods used to call the Champion Mastery endpoints.
9
+ class ChampionMasteryV4
10
+ # Get all champion mastery entries sorted by number of champion points descending.
11
+ def self.summoner(encrypted_summoner_id:, region:)
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{encrypted_summoner_id}"
16
+ )
17
+ end
18
+
19
+ # Get a champion mastery by player ID and champion ID.
20
+ def self.summoner_on_champion(encrypted_summoner_id:, champion_id:, region:)
21
+ Starcall::Regions.valid?(region: region)
22
+ Starcall::ApiRequests.make_request(
23
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
24
+ "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{encrypted_summoner_id}"\
25
+ "/by-champion/#{champion_id}"
26
+ )
27
+ end
28
+
29
+ # Get a player's total champion mastery score, which is the sum of individual champion mastery levels.
30
+ def self.summoner_total_mastery(encrypted_summoner_id:, region:)
31
+ Starcall::Regions.valid?(region: region)
32
+ Starcall::ApiRequests.make_request(
33
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
34
+ "/lol/champion-mastery/v4/scores/by-summoner/#{encrypted_summoner_id}"
35
+ )
36
+ end
37
+
38
+ def self.parse_region(region:)
39
+ Starcall::Helpers::RegionParser.parse(region: region)
40
+ end
41
+
42
+ private_class_method :parse_region
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods used to call the Champion endpoints.
9
+ class ChampionV3
10
+ # Returns champion rotations, including free-to-play and low-level free-to-play rotations
11
+ def self.champion_rotations(region: 'euw')
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ '/lol/platform/v3/champion-rotations'
16
+ )
17
+ end
18
+
19
+ def self.parse_region(region:)
20
+ Starcall::Helpers::RegionParser.parse(region: region)
21
+ end
22
+
23
+ private_class_method :parse_region
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods used to get information about clash
9
+ class ClashV1
10
+ # Get players by summoner ID.
11
+ def self.clash_by_summoner_id(encrypted_summoner_id:, region:)
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ "/lol/clash/v1/players/by-summoner/#{encrypted_summoner_id}"
16
+ )
17
+ end
18
+
19
+ # Get team by ID.
20
+ def self.clash_by_team_id(team_id:, region:)
21
+ Starcall::Regions.valid?(region: region)
22
+ Starcall::ApiRequests.make_request(
23
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
24
+ "/lol/clash/v1/teams/#{team_id}"
25
+ )
26
+ end
27
+
28
+ # Get all active or upcoming tournaments.
29
+ def self.clash_tournaments(region:)
30
+ Starcall::Regions.valid?(region: region)
31
+ Starcall::ApiRequests.make_request(
32
+ url: "https://#{parse_region(region: region)}.api.riotgames.com/lol/clash/v1/tournaments"
33
+ )
34
+ end
35
+
36
+ # Get tournament by team ID.
37
+ def self.clash_tournaments_by_team_id(team_id:, region:)
38
+ Starcall::Regions.valid?(region: region)
39
+ Starcall::ApiRequests.make_request(
40
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
41
+ "/lol/clash/v1/tournaments/by-team/#{team_id}"
42
+ )
43
+ end
44
+
45
+ # Get tournament by ID
46
+ def self.clash_tournaments_by_tournament_id(tournament_id:, region:)
47
+ Starcall::Regions.valid?(region: region)
48
+ Starcall::ApiRequests.make_request(
49
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
50
+ "/lol/clash/v1/tournaments/#{tournament_id}"
51
+ )
52
+ end
53
+
54
+ def self.parse_region(region:)
55
+ Starcall::Helpers::RegionParser.parse(region: region)
56
+ end
57
+
58
+ private_class_method :parse_region
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'champion_mastery_v4'
4
+ require_relative 'champion_v3'
5
+ require_relative 'clash_v1'
6
+ require_relative 'summoner_v4'
7
+ require_relative 'status_v3'
8
+ require_relative 'spectator_v4'
9
+ require_relative 'third_party_code_v4'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods for getting spectator information
9
+ class SpectatorV4
10
+ # Get current game information for the given summoner ID
11
+ def self.summoner_game_info(encrypted_summoner_id:, region:)
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ "/lol/spectator/v4/active-games/by-summoner/#{encrypted_summoner_id}"
16
+ )
17
+ end
18
+
19
+ # Get list of featured games
20
+ def self.featured_games(region: 'euw')
21
+ Starcall::Regions.valid?(region: region)
22
+ Starcall::ApiRequests.make_request(
23
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
24
+ '/lol/spectator/v4/featured-games'
25
+ )
26
+ end
27
+
28
+ def self.parse_region(region:)
29
+ Starcall::Helpers::RegionParser.parse(region: region)
30
+ end
31
+
32
+ private_class_method :parse_region
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Method to check the status of services in a region
9
+ class StatusV3
10
+ # Get League of Legends status for the given shard
11
+ def self.status_data(region: 'euw')
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ '/lol/status/v3/shard-data'
16
+ )
17
+ end
18
+
19
+ def self.parse_region(region:)
20
+ Starcall::Helpers::RegionParser.parse(region: region)
21
+ end
22
+
23
+ private_class_method :parse_region
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods used to get information about summoners.
9
+ class SummonerV4
10
+ # Get a summoner by account ID.
11
+ def self.by_account_id(encrypted_account_id:, region:)
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ "/lol/summoner/v4/summoners/by-account/#{encrypted_account_id}"
16
+ )
17
+ end
18
+
19
+ # Get a summoner by summoner name.
20
+ def self.by_summoner_name(summoner_name:, region:)
21
+ Starcall::Regions.valid?(region: region)
22
+ Starcall::ApiRequests.make_request(
23
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
24
+ "/lol/summoner/v4/summoners/by-name/#{summoner_name}"
25
+ )
26
+ end
27
+
28
+ # Get a summoner by PUUID.
29
+ def self.by_puuid(puuid:, region:)
30
+ Starcall::Regions.valid?(region: region)
31
+ Starcall::ApiRequests.make_request(
32
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
33
+ "/lol/summoner/v4/summoners/by-puuid/#{puuid}"
34
+ )
35
+ end
36
+
37
+ # Get a summoner by summoner ID.
38
+ def self.by_summoner_id(summoner_id:, region:)
39
+ Starcall::Regions.valid?(region: region)
40
+ Starcall::ApiRequests.make_request(
41
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
42
+ "/lol/summoner/v4/summoners/#{summoner_id}"
43
+ )
44
+ end
45
+
46
+ def self.parse_region(region:)
47
+ Starcall::Helpers::RegionParser.parse(region: region)
48
+ end
49
+
50
+ private_class_method :parse_region
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/helpers/region_parser'
4
+ require 'starcall/api_requests'
5
+
6
+ module Starcall
7
+ module Endpoints
8
+ # Methods to check 3rd party codes
9
+ class ThirdPartyCodeV4
10
+ # Get third party code for a given summoner ID
11
+ def self.check_for_summoner(encrypted_summoner_id:, region:)
12
+ Starcall::Regions.valid?(region: region)
13
+ Starcall::ApiRequests.make_request(
14
+ url: "https://#{parse_region(region: region)}.api.riotgames.com"\
15
+ "/lol/platform/v4/third-party-code/by-summoner/#{encrypted_summoner_id}"
16
+ )
17
+ end
18
+
19
+ def self.parse_region(region:)
20
+ Starcall::Helpers::RegionParser.parse(region: region)
21
+ end
22
+
23
+ private_class_method :parse_region
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'invalid_language'
4
+ require_relative 'invalid_region'
@@ -1,23 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Starcall
4
- module Error
5
- # A Custom error message, used when an incorrect region is passed.
6
- class InvalidRegion < StandardError
7
- def initialize(region:)
8
- super
9
- @region = region
10
- end
11
-
12
- def message
13
- "#{region} is not a valid region. Please consult Starcall::Regions.list for a list of valid regions."
14
- end
15
-
16
- private
17
-
18
- attr_reader :region
19
- end
20
-
4
+ module Errors
21
5
  # A Custom error message, used when an incorrect language is passed.
22
6
  class InvalidLanguage < StandardError
23
7
  def initialize(language:)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Starcall
4
+ module Errors
5
+ # A Custom error message, used when an incorrect region is passed.
6
+ class InvalidRegion < StandardError
7
+ def initialize(region:)
8
+ super
9
+ @region = region
10
+ end
11
+
12
+ def message
13
+ "#{region} is not a valid region. Please consult Starcall::Regions.list for a list of valid regions."
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :region
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starcall/regions'
4
+
5
+ module Starcall
6
+ module Helpers
7
+ # The API URLs don't use the actual region name, they used different ones.
8
+ # This converts from a region name to the URL string.
9
+ class RegionParser
10
+ def self.parse(region:)
11
+ Starcall::Regions.valid?(region: region)
12
+
13
+ region_matchup = {
14
+ br: 'br1',
15
+ eune: 'eun1',
16
+ euw: 'euw1',
17
+ lan: 'la1',
18
+ las: 'la2',
19
+ na: 'na1',
20
+ oce: 'oc1',
21
+ ru: 'ru',
22
+ tr: 'tr1',
23
+ jp: 'jp1',
24
+ kr: 'kr'
25
+ }
26
+ region_matchup[region.to_sym]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'starcall/error'
4
-
5
3
  module Starcall
6
4
  # This class is used to list and validate languages.
7
5
  class Languages
@@ -45,7 +43,7 @@ module Starcall
45
43
  def self.valid?(language:)
46
44
  return true if list.include? language
47
45
 
48
- raise Starcall::Error::InvalidLanguage.new(language: language)
46
+ raise Starcall::Errors::InvalidLanguage.new(language: language)
49
47
  end
50
48
  end
51
49
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'starcall/error'
4
-
5
3
  module Starcall
6
4
  # This class is used to list and validate regions.
7
5
  class Regions
@@ -26,7 +24,7 @@ module Starcall
26
24
  def self.valid?(region:)
27
25
  return true if list.include? region
28
26
 
29
- raise Starcall::Error::InvalidRegion.new(region: region)
27
+ raise Starcall::Errors::InvalidRegion.new(region: region)
30
28
  end
31
29
  end
32
30
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'starcall/api_requests'
4
- require 'starcall/regions'
5
- require 'starcall/languages'
6
4
 
7
5
  module Starcall
8
6
  # This class is used for all things Static Data related.
@@ -20,29 +18,29 @@ module Starcall
20
18
  # Season ids are used in match history to indicate which season a match was played.
21
19
  # A full list of season ids can be retrieved with the below method.
22
20
  def season_ids
23
- ApiRequests.make_request(url: static_url(search_term: 'seasons'))
21
+ Starcall::ApiRequests.make_request(url: static_url(search_term: 'seasons'))
24
22
  end
25
23
 
26
24
  # Queue ids show up in several places throughout the API and are used to indicate which kind of match was played.
27
25
  # A full list of queue ids can be can be retrieved with the below method.
28
26
  def queue_ids
29
- ApiRequests.make_request(url: static_url(search_term: 'queues'))
27
+ Starcall::ApiRequests.make_request(url: static_url(search_term: 'queues'))
30
28
  end
31
29
 
32
30
  # Map ids are used in match history to indicate which map a match was played.
33
31
  # A full list of map ids can be can be retrieved with the below method.
34
32
  def map_ids
35
- ApiRequests.make_request(url: static_url(search_term: 'maps'))
33
+ Starcall::ApiRequests.make_request(url: static_url(search_term: 'maps'))
36
34
  end
37
35
 
38
36
  # A full list of game modes can be can be retrieved with the below method.
39
37
  def game_modes
40
- ApiRequests.make_request(url: static_url(search_term: 'gameModes'))
38
+ Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameModes'))
41
39
  end
42
40
 
43
41
  # A full list of game types can be can be retrieved with the below method.
44
42
  def game_types
45
- ApiRequests.make_request(url: static_url(search_term: 'gameTypes'))
43
+ Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameTypes'))
46
44
  end
47
45
 
48
46
  # All valid Data Dragon versions can be can be retrieved with the below method.
@@ -51,39 +49,39 @@ module Starcall
51
49
  # This typically occurs when there's an error in the original build.
52
50
  # As such, you should always use the most recent Data Dragon version for a given patch for the best results.
53
51
  def dd_versions
54
- ApiRequests.make_request(url: dd_versions_url)
52
+ Starcall::ApiRequests.make_request(url: dd_versions_url)
55
53
  end
56
54
 
57
55
  # Data Dragon versions aren't always equivalent to the League of Legends client version in a region.
58
56
  def dd_region_versions
59
- ApiRequests.make_request(url: dd_region_version_url)
57
+ Starcall::ApiRequests.make_request(url: dd_region_version_url)
60
58
  end
61
59
 
62
60
  # This returns a list of all champion with a brief summary, including stats, id and blurb.
63
61
  def dd_champions
64
- ApiRequests.make_request(url: dd_url(game_component: 'champion'))
62
+ Starcall::ApiRequests.make_request(url: dd_url(game_component: 'champion'))
65
63
  end
66
64
 
67
65
  # For me detailed and specific information about a champion, this call can be used.
68
66
  def dd_specific_champion(champion_name:)
69
- ApiRequests.make_request(url: dd_specific_champion_url(champion_name: champion_name))
67
+ Starcall::ApiRequests.make_request(url: dd_specific_champion_url(champion_name: champion_name))
70
68
  end
71
69
 
72
70
  # Data Dragon also provides detail for every item in the game.
73
71
  # with this method you can find info such as the item's description, purchase value, sell value,
74
72
  # items it builds from, items it builds into, and stats granted from the item.
75
73
  def dd_items
76
- ApiRequests.make_request(url: dd_url(game_component: 'item'))
74
+ Starcall::ApiRequests.make_request(url: dd_url(game_component: 'item'))
77
75
  end
78
76
 
79
77
  # Details about summoner spells.
80
78
  def dd_summoner_spells
81
- ApiRequests.make_request(url: dd_url(game_component: 'summoner'))
79
+ Starcall::ApiRequests.make_request(url: dd_url(game_component: 'summoner'))
82
80
  end
83
81
 
84
82
  # Details about profile icons and where they can be found on the sprite sheets.
85
83
  def dd_profile_icons
86
- ApiRequests.make_request(url: dd_url(game_component: 'profileicon'))
84
+ Starcall::ApiRequests.make_request(url: dd_url(game_component: 'profileicon'))
87
85
  end
88
86
 
89
87
  private
@@ -107,7 +105,7 @@ module Starcall
107
105
 
108
106
  # This gets the current version of specific game components, such as champions.
109
107
  def dd_current_data_version(game_component:)
110
- ApiRequests.make_request(url: dd_region_version_url)['n'][game_component]
108
+ Starcall::ApiRequests.make_request(url: dd_region_version_url)['n'][game_component]
111
109
  end
112
110
 
113
111
  # This builds the data dragon url for specific components such as champions,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Starcall
4
- VERSION = '0.2.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ['lib']
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 2.0'
33
+ spec.add_development_dependency 'pry', '~> 0.13'
33
34
  spec.add_development_dependency 'rake', '~> 12.3'
34
35
  spec.add_development_dependency 'rspec', '~> 3.0'
35
36
  spec.add_development_dependency 'rubocop', '~> 0.86'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starcall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelvin Samuel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-28 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +128,18 @@ files:
114
128
  - Rakefile
115
129
  - lib/starcall.rb
116
130
  - lib/starcall/api_requests.rb
117
- - lib/starcall/error.rb
131
+ - lib/starcall/endpoints/champion_mastery_v4.rb
132
+ - lib/starcall/endpoints/champion_v3.rb
133
+ - lib/starcall/endpoints/clash_v1.rb
134
+ - lib/starcall/endpoints/endpoints.rb
135
+ - lib/starcall/endpoints/spectator_v4.rb
136
+ - lib/starcall/endpoints/status_v3.rb
137
+ - lib/starcall/endpoints/summoner_v4.rb
138
+ - lib/starcall/endpoints/third_party_code_v4.rb
139
+ - lib/starcall/errors/errors.rb
140
+ - lib/starcall/errors/invalid_language.rb
141
+ - lib/starcall/errors/invalid_region.rb
142
+ - lib/starcall/helpers/region_parser.rb
118
143
  - lib/starcall/languages.rb
119
144
  - lib/starcall/regions.rb
120
145
  - lib/starcall/static_data.rb
@@ -143,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
168
  - !ruby/object:Gem::Version
144
169
  version: '0'
145
170
  requirements: []
146
- rubygems_version: 3.0.3
171
+ rubygems_version: 3.0.1
147
172
  signing_key:
148
173
  specification_version: 4
149
174
  summary: A Helper Gem for calling Riots API