taric 0.3.1 → 0.3.3

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
  SHA1:
3
- metadata.gz: 7902c7e824920bcdc9adc4b42f334dbac902fe68
4
- data.tar.gz: 30e5b9ef6a135ec72dd44734aa884660064fc3f0
3
+ metadata.gz: c302de47946d4d5337732907248b9cdf7f45fa6b
4
+ data.tar.gz: 34cdc8513b9d50a55197e69be960b64d43350635
5
5
  SHA512:
6
- metadata.gz: 43f68e87d1cffe89e1a40bd4bf6ed7413e3e554800052d1b7690a4fcaff2fc075cdb2b21655f8201cbcbadfc3aa805e279099d4c0c588643053683a5daa7236c
7
- data.tar.gz: 1a012bddbce732f14f9ebf8b445e87c1dcc6ed2e0f511346a63fa62929c46db3794f659d544f98b29bed48d3d80f67ddae41b4b3f2dcfda503f2dca0cb451d77
6
+ metadata.gz: adb304d96a47d9a67ce8ebbe3cbbcfa0b0728ca4b760cce434ed02a84797075d31bb1c5e3e96d66af2442b1eaf75f0bdd16a374f00bfc6e65ed39b809c89e6d9
7
+ data.tar.gz: 5b14d61f5ec6d887d16658c0a487b698e8571fa403478452089aed7b2a326c13e731f8c0288f00aa2d3e1bb8a4f85d4d5d37b286205fa62c3b09ad1b5fed015d
data/lib/taric.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'taric/client'
2
2
  require 'taric/configuration'
3
-
3
+ require 'taric/constants'
4
4
  require 'taric/version'
5
5
  require 'memoist'
6
6
 
data/lib/taric/client.rb CHANGED
@@ -23,6 +23,8 @@ module Taric
23
23
 
24
24
  REGION_ENDPOINT_STRING_KEYS = REGION_ENDPOINT_INFO.keys.map(&:to_s).freeze
25
25
 
26
+ # New instance of Taric::Client.
27
+ #
26
28
  # @param api_key [String] rito api key
27
29
  # @param region [Symbol] region code
28
30
  # @param config [Configuration] configuration
@@ -0,0 +1,14 @@
1
+ module Taric
2
+ # rankedQueues
3
+ RANKED_SOLO_5X5 = 'RANKED_SOLO_5x5'.freeze
4
+ RANKED_TEAM_3X3 = 'RANKED_TEAM_3x3'.freeze
5
+ RANKED_TEAM_5X5 = 'RANKED_TEAM_5x5'.freeze
6
+
7
+ # seasons
8
+ PRESEASON3 = 'PRESEASON3'.freeze
9
+ SEASON3 = 'SEASON3'.freeze
10
+ PRESEASON2014 = 'PRESEASON2014'.freeze
11
+ SEASON2014 = 'SEASON2014'.freeze
12
+ PRESEASON2015 = 'PRESEASON2015'.freeze
13
+ SEASON2015 = 'SEASON2015'.freeze
14
+ end
@@ -10,6 +10,8 @@ require_relative 'match_list'
10
10
  require_relative 'stats'
11
11
  require_relative 'summoner'
12
12
  require_relative 'team'
13
+
14
+ # Combines operations of LoL API.
13
15
  module Taric
14
16
  module Operation
15
17
  module API
@@ -3,6 +3,14 @@ module Taric
3
3
  module Base
4
4
  BASE_URL_FN = -> version {"https://{host}/api/lol/{region}/#{version}"}
5
5
 
6
+ # Converts [Time] to [Fixnum], or returns argument.
7
+ #
8
+ # @param time [Time] Time to convert to epoch.
9
+ # @return [Fixnum] Time in epoch.
10
+ def epoch_time(time)
11
+ return time.to_i if time.instance_of? Time
12
+ time
13
+ end
6
14
  end
7
15
  end
8
16
  end
@@ -13,39 +13,82 @@ module Taric
13
13
  LEAGUES_BY_TEAM_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-team/{teamIds}{?api_key}"
