starcall 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/.rakeTasks +1 -1
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +7 -1
- data/README.md +28 -0
- data/lib/starcall.rb +2 -2
- data/lib/starcall/api_requests.rb +7 -4
- data/lib/starcall/endpoints/champion_mastery_v4.rb +45 -0
- data/lib/starcall/endpoints/endpoints.rb +3 -0
- data/lib/starcall/errors/errors.rb +4 -0
- data/lib/starcall/{error.rb → errors/invalid_language.rb} +1 -17
- data/lib/starcall/errors/invalid_region.rb +21 -0
- data/lib/starcall/helpers/region_parser.rb +30 -0
- data/lib/starcall/languages.rb +1 -1
- data/lib/starcall/regions.rb +1 -1
- data/lib/starcall/static_data.rb +15 -13
- data/lib/starcall/version.rb +1 -1
- data/starcall.gemspec +1 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afe7b17e98b4f26c45a50c13d4631ddbaae2f6e8f5674ad3769e5a85cb35089e
|
4
|
+
data.tar.gz: 216b511b0109f37211c59777012716cf76d3ecbf803dd38ec5387bd8646fc202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b023aaee23d61056c570301b95bc360cd68ff045afa2551b0386238b83cc0de4ba49427434f926dc1bb983ff25fb773b5a38e06420c3af3108ffd26a74e21aa
|
7
|
+
data.tar.gz: 4ca4dc69588b7196d1ee04e77a684fc4f2b9ab1894277fb2953445baecdeea6ff13b88275c08b34fa887cedf74eb647c6c32c7153c91341a4b7de38938c4a636
|
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"
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,22 @@ None
|
|
13
13
|
|
14
14
|
---
|
15
15
|
|
16
|
+
## v0.3.0 - Alistar
|
17
|
+

|
18
|
+
|
19
|
+
### New features
|
20
|
+
- Added the 3 Champion Mastery Endpoints.
|
21
|
+
- `ApiRequests` now checks for an API key called `RIOT_API_KEY` and adds to the headers.
|
22
|
+
- Added a region parser as the API URLs require a region, but they are not the same as the normal regions.
|
23
|
+
|
24
|
+
### Changes
|
25
|
+
- Move `ApiRequests` under the `Starcall` namespace.
|
26
|
+
- Move errors in to their own directory.
|
27
|
+
|
28
|
+
### Bug fixes
|
29
|
+
|
30
|
+
---
|
31
|
+
|
16
32
|
## v0.2.1 - Akali
|
17
33
|

