taric 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/taric/client.rb +44 -11
- data/lib/taric/connection.rb +1 -0
- data/lib/taric/operation/api.rb +6 -15
- data/lib/taric/operation/champion.rb +10 -2
- data/lib/taric/operation/current_game.rb +2 -2
- data/lib/taric/operation/featured_games.rb +2 -2
- data/lib/taric/operation/game.rb +2 -2
- data/lib/taric/operation/lol_static_data.rb +51 -1
- data/lib/taric/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e7a47c9d9fcc0b6a342967bbcdce1d36df210e3
|
4
|
+
data.tar.gz: 05d90533b37c099998da7b6c9c49926a53049d48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e15826735122a20bd4bc40aab70f0a6ab792742d11ccd125cea6ffef22be2f888b3b3803798f8cbc3e7f4fc4df24c64b5d62237aad3be7121d88effc054765b3
|
7
|
+
data.tar.gz: 0865f86f099767656b268235feb4cb6c045362114ae3e783c842666f9321f796647113eea68ba188f6ab948b9cc7b4e26143232c576700dae20d156791ba1432
|
data/lib/taric/client.rb
CHANGED
@@ -4,6 +4,20 @@ module Taric
|
|
4
4
|
class Client
|
5
5
|
include Taric::Operation::API
|
6
6
|
|
7
|
+
REGION_ENDPOINT_INFO = {
|
8
|
+
br: {region: 'br'.freeze, platform_id: 'BR1'.freeze, host: 'br.api.pvp.net'},
|
9
|
+
eune: {region: 'eune'.freeze, platform_id: 'EUN1'.freeze, host: 'eune.api.pvp.net'},
|
10
|
+
euw: {region: 'euw'.freeze, platform_id: 'EUW1', host: 'euw.api.pvp.net'},
|
11
|
+
kr: {region: 'kr'.freeze, platform_id: 'KR', host: 'kr.api.pvp.net'},
|
12
|
+
lan: {region: 'lan'.freeze, platform_id: 'LA1', host: 'lan.api.pvp.net'},
|
13
|
+
las: {region: 'las'.freeze, platform_id: 'LA2', host: 'las.api.pvp.net'},
|
14
|
+
na: {region: 'na'.freeze, platform_id: 'NA1', host: 'na.api.pvp.net'},
|
15
|
+
oce: {region: 'oce'.freeze, platform_id: 'OC1', host: 'oce.api.pvp.net'},
|
16
|
+
tr: {region: 'tr'.freeze, platform_id: 'TR1', host: 'tr.api.pvp.net'},
|
17
|
+
ru: {region: 'ru'.freeze, platform_id: 'RU', host: 'ru.api.pvp.net'},
|
18
|
+
pbe: {region: 'pbe'.freeze, platform_id: 'PBE1', host: 'pbe.api.pvp.net'}
|
19
|
+
}.freeze
|
20
|
+
|
7
21
|
def initialize(api_key, region, requestor, response_handler)
|
8
22
|
@api_key = api_key
|
9
23
|
@region = region
|
@@ -11,21 +25,40 @@ module Taric
|
|
11
25
|
@response_handler = response_handler
|
12
26
|
end
|
13
27
|
|
14
|
-
def expand_template(operation, options = {})
|
15
|
-
operation.expand(options.merge(self.class.operation_values(@api_key, @region)))
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def response_for(operation, options = {})
|
20
|
-
RESPONSE.(expand_template(operation, options), @requestor, @response_handler)
|
21
|
-
end
|
22
|
-
|
23
28
|
class << self
|
24
29
|
extend Memoist
|
25
|
-
|
26
|
-
|
30
|
+
|
31
|
+
# @note Memoized
|
32
|
+
#
|
33
|
+
# Sets up and returns hash of api key and region values.
|
34
|
+
#
|
35
|
+
# @params api_key [String] rito api key
|
36
|
+
# @params region [Symbol] key for region
|
37
|
+
# @return [Hash] of api_key and region info
|
38
|
+
def operation_values(api_key:, region:)
|
39
|
+
{api_key: api_key}.merge!(REGION_ENDPOINT_INFO[region])
|
40
|
+
end
|
41
|
+
memoize :operation_values
|
42
|
+
|
43
|
+
# Expands operation template with api_key, region, and option values.
|
44
|
+
#
|
45
|
+
# @param api_key [String] rito api key
|
46
|
+
# @param region [Symbol] key for region
|
47
|
+
# @param operation [Addressable::Template] URI template for operation
|
48
|
+
# @param options [Hash] optional, values for template
|
49
|
+
# @return [Addressable::URI] of expanded template
|
50
|
+
#
|
51
|
+
# @example
|
52
|
+
# Taric::Client.expand_template(api_key: 'ritokey', region: :na, operation: Taric::Operation::Champion::CHAMPIONS)
|
53
|
+
def expand_template(api_key:, region:, operation:, options: {})
|
54
|
+
operation.expand(options.merge(operation_values(api_key: api_key, region: region)))
|
27
55
|
end
|
28
56
|
end
|
29
57
|
|
58
|
+
private
|
59
|
+
def response_for(operation, options = {})
|
60
|
+
url = self.class.expand_template(api_key: @api_key, region: @region, operation: operation, options: options)
|
61
|
+
API_CALL.(url: url, requestor: @requestor, response_handler: @response_handler)
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
data/lib/taric/connection.rb
CHANGED
data/lib/taric/operation/api.rb
CHANGED
@@ -22,21 +22,12 @@ module Taric
|
|
22
22
|
include Taric::Operation::Stats
|
23
23
|
include Taric::Operation::Summoner
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
las: {region: 'las'.freeze, platform_id: 'LA2', host: 'las.api.pvp.net'},
|
32
|
-
na: {region: 'na'.freeze, platform_id: 'NA1', host: 'na.api.pvp.net'},
|
33
|
-
oce: {region: 'oce'.freeze, platform_id: 'OC1', host: 'oce.api.pvp.net'},
|
34
|
-
tr: {region: 'tr'.freeze, platform_id: 'TR1', host: 'tr.api.pvp.net'},
|
35
|
-
ru: {region: 'ru'.freeze, platform_id: 'RU', host: 'ru.api.pvp.net'},
|
36
|
-
pbe: {region: 'pbe'.freeze, platform_id: 'PBE1', host: 'pbe.api.pvp.net'}
|
37
|
-
}.freeze
|
38
|
-
|
39
|
-
RESPONSE = -> url, requestor, response_handler {
|
25
|
+
# Template for requesting the url and processing the response.
|
26
|
+
#
|
27
|
+
# @param url String
|
28
|
+
# @param requestor Proc (lambda)
|
29
|
+
# @param response_handler Proc (lambda)
|
30
|
+
API_CALL = -> (url:, requestor:, response_handler:) {
|
40
31
|
response_handler.(requestor.(url))
|
41
32
|
}.curry
|
42
33
|
|
@@ -11,9 +11,9 @@ module Taric
|
|
11
11
|
CHAMPIONS = Addressable::Template.new("#{CHAMPION_BASE_URL}{?api_key,freeToPlay}")
|
12
12
|
CHAMPION_BY_ID = Addressable::Template.new("#{CHAMPION_BASE_URL}/{id}{?api_key}")
|
13
13
|
|
14
|
-
# Returns
|
14
|
+
# Returns champion data.
|
15
15
|
#
|
16
|
-
# @see
|
16
|
+
# @see https://developer.riotgames.com/api/methods#!/958/3290
|
17
17
|
# @param free_to_play [Boolean] optional, nil returns all, true or false to filter if they're free to play or not
|
18
18
|
# @return [Hash] embedding [Array] of champions keyed off of "champions"
|
19
19
|
#
|
@@ -25,6 +25,14 @@ module Taric
|
|
25
25
|
response_for CHAMPIONS, freeToPlay: free_to_play
|
26
26
|
end
|
27
27
|
|
28
|
+
# Returns champion data by id.
|
29
|
+
#
|
30
|
+
# @see https://developer.riotgames.com/api/methods#!/958/3289
|
31
|
+
# @param id [Fixnum] id of champion
|
32
|
+
# @return [Hash] of champion data
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# champion = client.champion(id: 266)
|
28
36
|
def champion(id:)
|
29
37
|
response_for CHAMPION_BY_ID, id: id
|
30
38
|
end
|
@@ -3,9 +3,9 @@ module Taric
|
|
3
3
|
module CurrentGame
|
4
4
|
GAME_INFO = Addressable::Template.new 'https://{host}/observer-mode/rest/consumer/getSpectatorGameInfo/{platform_id}/{summonerId}{?api_key}'
|
5
5
|
|
6
|
-
# Returns
|
6
|
+
# Returns current game data for summoner id.
|
7
7
|
#
|
8
|
-
# @see
|
8
|
+
# @see https://developer.riotgames.com/api/methods#!/956/3287
|
9
9
|
# @param summoner_id [Fixnum] required, id of summoner
|
10
10
|
# @return [Hash] of game data for summoner id
|
11
11
|
#
|
@@ -3,9 +3,9 @@ module Taric
|
|
3
3
|
module FeaturedGames
|
4
4
|
FEATURED_GAMES = Addressable::Template.new 'https://{host}/observer-mode/rest/featured{?api_key}'
|
5
5
|
|
6
|
-
# Returns
|
6
|
+
# Returns featured games.
|
7
7
|
#
|
8
|
-
# @see
|
8
|
+
# @see https://developer.riotgames.com/api/methods#!/957/3288
|
9
9
|
# @return [Hash] of featured games in [Array] keyed by 'gameList'
|
10
10
|
#
|
11
11
|
# @example
|
data/lib/taric/operation/game.rb
CHANGED
@@ -7,9 +7,9 @@ module Taric
|
|
7
7
|
GAME_VERSION = 'v1.3'.freeze
|
8
8
|
RECENT = Addressable::Template.new "#{BASE_URL_FN.(GAME_VERSION)}/game/by-summoner/{summonerId}/recent{?api_key}"
|
9
9
|
|
10
|
-
# Returns
|
10
|
+
# Returns recent game data for summoner id.
|
11
11
|
#
|
12
|
-
# @see
|
12
|
+
# @see https://developer.riotgames.com/api/methods#!/959/3291
|
13
13
|
# @param summoner_id [Fixnum] required, id of summoner
|
14
14
|
# @return [Hash] of recent game data for summoner id
|
15
15
|
#
|
@@ -6,7 +6,7 @@ module Taric
|
|
6
6
|
VERSION = 'v1.2'
|
7
7
|
BASE_STATIC_URL = "https://global.api.pvp.net/api/lol/static-data/{region}/#{VERSION}"
|
8
8
|
|
9
|
-
STATIC_CHAMPIONS = Addressable::Template.new "#{BASE_STATIC_URL}/champion{?api_key}"
|
9
|
+
STATIC_CHAMPIONS = Addressable::Template.new "#{BASE_STATIC_URL}/champion{?api_key,dataById}"
|
10
10
|
STATIC_CHAMPION = Addressable::Template.new "#{STATIC_CHAMPIONS}/{id}{?api_key}"
|
11
11
|
STATIC_ITEMS = Addressable::Template.new "#{BASE_STATIC_URL}/item{?api_key}"
|
12
12
|
STATIC_ITEM = Addressable::Template.new "#{STATIC_ITEMS}/{id}{?api_key}"
|
@@ -93,6 +93,56 @@ module Taric
|
|
93
93
|
'vars'.freeze
|
94
94
|
].freeze
|
95
95
|
|
96
|
+
# locales mapped to languages
|
97
|
+
LOCALE = {
|
98
|
+
bg_BG: 'Bulgarian (Bulgaria)',
|
99
|
+
cs_CZ: 'Czech (Czech Republic)',
|
100
|
+
de_DE: 'German (Germany)',
|
101
|
+
el_GR: 'Greek (Greece)',
|
102
|
+
en_AU: 'English (Australia)',
|
103
|
+
en_GB: 'English (United Kingdom)',
|
104
|
+
en_PH: 'English (Republic of the Philippines)',
|
105
|
+
en_PL: 'English (Poland)',
|
106
|
+
en_SG: 'English (Singapore)',
|
107
|
+
en_US: 'English (United States)',
|
108
|
+
es_AR: 'Spanish (Argentina)',
|
109
|
+
es_ES: 'Spanish (Spain)',
|
110
|
+
es_MX: 'Spanish (Mexico)',
|
111
|
+
fr_FR: 'French (France)',
|
112
|
+
hu_HU: 'Hungarian (Hungary)',
|
113
|
+
id_ID: 'Indonesian (Indonesia)',
|
114
|
+
it_IT: 'Italian (Italy)',
|
115
|
+
ja_JP: 'Japanese (Japan)',
|
116
|
+
ko_KR: 'Korean (Korea)',
|
117
|
+
nl_NL: 'Dutch (Netherlands)',
|
118
|
+
ms_MY: 'Malay (Malaysia)',
|
119
|
+
pl_PL: 'Polish (Poland)',
|
120
|
+
pt_BR: 'Portuguese (Brazil)',
|
121
|
+
pt_PT: 'Portuguese (Portugal)',
|
122
|
+
ro_RO: 'Romanian (Romania)',
|
123
|
+
ru_RU: 'Russian (Russia)',
|
124
|
+
th_TH: 'Thai (Thailand)',
|
125
|
+
tr_TR: 'Turkish (Turkey)',
|
126
|
+
vn_VN: 'Vietnamese (Viet Nam)',
|
127
|
+
zh_CN: 'Chinese (China)',
|
128
|
+
zh_MY: 'Chinese (Malaysia)',
|
129
|
+
zh_TW: 'Chinese (Taiwan)'
|
130
|
+
}
|
131
|
+
|
132
|
+
LOCALE_KEYS = LOCALE.keys
|
133
|
+
|
134
|
+
# Static champion data
|
135
|
+
#
|
136
|
+
# @param data_by_id [Boolean] optional, if true, champion data keyed to IDs
|
137
|
+
# @param champ_data_option [String] optional, filter from [CHAMP_DATA_OPTIONS]
|
138
|
+
# @param locale [Symbol] optional, results will be in locale [LOCALE], or default for region if nil
|
139
|
+
# @param version [String] optional, enforces version of static data, or latest if nil
|
140
|
+
#
|
141
|
+
# @return [Hash] of static champion data
|
142
|
+
#
|
143
|
+
# @example
|
144
|
+
# champions = client.static_champions
|
145
|
+
# champions_mapped_by_id = client.static_champions(data_by_id: true)
|
96
146
|
def static_champions(data_by_id: nil, champ_data_option: nil, locale: nil, version: nil)
|
97
147
|
response_for STATIC_CHAMPIONS, {dataById: data_by_id, champData: champ_data_option, locale: locale, version: version}
|
98
148
|
end
|
data/lib/taric/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Yi
|
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
240
|
version: '0'
|
241
241
|
requirements: []
|
242
242
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.4.
|
243
|
+
rubygems_version: 2.4.3
|
244
244
|
signing_key:
|
245
245
|
specification_version: 4
|
246
246
|
summary: An outrageous Riot Games LoL API Client
|