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 +4 -4
- data/.rubocop_todo.yml +7 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/blizzard_api/exception.rb +9 -7
- data/lib/blizzard_api/request.rb +1 -1
- data/lib/blizzard_api/version.rb +1 -1
- data/lib/blizzard_api/wow/community/character.rb +2 -2
- data/lib/blizzard_api/wow/community/guild.rb +1 -1
- data/lib/blizzard_api/wow/game_data/playable_class.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 986e5045b51505acbdcbe757c1cab63997ae59ccd517ea10f31e53005a6a59d0
|
4
|
+
data.tar.gz: d0cc98867e15d90d40418474e5b3be6e3fdac5dd06b6bb0d065c94d32e879882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module BlizzardApi
|
4
|
+
##
|
5
|
+
# API Exception
|
6
|
+
class ApiException < RuntimeError
|
7
|
+
attr_reader :code
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def initialize(msg = '', code = nil)
|
10
|
+
@code = code
|
11
|
+
super msg
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
data/lib/blizzard_api/request.rb
CHANGED
@@ -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
|
|
data/lib/blizzard_api/version.rb
CHANGED
@@ -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}/#{
|
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}/#{
|
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.
|
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-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|