14
14
  ENTRIES_BY_TEAM_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-team/{teamIds}/entry{?api_key}"
15
15
  CHALLENGER = Addressable::Template.new "#{BASE_LEAGUE_URL}/challenger{?api_key,type}"
16
+ MASTER = Addressable::Template.new "#{BASE_LEAGUE_URL}/master{?api_key,type}"
16
17
 
17
18
  CHALLENGER_QUEUE_TYPES = ['RANKED_SOLO_5x5'.freeze, 'RANKED_TEAM_3x3'.freeze, 'RANKED_TEAM_5x5'.freeze].freeze
19
+ MASTER_QUEUE_TYPES = CHALLENGER_QUEUE_TYPES
18
20
 
19
- # @see https://developer.riotgames.com/api/methods#!/936/3241
21
+ # Leagues by summoner IDs.
22
+ #
23
+ # @see https://developer.riotgames.com/api/methods#!/985/3351
24
+ # @param summoner_ids summoner_ids [String] comma separated list of summoner ids
25
+ # @return [Hash] leagues keyed by summoner ids
26
+ #
27
+ # @example
28
+ # result = client.leagues_by_summoner_ids(summoner_ids: '21066,38877656')
29
+ # leagues = result['21066']
30
+ # entries = first_summoner_leagues.first['entries']
20
31
  def leagues_by_summoner_ids(summoner_ids:)
21
32
  response_for LEAGUES_BY_SUMMONER_IDS, {summonerIds: summoner_ids}
22
33
  end
23
34
 
24
- # @see https://developer.riotgames.com/api/methods#!/936/3245
35
+ # League entries by summoner IDs.
36
+ #
37
+ # @see https://developer.riotgames.com/api/methods#!/985/3351
38
+ # @param summoner_ids summoner_ids [String] comma separated list of summoner ids
39
+ # @return [Hash] league entries keyed by summoner_ids
40
+ #
41
+ # @example
42
+ # result = client.league_entries_by_summoner_ids(summoner_ids: '21066,38877656')
43
+ # entries = result['38877656']
44
+ # entry = entries.first
45
+ # entry_name = entry['name']
46
+ # entry_tier = entry['tier']
25
47
  def league_entries_by_summoner_ids(summoner_ids:)
26
48
  response_for ENTRIES_BY_SUMMONER_IDS, {summonerIds: summoner_ids}
27
49
  end
28
50
 
29
- # @see https://developer.riotgames.com/api/methods#!/936/3242
51
+ # Leagues by team IDs.
52
+ #
53
+ # @see https://developer.riotgames.com/api/methods#!/985/3352
54
+ # @param team_ids team_ids [String] comma separated list of team ids
55
+ # @return [Hash] leagues keyed by team_ids
30
56
  def leagues_by_team_ids(team_ids:)
31
57
  response_for LEAGUES_BY_TEAM_IDS, {teamIds: team_ids}
32
58
  end
33
59
 
34
- # @see https://developer.riotgames.com/api/methods#!/936/3244
60
+ # League entries by team IDs.
61
+ #
62
+ # @see https://developer.riotgames.com/api/methods#!/985/3355
63
+ # @param team_ids team_ids [String] comma separated list of team ids
64
+ # @return [Hash] league entries keyed by team_ids
35
65
  def league_entries_by_team_ids(team_ids:)
36
66
  response_for ENTRIES_BY_TEAM_IDS, {teamIds: team_ids}
37
67
  end
38
68
 
39
- # Challenger league data for type.
69
+ # Challenger league data for queue type.
40
70
  #
41
71
  # @param type [String] required, must be RANKED_SOLO_5x5, RANKED_TEAM_3x3, or RANKED_TEAM_5x5
42
- # @see https://developer.riotgames.com/api/methods#!/936/3243
72
+ # @return [Hash] challenger league data
73
+ # @see https://developer.riotgames.com/api/methods#!/985/3353
43
74
  def challenger(type: )
44
75
  raise ArgumentError,
