blizzard_api 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 25a4f7ae3f8e8b5230e6cc493c10f964dc977f45d1813e6d074b24237094299f
4
- data.tar.gz: bc1a1ab587dec338a24e6013373e32cc21fb32db7c098128098b7f0246f50439
3
+ metadata.gz: 986e5045b51505acbdcbe757c1cab63997ae59ccd517ea10f31e53005a6a59d0
4
+ data.tar.gz: d0cc98867e15d90d40418474e5b3be6e3fdac5dd06b6bb0d065c94d32e879882
5
5
  SHA512:
6
- metadata.gz: 88c61c928fb2743d79cdf7d5fd4b8c6117317c5e102908d7108fea7d71887a9ebf916e7dc858055daff7dbf7df563e3525638382ba411cf51a14bdd78a46de54
7
- data.tar.gz: 7b73bd97fa40f2ffb7161a855c107a515e42a155b5357d51f094f54f02060f8079eb5fb2ec60a49651d71920aa5be98e25c93f02d266709b73cfa0bfbb22a362
6
+ metadata.gz: 84d3dbf1f764c2ebfc05d91ae9f78c0e081f722b10b03874c97b710cbac0357fdfa03d2272c833c5ca5726eb69c0a79c68af56552f945b1f6f08c74f991de94c
7
+ data.tar.gz: 4622761622e15884190e238d79f4fd00ae26091098394c84673a8a6d8c465e09773038b1bd85e5169d6da72cbcb8a21984025477a96a5c95dc05228c16af1e52
data/.rubocop_todo.yml CHANGED
@@ -1,7 +1,13 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-12-16 19:08:57 -0200 using RuboCop version 0.61.1.
3
+ # on 2019-03-06 13:04:37 -0300 using RuboCop version 0.61.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ Lint/UriEscapeUnescape:
11
+ Exclude:
12
+ - 'lib/blizzard_api/wow/community/character.rb'
13
+ - 'lib/blizzard_api/wow/community/guild.rb'
data/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.2.1**
4
+ * Added icon to playable_class return value
5
+ * Temporarily ignoring some rubocop offenses as the recommended alternatives are not suitable
6
+
7
+ **Version 0.2.0**
8
+ * D3/SC2 endpoints
9
+ * Lots of improvements to WoW endpoints
10
+
3
11
  **Version 0.1.0**
4
12
  * Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.1.0)
4
+ blizzard_api (0.2.0)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # API Exception
5
- class ApiException < RuntimeError
6
- attr_reader :code
3
+ module BlizzardApi
4
+ ##
5
+ # API Exception
6
+ class ApiException < RuntimeError
7
+ attr_reader :code
7
8
 
8
- def initialize(msg = '', code = nil)
9
- @code = code
10
- super msg
9
+ def initialize(msg = '', code = nil)
10
+ @code = code
11
+ super msg
12
+ end
11
13
  end
12
14
  end
@@ -159,7 +159,7 @@ module BlizzardApi
159
159
 
160
160
  # Executes the request
161
161
  http.request(request).tap do |response|
162
- raise ApiException.new 'Request failed', response.code unless response.code.to_i == 200
162
+ raise BlizzardApi::ApiException.new 'Request failed', response.code.to_i unless response.code.to_i == 200
163
163
  end
164
164
  end
165
165
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
@@ -60,7 +60,7 @@ module BlizzardApi
60
60
 
61
61
  opts = { ttl: CACHE_DAY, fields: fields.join(',') }.merge(options)
62
62
 
63
- api_request "#{base_url(:community)}/character/#{realm}/#{CGI.escape(character)}", opts
63
+ api_request "#{base_url(:community)}/character/#{realm}/#{URI.encode(character)}", opts
64
64
  end
65
65
 
66
66
  ##
@@ -79,7 +79,7 @@ module BlizzardApi
79
79
  def get_keystone_profile(realm, character, user_token, season = nil, options = {})
80
80
  opts = { ttl: CACHE_HOUR, namespace: "profile-#{region}" }.merge(options)
81
81
  opts[:access_token] = user_token
82
- url = "#{base_url(:profile)}/character/#{realm}/#{CGI.escape(character)}/mythic-keystone-profile"
82
+ url = "#{base_url(:profile)}/character/#{realm}/#{URI.encode(character)}/mythic-keystone-profile"
83
83
  url += "/season/#{season}" unless season.nil?
84
84
  api_request url, opts
85
85
  end
@@ -60,7 +60,7 @@ module BlizzardApi
60
60
 
61
61
  opts = { ttl: CACHE_DAY, fields: fields.join(',') }.merge(options)
62
62
 
63
- api_request "#{base_url(:community)}/guild/#{realm}/#{guild}", opts
63
+ api_request "#{base_url(:community)}/guild/#{realm}/#{URI.encode(guild)}", opts
64
64
  end
65
65
  end
66
66
  end
@@ -43,12 +43,19 @@ module BlizzardApi
43
43
  index_data[:classes].each do |pclass|
44
44
  class_id = %r{playable-class/([0-9]+)}.match(pclass[:key].to_s)[1]
45
45
  class_data = get class_id, options
46
- class_data.delete :_links
47
46
  classes.push class_data
48
47
  end
49
48
  end
50
49
  end
51
50
 
51
+ def get(id, options = {})
52
+ data = api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}", default_options.merge(options)
53
+ data[:icon] = get_class_icon data[:media], options
54
+ data.delete :_links
55
+ data.delete :media
56
+ data
57
+ end
58
+
52
59
  protected
53
60
 
54
61
  def endpoint_setup
@@ -57,6 +64,11 @@ module BlizzardApi
57
64
  @collection = 'classes'
58
65
  @ttl = CACHE_TRIMESTER
59
66
  end
67
+
68
+ def get_class_icon(media_url, options)
69
+ media_data = request media_url[:key][:href], options
70
+ %r{56/([a-z_]+).jpg}.match(media_data[:assets][0][:value].to_s)[1]
71
+ end
60
72
  end
61
73
  end
62
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blizzard_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Schiavo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis