lolapi 0.0.2 → 0.1.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
  SHA1:
3
- metadata.gz: e7d8bebee5848c3a7da0853ce2af3e1a0ccdab1a
4
- data.tar.gz: f2ea8a50c5ac4a590d965069c0bfae87bcdbdcde
3
+ metadata.gz: c70a1ce14e133f6e23bac047631748e143cba8c5
4
+ data.tar.gz: c854ea9d3330b81240081f5ba27eaf0a172ace44
5
5
  SHA512:
6
- metadata.gz: e9f19fe533b208d5082327be7f359c18279b4eef5da207f2bd5aec8bb5b8ea86ad77023084a325a1c69367c403084276f8e9a44116cfef380fdbd1ccb3bddf0c
7
- data.tar.gz: 8ee7c6866ad3993035bbaf16f66b216c57ad99c7df5affe7cef185ee6e81fc54fa71f85f81ccb782d476a4421852180125f2c90d01e9a87bcb2eccc2f4924234
6
+ metadata.gz: ac609032ed8b62c22cc72a3945fccff6e1a8511502018bb4c1d4cac81f1ea2503055b6cd33e003058afc4cbdb252529fed1bec34ef44a98284cfcc62c8404a83
7
+ data.tar.gz: 5bb4cd7c85340ea35d651ddaa57786b751bee68b1a358b5d6e8a3ab868f21c483e11f680c6a9e54501c5476df667b03741ae70a734500b2e6cd9b12c7b501a37
@@ -0,0 +1,3 @@
1
+ module LoLAPI
2
+ VERSION = "0.1.0"
3
+ end
@@ -1,12 +1,10 @@
1
1
  module Configuration
2
- DEFAULT_API_KEY = 'API KEY HERE'
3
-
4
2
  VALID_OPTIONS_KEYS = [:api_key].freeze
5
3
 
6
4
  attr_accessor *VALID_OPTIONS_KEYS
7
5
 
8
6
  def reset
9
- self.api_key = DEFAULT_API_KEY
7
+ self.api_key = nil
10
8
  end
11
9
 
12
10
  def configure
@@ -1,45 +1,86 @@
1
1
  require 'net/http'
2
- require 'cgi'
3
2
  require 'json'
4
3
  require 'configuration'
5
- class LoLAPI
4
+ require 'LoLAPI/version'
5
+ module LoLAPI
6
6
  extend Configuration
7
7
 
8
- def self.champion(region)
9
- query '/api/lol/' + region + '/v1.1/champion'
8
+ BASE_URL = 'http://prod.api.pvp.net'
9
+
10
+ def self.get_champions(region, free: nil)
11
+ if free.nil?
12
+ query '/api/lol/' + region + '/v1.1/champion'
13
+ else
14
+ query '/api/lol/' + region + '/v1.1/champion', params: 'freeToPlay=' + free.to_s
15
+ end
10
16
  end
11
17
 
12
- def self.game(summoner_id, region)
18
+ def self.get_game(summoner_id, region)
13
19
  query '/api/lol/' + region + '/v1.1/game/by-summoner/' + summoner_id.to_s + '/recent'
14
20
  end
15
21
 
16
- def self.league(summoner_id, region)
22
+ def self.get_league(summoner_id, region)
17
23
  query '/api/' + region + '/v2.1/league/by-summoner/' + summoner_id.to_s
18
24
  end
19
25
 
20
- def self.summary(summoner_id, region)
21
- query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/summary', 'season=SEASON3'
26
+ def self.get_summary(summoner_id, region, season: nil)
27
+ if season.nil?
28
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/summary'
29
+ else
30
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/summary', params: 'season=' + season
31
+ end
32
+ end
33
+
34
+ def self.get_ranked(summoner_id, region, season: nil)
35
+ if season.nil?
36
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/ranked'
37
+ else
38
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/ranked', params: 'season=' + season
39
+ end
40
+ end
41
+
42
+ def self.get_summoner_by_name(name, region)
43
+ query '/api/lol/' + region + '/v1.1/summoner/by-name/' + name.delete(' ')
44
+ end
45
+
46
+ def self.get_summoner_masteries(summoner_id, region)
47
+ query '/api/lol/' + region + '/v1.1/summoner/' + summoner_id.to_s + '/masteries'
48
+ end
49
+
50
+ def self.get_summoner_runes(summoner_id, region)
51
+ query '/api/lol/' + region + '/v1.1/summoner/' + summoner_id.to_s + '/runes'
22
52
  end
23
53
 
24
- def self.ranked(summoner_id, region)
25
- query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/ranked'
54
+ def self.get_summoner(summoner_id, region)
55
+ query '/api/lol/' + region + '/v1.1/summoner/' + summoner_id.to_s
26
56
  end
27
57
 
28
- def self.summoner(name, region)
29
- query '/api/lol/' + region + '/v1.1/summoner/by-name/' + name
58
+ def self.get_summoner_name(summoner_id, region)
59
+ query '/api/lol/' + region + '/v1.1/summoner/' + summoner_id.to_s + '/name'
30
60
  end
31
61
 
32
- def self.team(summoner_id, region)
62
+ def self.get_team(summoner_id, region)
33
63
  query '/api/' + region + '/v2.1/team/by-summoner/' + summoner_id.to_s
34
64
  end
35
65
 
36
- def self.query(uri, params = nil)
66
+ def self.query(uri, params: nil)
67
+ if check_key == 1
68
+ return nil
69
+ end
70
+
37
71
  if params.nil?
38
- response = Net::HTTP.get(URI('http://prod.api.pvp.net' + uri + '?api_key=' + self.api_key))
72
+ response = Net::HTTP.get(URI(BASE_URL + uri + '?api_key=' + self.api_key))
39
73
  else
40
- response = Net::HTTP.get(URI('http://prod.api.pvp.net' + uri + '?' + params + '&api_key=' + self.api_key))
74
+ response = Net::HTTP.get(URI(BASE_URL + uri + '?' + params + '&api_key=' + self.api_key))
41
75
  end
42
76
 
43
77
  JSON.parse(response)
44
78
  end
79
+
80
+ def self.check_key
81
+ if self.api_key.nil?
82
+ puts "ERROR: Please initialize lolapi with an API Key."
83
+ return 1
84
+ end
85
+ end
45
86
  end
metadata CHANGED
@@ -1,25 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2013-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
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
41
  description: A wrapper for the League of Legends API desc
14
- email: ian.mitchel1@live.com
42
+ email:
43
+ - ian.mitchel1@live.com
15
44
  executables: []
16
45
  extensions: []
17
46
  extra_rdoc_files: []
18
47
  files:
19
48
  - lib/lolapi.rb
20
49
  - lib/configuration.rb
50
+ - lib/LoLAPI/version.rb
21
51
  homepage: http://github.com/ianmitchell/lolapi
22
- licenses: []
52
+ licenses:
53
+ - MIT
23
54
  metadata: {}
24
55
  post_install_message:
25
56
  rdoc_options: []