|
18
34
|
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
starcall (0.
|
4
|
+
starcall (0.3.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)
|
data/README.md
CHANGED
@@ -119,6 +119,34 @@ 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
|
+
### Champion Mastery V4
|
126
|
+
|
127
|
+
#### `summoner`
|
128
|
+
[Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getAllChampionMasteries)
|
129
|
+
|
130
|
+
Required fields:
|
131
|
+
- `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
|
132
|
+
- `region` (The reigion that the summoner is in.)
|
133
|
+
|
134
|
+
#### `summoner_on_champion`
|
135
|
+
[Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getChampionMastery)
|
136
|
+
|
137
|
+
Required fields:
|
138
|
+
- `encrypted_summoner_id` (The encrypted summoner ID for the summoner you want to know about.)
|
139
|
+
- `champion_id` (The ID number of the champion that you want to know about.)
|
140
|
+
- `region` (The reigion that the summoner is in.)
|
141
|
+
|
142
|
+
#### `summoner_total_mastery`
|
143
|
+
[Riot API Documentation](https://developer.riotgames.com/apis#champion-mastery-v4/GET_getChampionMasteryScore)
|
144
|
+
|
145
|
+
Required fields:
|
146
|
+
- `encrypted_summoner_id` (the encrypted summoner ID for the summoner you want to know about.)
|
147
|
+
- `region` (The reigion that the summoner is in.)
|
148
|
+
|
149
|
+
|
122
150
|
## Development
|
123
151
|
|
124
152
|
After checking out the repo, run `bundle install` to install dependencies.
|
data/lib/starcall.rb
CHANGED
@@ -2,9 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
|
6
|
-
class
|
7
|
-
|
8
|
-
|
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
|
@@ -1,23 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Starcall
|
4
|
-
module
|
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
|
data/lib/starcall/languages.rb
CHANGED
data/lib/starcall/regions.rb
CHANGED
data/lib/starcall/static_data.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'starcall/api_requests'
|
4
|
+
|
3
5
|
module Starcall
|
4
6
|
# This class is used for all things Static Data related.
|
5
7
|
# Using Riots Static data and Data Dragon.
|
@@ -16,29 +18,29 @@ module Starcall
|
|
16
18
|
# Season ids are used in match history to indicate which season a match was played.
|
17
19
|
# A full list of season ids can be retrieved with the below method.
|
18
20
|
def season_ids
|
19
|
-
ApiRequests.make_request(url: static_url(search_term: 'seasons'))
|
21
|
+
Starcall::ApiRequests.make_request(url: static_url(search_term: 'seasons'))
|
20
22
|
end
|
21
23
|
|
22
24
|
# Queue ids show up in several places throughout the API and are used to indicate which kind of match was played.
|
23
25
|
# A full list of queue ids can be can be retrieved with the below method.
|
24
26
|
def queue_ids
|
25
|
-
ApiRequests.make_request(url: static_url(search_term: 'queues'))
|
27
|
+
Starcall::ApiRequests.make_request(url: static_url(search_term: 'queues'))
|
26
28
|
end
|
27
29
|
|
28
30
|
# Map ids are used in match history to indicate which map a match was played.
|
29
31
|
# A full list of map ids can be can be retrieved with the below method.
|
30
32
|
def map_ids
|
31
|
-
ApiRequests.make_request(url: static_url(search_term: 'maps'))
|
33
|
+
Starcall::ApiRequests.make_request(url: static_url(search_term: 'maps'))
|
32
34
|
end
|
33
35
|
|
34
36
|
# A full list of game modes can be can be retrieved with the below method.
|
35
37
|
def game_modes
|
36
|
-
ApiRequests.make_request(url: static_url(search_term: 'gameModes'))
|
38
|
+
Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameModes'))
|
37
39
|
end
|
38
40
|
|
39
41
|
# A full list of game types can be can be retrieved with the below method.
|
40
42
|
def game_types
|
41
|
-
ApiRequests.make_request(url: static_url(search_term: 'gameTypes'))
|
43
|
+
Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameTypes'))
|
42
44
|
end
|
43
45
|
|
44
46
|
# All valid Data Dragon versions can be can be retrieved with the below method.
|
@@ -47,39 +49,39 @@ module Starcall
|
|
47
49
|
# This typically occurs when there's an error in the original build.
|
48
50
|
# As such, you should always use the most recent Data Dragon version for a given patch for the best results.
|
49
51
|
def dd_versions
|
50
|
-
ApiRequests.make_request(url: dd_versions_url)
|
52
|
+
Starcall::ApiRequests.make_request(url: dd_versions_url)
|
51
53
|
end
|
52
54
|
|
53
55
|
# Data Dragon versions aren't always equivalent to the League of Legends client version in a region.
|
54
56
|
def dd_region_versions
|
55
|
-
ApiRequests.make_request(url: dd_region_version_url)
|
57
|
+
Starcall::ApiRequests.make_request(url: dd_region_version_url)
|
56
58
|
end
|
57
59
|
|
58
60
|
# This returns a list of all champion with a brief summary, including stats, id and blurb.
|
59
61
|
def dd_champions
|
60
|
-
ApiRequests.make_request(url: dd_url(game_component: 'champion'))
|
62
|
+
Starcall::ApiRequests.make_request(url: dd_url(game_component: 'champion'))
|
61
63
|
end
|
62
64
|
|
63
65
|
# For me detailed and specific information about a champion, this call can be used.
|
64
66
|
def dd_specific_champion(champion_name:)
|
65
|
-
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))
|
66
68
|
end
|
67
69
|
|
68
70
|
# Data Dragon also provides detail for every item in the game.
|
69
71
|
# with this method you can find info such as the item's description, purchase value, sell value,
|
70
72
|
# items it builds from, items it builds into, and stats granted from the item.
|
71
73
|
def dd_items
|
72
|
-
ApiRequests.make_request(url: dd_url(game_component: 'item'))
|
74
|
+
Starcall::ApiRequests.make_request(url: dd_url(game_component: 'item'))
|
73
75
|
end
|
74
76
|
|
75
77
|
# Details about summoner spells.
|
76
78
|
def dd_summoner_spells
|
77
|
-
ApiRequests.make_request(url: dd_url(game_component: 'summoner'))
|
79
|
+
Starcall::ApiRequests.make_request(url: dd_url(game_component: 'summoner'))
|
78
80
|
end
|
79
81
|
|
80
82
|
# Details about profile icons and where they can be found on the sprite sheets.
|
81
83
|
def dd_profile_icons
|
82
|
-
ApiRequests.make_request(url: dd_url(game_component: 'profileicon'))
|
84
|
+
Starcall::ApiRequests.make_request(url: dd_url(game_component: 'profileicon'))
|
83
85
|
end
|
84
86
|
|
85
87
|
private
|
@@ -103,7 +105,7 @@ module Starcall
|
|
103
105
|
|
104
106
|
# This gets the current version of specific game components, such as champions.
|
105
107
|
def dd_current_data_version(game_component:)
|
106
|
-
ApiRequests.make_request(url: dd_region_version_url)['n'][game_component]
|
108
|
+
Starcall::ApiRequests.make_request(url: dd_region_version_url)['n'][game_component]
|
107
109
|
end
|
108
110
|
|
109
111
|
# This builds the data dragon url for specific components such as champions,
|
data/lib/starcall/version.rb
CHANGED
data/starcall.gemspec
CHANGED
@@ -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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2020-06-30 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,12 @@ files:
|
|
114
128
|
- Rakefile
|
115
129
|
- lib/starcall.rb
|
116
130
|
- lib/starcall/api_requests.rb
|
117
|
-
- lib/starcall/
|
131
|
+
- lib/starcall/endpoints/champion_mastery_v4.rb
|
132
|
+
- lib/starcall/endpoints/endpoints.rb
|
133
|
+
- lib/starcall/errors/errors.rb
|
134
|
+
- lib/starcall/errors/invalid_language.rb
|
135
|
+
- lib/starcall/errors/invalid_region.rb
|
136
|
+
- lib/starcall/helpers/region_parser.rb
|
118
137
|
- lib/starcall/languages.rb
|
119
138
|
- lib/starcall/regions.rb
|
120
139
|
- lib/starcall/static_data.rb
|