45
76
  "Invalid argument: #{type}, arg must be in #{CHALLENGER_QUEUE_TYPES}" unless CHALLENGER_QUEUE_TYPES.include?(type)
46
77
 
47
78
  response_for CHALLENGER, {type: type}
48
79
  end
80
+
81
+ # Master league data for queue type.
82
+ #
83
+ # @param type [String] required, must be RANKED_SOLO_5x5, RANKED_TEAM_3x3, or RANKED_TEAM_5x5
84
+ # @return [Hash] master league data
85
+ # https://developer.riotgames.com/api/methods#!/985/3354
86
+ def master(type: )
87
+ raise ArgumentError,
88
+ "Invalid argument: #{type}, arg must be in #{MASTER_QUEUE_TYPES}" unless MASTER_QUEUE_TYPES.include?(type)
89
+
90
+ response_for MASTER, {type: type}
91
+ end
49
92
  end
50
93
  end
51
94
  end
@@ -220,7 +220,11 @@ module Taric
220
220
  response_for STATIC_LANGUAGES
221
221
  end
222
222
 
223
+ # Maps availalble.
223
224
  # @see https://developer.riotgames.com/api/methods#!/968/3328
225
+ # @param locale [String] filter by locale
226
+ # @param version [String] patch version
227
+ # @return [Hash] of maps available.
224
228
  def static_map(locale: nil, version: nil)
225
229
  response_for STATIC_MAP, {locale: locale, version: version}
226
230
  end
@@ -7,17 +7,20 @@ module Taric
7
7
  MATCH_LIST_VERSION = 'v2.2'.freeze
8
8
  MATCH_LIST = Addressable::Template.new "#{BASE_URL_FN.(MATCH_LIST_VERSION)}/matchlist/by-summoner/{summonerId}{?api_key,championIds,rankedQueues,seasons,beginTime,endTime,beginIndex,endIndex}"
9
9
 
10
+ # Returns match list for summoner.
11
+ #
10
12
  # @see https://developer.riotgames.com/api/methods#!/1026/3480
11
13
  # @param summoner_id [Fixnum] summoner Id
12
14
  # @param champion_ids [String] Optional - Comma-separated list of champion IDs to use for fetching games.
13
15
  # @param ranked_queues [String] Optional - Comma-separated list of ranked queue types to use for fetching games. Non-ranked queue types will be ignored.
14
16
  # @param seasons [String] Optional - Comma-separated list of seasons to use for fetching games.
15
- # @param begin_time [Fixnum] Optional - The begin time in epoch milliseconds to use for fetching games.
16
- # @param end_time [Fixnum] Optional - The end time in epoch milliseconds to use for fetching games.
17
+ # @param begin_time [Fixnum or Time] Optional - The begin time to use for fetching games.
18
+ # @param end_time [Fixnum or Time] Optional - The end time to use for fetching games.
17
19
  def match_list(summoner_id:, champion_ids: nil, ranked_queues: nil, seasons: nil, begin_time: nil, end_time: nil, begin_index: nil, end_index: nil)
18
20
  response_for MATCH_LIST,
19
- {summonerId: summoner_id, championIds: champion_ids, rankedQueues: ranked_queues, seasons: seasons, beginTime: begin_time, endTime: end_time, beginIndex: begin_index, endIndex: end_index}
21
+ {summonerId: summoner_id, championIds: champion_ids, rankedQueues: ranked_queues, seasons: seasons, beginTime: epoch_time(begin_time), endTime: epoch_time(end_time), beginIndex: begin_index, endIndex: end_index}
20
22
  end
23
+
21
24
  end
22
25
  end
23
26
  end
data/lib/taric/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Taric
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Yi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,6 +177,7 @@ files:
177
177
  - lib/taric/client.rb
178
178
  - lib/taric/configuration.rb
179
179
  - lib/taric/connection.rb
180
+ - lib/taric/constants.rb
180
181
  - lib/taric/faraday_middleware/http_exception.rb
181
182
  - lib/taric/operation/api.rb
182
183
  - lib/taric/operation/base.rb