taric 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d7d5bd2d82c7a170eb90b471c89dbe128e9a4fe
4
- data.tar.gz: 50920d65ad41b29f90f110e5dc94dad9778c0b22
3
+ metadata.gz: af5a3fbf7f3ce947a8d074935d86c42bcec230a0
4
+ data.tar.gz: 123007565b2acd2dd52d31e41cb53e327242b840
5
5
  SHA512:
6
- metadata.gz: 569901532a3f398f084a33f07adeb48e797a5d01ed4e3cdd339acb18af3bc33587f81fc8eb8d5bfcd2b0d1f0dc61e164931e2ed0cbac481bc6e4ccb4e81da12e
7
- data.tar.gz: e91429937212e222b021fd0029daf59f5d605de31cf65a5a6c71018f8fec11e9d7397430ee7f743f710138763eed7a0d523e0c31cfa339c4dcf91d38fca0d498
6
+ metadata.gz: a4b22562e2dbd547266f99e9512169b9641aec212d9da8815fb2ccc56464bbc032c251a8118cd07889f15f60027e30175b3948c9a952d52e972699b10e110700
7
+ data.tar.gz: fb14c6ebda12d959f448a4346d9b36757a0000efd9a3f8bdf44b2b19bd33fd66d21cc19de1dfce49d990f17875da07bb6223ffbf54e255345b12b480b7ccbe02
data/lib/taric.rb CHANGED
@@ -7,32 +7,32 @@ require 'memoist'
7
7
 
8
8
  module Taric
9
9
  class << self
10
- extend Memoist
11
10
  attr_accessor :configuration
12
11
 
13
- def client(region = :na, config = @configuration ||= Taric::Configuration.new)
14
- Taric::Client.new(config.api_key, region, config.requestor.(connection(config)), config.response_handler)
12
+ def client(region: :na, config: @configuration ||= Taric::Configuration.new)
13
+ Taric::Client.new(api_key: config.api_key,
14
+ region: region,
15
+ requestor: config.requestor.(connection(config)),
16
+ response_handler: config.response_handler)
15
17
  end
16
- memoize :client
17
18
 
19
+ # Sets global configuration.
20
+ #
21
+ # @example
22
+ # Taric.configure! do |config|
23
+ # config.api_key = 'your_api_key'
24
+ # end
18
25
  def configure!
19
26
  reset!
20
27
  yield(configuration)
21
28
  end
22
29
 
30
+ # Resets global configuration.
31
+ #
23
32
  def reset!
24
33
  @configuration = Taric::Configuration.new
25
34
  end
26
35
 
27
- def method_missing(method, *args, &block)
28
- return super unless client.respond_to?(method)
29
- client.send(method, *args, &block)
30
- end
31
-
32
- def respond_to?(method, include_all=false)
33
- client.respond_to?(method, include_all) || super
34
- end
35
-
36
36
  include Taric::Connection
37
37
  end
38
38
 
data/lib/taric/client.rb CHANGED
@@ -18,7 +18,12 @@ module Taric
18
18
  pbe: {region: 'pbe'.freeze, platform_id: 'PBE1', host: 'pbe.api.pvp.net'}
19
19
  }.freeze
20
20
 
21
- def initialize(api_key, region, requestor, response_handler)
21
+ # @param api_key [String] rito api key
22
+ # @param region [Symbol] region code
23
+ # @param requestor [Proc] lambda that will accept a url and return a [Faraday::Response]
24
+ # @param response_handler [Proc] lambda that accepts [Faraday::Response] and handles it
25
+ #
26
+ def initialize(api_key:, region:, requestor:, response_handler:)
22
27
  @api_key = api_key
23
28
  @region = region
24
29
  @requestor = requestor
@@ -9,6 +9,7 @@ require_relative 'match'
9
9
  require_relative 'match_history'
10
10
  require_relative 'stats'
11
11
  require_relative 'summoner'
12
+ require_relative 'team'
12
13
  module Taric
13
14
  module Operation
14
15
  module API
@@ -23,6 +24,7 @@ module Taric
23
24
  include Taric::Operation::MatchHistory
24
25
  include Taric::Operation::Stats
25
26
  include Taric::Operation::Summoner
27
+ include Taric::Operation::Team
26
28
 
27
29
  # Template for requesting the url and processing the response.
28
30
  #
@@ -9,28 +9,41 @@ module Taric
9
9
  BASE_LEAGUE_URL = "#{BASE_URL_FN.(LEAGUE_VERSION)}/league"
10
10
 
11
11
  LEAGUES_BY_SUMMONER_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-summoner/{summonerIds}{?api_key}"
12
- ENTRIES_BY_SUMMONER_IDS = Addressable::Template.new "#{LEAGUES_BY_SUMMONER_IDS}/entry{?api_key}"
12
+ ENTRIES_BY_SUMMONER_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-summoner/{summonerIds}/entry{?api_key}"
13
13
  LEAGUES_BY_TEAM_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-team/{teamIds}{?api_key}"
14
- ENTRIES_BY_TEAM_IDS = Addressable::Template.new "#{LEAGUES_BY_TEAM_IDS}/entry{?api_key}"
15
- CHALLENGER = Addressable::Template.new "#{BASE_LEAGUE_URL}/challenger{?api_key}"
14
+ ENTRIES_BY_TEAM_IDS = Addressable::Template.new "#{BASE_LEAGUE_URL}/by-team/{teamIds}/entry{?api_key}"
15
+ CHALLENGER = Addressable::Template.new "#{BASE_LEAGUE_URL}/challenger{?api_key,type}"
16
16
 
17
+ CHALLENGER_QUEUE_TYPES = ['RANKED_SOLO_5x5'.freeze, 'RANKED_TEAM_3x3'.freeze, 'RANKED_TEAM_5x5'.freeze].freeze
18
+
19
+ # @see https://developer.riotgames.com/api/methods#!/936/3241
17
20
  def leagues_by_summoner_ids(summoner_ids:)
18
21
  response_for LEAGUES_BY_SUMMONER_IDS, {summonerIds: summoner_ids}
19
22
  end
20
23
 
24
+ # @see https://developer.riotgames.com/api/methods#!/936/3245
21
25
  def league_entries_by_summoner_ids(summoner_ids:)
22
26
  response_for ENTRIES_BY_SUMMONER_IDS, {summonerIds: summoner_ids}
23
27
  end
24
28
 
29
+ # @see https://developer.riotgames.com/api/methods#!/936/3242
25
30
  def leagues_by_team_ids(team_ids:)
26
31
  response_for LEAGUES_BY_TEAM_IDS, {teamIds: team_ids}
27
32
  end
28
33
 
34
+ # @see https://developer.riotgames.com/api/methods#!/936/3244
29
35
  def league_entries_by_team_ids(team_ids:)
30
36
  response_for ENTRIES_BY_TEAM_IDS, {teamIds: team_ids}
31
37
  end
32
38
 
39
+ # Challenger league data for type.
40
+ #
41
+ # @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
33
43
  def challenger(type: )
44
+ raise ArgumentError,
45
+ "Invalid argument: #{type}, arg must be in #{CHALLENGER_QUEUE_TYPES}" unless CHALLENGER_QUEUE_TYPES.include?(type)
46
+
34
47
  response_for CHALLENGER, {type: type}
35
48
  end
36
49
  end
@@ -10,10 +10,12 @@ module Taric
10
10
  TEAMS_BY_SUMMONER_IDS = Addressable::Template.new "#{BASE_TEAM_URL}/by-summoner/{summonerIds}"
11
11
  TEAMS_BY_TEAM_IDS = Addressable::Template.new "#{BASE_TEAM_URL}/{teamIds}"
12
12
 
13
+ # @see https://developer.riotgames.com/api/methods#!/937/3247
13
14
  def teams_by_summoner_ids(summoner_ids:)
14
15
  response_for TEAMS_BY_SUMMONER_IDS, {summonerIds: summoner_ids}
15
16
  end
16
17
 
18
+ # @see https://developer.riotgames.com/api/methods#!/937/3246
17
19
  def teams(team_ids:)
18
20
  response_for TEAMS_BY_TEAM_IDS, {teamIds: team_ids}
19
21
  end
data/lib/taric/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Taric
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.1.5
4
+ version: 0.1.6
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-03-19 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler