blizzard_api 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile.lock +6 -2
  5. data/blizzard_api.gemspec +2 -1
  6. data/lib/blizzard_api/configuration.rb +10 -34
  7. data/lib/blizzard_api/diablo/community/act.rb +2 -2
  8. data/lib/blizzard_api/diablo/community/artisan.rb +2 -2
  9. data/lib/blizzard_api/diablo/community/character.rb +2 -2
  10. data/lib/blizzard_api/diablo/community/follower.rb +1 -1
  11. data/lib/blizzard_api/diablo/community/item.rb +1 -1
  12. data/lib/blizzard_api/diablo/community/item_type.rb +2 -2
  13. data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +3 -3
  14. data/lib/blizzard_api/hearthstone/game_data/back.rb +1 -1
  15. data/lib/blizzard_api/hearthstone/game_data/card.rb +2 -2
  16. data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +2 -2
  17. data/lib/blizzard_api/request.rb +5 -4
  18. data/lib/blizzard_api/starcraft/community/ladder.rb +2 -2
  19. data/lib/blizzard_api/starcraft/community/profile.rb +5 -5
  20. data/lib/blizzard_api/starcraft/game_data/league.rb +1 -1
  21. data/lib/blizzard_api/version.rb +1 -1
  22. data/lib/blizzard_api/wow/game_data/achievement.rb +3 -3
  23. data/lib/blizzard_api/wow/game_data/auction.rb +1 -1
  24. data/lib/blizzard_api/wow/game_data/azerite_essence.rb +1 -1
  25. data/lib/blizzard_api/wow/game_data/covenant.rb +5 -5
  26. data/lib/blizzard_api/wow/game_data/creature.rb +6 -6
  27. data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +20 -8
  28. data/lib/blizzard_api/wow/game_data/guild_crest.rb +2 -2
  29. data/lib/blizzard_api/wow/game_data/item.rb +6 -6
  30. data/lib/blizzard_api/wow/game_data/journal.rb +7 -7
  31. data/lib/blizzard_api/wow/game_data/modified_crafting.rb +4 -4
  32. data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +6 -6
  33. data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +1 -1
  34. data/lib/blizzard_api/wow/game_data/mythic_keystone_leaderboard.rb +2 -2
  35. data/lib/blizzard_api/wow/game_data/mythic_raid_leaderboard.rb +1 -1
  36. data/lib/blizzard_api/wow/game_data/pet.rb +4 -4
  37. data/lib/blizzard_api/wow/game_data/playable_class.rb +8 -8
  38. data/lib/blizzard_api/wow/game_data/playable_specialization.rb +8 -8
  39. data/lib/blizzard_api/wow/game_data/profession.rb +4 -4
  40. data/lib/blizzard_api/wow/game_data/pvp_season.rb +3 -3
  41. data/lib/blizzard_api/wow/game_data/pvp_tier.rb +1 -1
  42. data/lib/blizzard_api/wow/game_data/quest.rb +6 -6
  43. data/lib/blizzard_api/wow/game_data/reputation.rb +4 -4
  44. data/lib/blizzard_api/wow/game_data/spell.rb +1 -1
  45. data/lib/blizzard_api/wow/game_data/talent.rb +2 -2
  46. data/lib/blizzard_api/wow/game_data/tech_talent.rb +3 -3
  47. data/lib/blizzard_api/wow/game_data/wow_token.rb +1 -1
  48. data/lib/blizzard_api/wow/profile/character_profile.rb +27 -27
  49. data/lib/blizzard_api/wow/profile/guild.rb +5 -5
  50. data/lib/blizzard_api/wow/profile/profile.rb +5 -5
  51. data/lib/blizzard_api/wow/search/search_request.rb +1 -1
  52. metadata +18 -4
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  # @!macro response
20
20
  def get(connected_realm_id, **options)
21
21
  opts = { ttl: CACHE_HOUR, namespace: :dynamic }.merge(options)
22
- api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions", opts
22
+ api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions", **opts
23
23
  end
24
24
  end
25
25
  end
@@ -21,7 +21,7 @@ module BlizzardApi
21
21
  #
22
22
  # @!macro response
23
23
  def media(id, **options)
24
- api_request "#{base_url(:media)}/azerite-essence/#{id}", default_options.merge(options)
24
+ api_request "#{base_url(:media)}/azerite-essence/#{id}", **default_options.merge(options)
25
25
  end
26
26
 
27
27
  protected
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  #
20
20
  # @!macro response
21
21
  def media(id, **options)
22
- api_request "#{base_url(:media)}/covenant/#{id}", default_options.merge(options)
22
+ api_request "#{base_url(:media)}/covenant/#{id}", **default_options.merge(options)
23
23
  end
24
24
 
25
25
  ##
@@ -29,7 +29,7 @@ module BlizzardApi
29
29
  #
30
30
  # @!macro response
31
31
  def soulbinds(**options)
32
- api_request "#{base_url(:game_data)}/covenant/soulbind/index", default_options.merge(options)
32
+ api_request "#{base_url(:game_data)}/covenant/soulbind/index", **default_options.merge(options)
33
33
  end
34
34
 
35
35
  ##
@@ -41,7 +41,7 @@ module BlizzardApi
41
41
  #
42
42
  # @!macro response
43
43
  def soulbind(id, **options)
44
- api_request "#{base_url(:game_data)}/covenant/soulbind/#{id}", default_options.merge(options)
44
+ api_request "#{base_url(:game_data)}/covenant/soulbind/#{id}", **default_options.merge(options)
45
45
  end
46
46
 
47
47
  ##
@@ -51,7 +51,7 @@ module BlizzardApi
51
51
  #
52
52
  # @!macro response
53
53
  def conduits(**options)
54
- api_request "#{base_url(:game_data)}/covenant/conduit/index", default_options.merge(options)
54
+ api_request "#{base_url(:game_data)}/covenant/conduit/index", **default_options.merge(options)
55
55
  end
56
56
 
57
57
  ##
@@ -63,7 +63,7 @@ module BlizzardApi
63
63
  #
64
64
  # @!macro response
65
65
  def conduit(id, **options)
66
- api_request "#{base_url(:game_data)}/covenant/conduit/#{id}", default_options.merge(options)
66
+ api_request "#{base_url(:game_data)}/covenant/conduit/#{id}", **default_options.merge(options)
67
67
  end
68
68
 
69
69
  protected
@@ -28,7 +28,7 @@ module BlizzardApi
28
28
  #
29
29
  # @!macro response
30
30
  def families(**options)
31
- api_request "#{endpoint_uri('family')}/index", default_options.merge(options)
31
+ api_request "#{endpoint_uri('family')}/index", **default_options.merge(options)
32
32
  end
33
33
 
34
34
  ##
@@ -41,7 +41,7 @@ module BlizzardApi
41
41
  #
42
42
  # @!macro response
43
43
  def family(id, **options)
44
- api_request "#{endpoint_uri('family')}/#{id}", default_options.merge(options)
44
+ api_request "#{endpoint_uri('family')}/#{id}", **default_options.merge(options)
45
45
  end
46
46
 
47
47
  ##
@@ -54,7 +54,7 @@ module BlizzardApi
54
54
  #
55
55
  # @!macro response
56
56
  def family_media(id, **options)
57
- api_request "#{base_url(:media)}/creature-family/#{id}", default_options.merge(options)
57
+ api_request "#{base_url(:media)}/creature-family/#{id}", **default_options.merge(options)
58
58
  end
59
59
 
60
60
  ##
@@ -65,7 +65,7 @@ module BlizzardApi
65
65
  #
66
66
  # @!macro response
67
67
  def types(**options)
68
- api_request "#{endpoint_uri('type')}/index", default_options.merge(options)
68
+ api_request "#{endpoint_uri('type')}/index", **default_options.merge(options)
69
69
  end
70
70
 
71
71
  ##
@@ -78,7 +78,7 @@ module BlizzardApi
78
78
  #
79
79
  # @!macro response
80
80
  def type(id, **options)
81
- api_request "#{endpoint_uri('type')}/#{id}", default_options.merge(options)
81
+ api_request "#{endpoint_uri('type')}/#{id}", **default_options.merge(options)
82
82
  end
83
83
 
84
84
  ##
@@ -91,7 +91,7 @@ module BlizzardApi
91
91
  #
92
92
  # @!macro response
93
93
  def display_media(id, **options)
94
- api_request "#{base_url(:media)}/creature-display/#{id}", default_options.merge(options)
94
+ api_request "#{base_url(:media)}/creature-display/#{id}", **default_options.merge(options)
95
95
  end
96
96
 
97
97
  protected
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'thwait'
4
+
3
5
  module BlizzardApi
4
6
  module Wow
5
7
  ##
@@ -19,7 +21,7 @@ module BlizzardApi
19
21
  # @!macro request_options
20
22
  # @!macro response
21
23
  def index(**options)
22
- api_request "#{endpoint_uri}/index", default_options.merge(options)
24
+ api_request "#{endpoint_uri}/index", **default_options.merge(options)
23
25
  end
24
26
 
25
27
  ##
@@ -30,20 +32,30 @@ module BlizzardApi
30
32
  #
31
33
  # @!macro response
32
34
  def get(id, **options)
33
- api_request "#{endpoint_uri}/#{id}", default_options.merge(options)
35
+ api_request "#{endpoint_uri}/#{id}", **default_options.merge(options)
34
36
  end
35
37
 
36
38
  ##
37
39
  # @!macro complete
38
40
  def complete(**options)
39
- [].tap do |complete_data|
40
- index_data = index options
41
- index_data[@collection.to_sym].each do |item|
42
- link = item.key?(:key) ? item[:key][:href] : item[:href]
43
- item_data = request link
44
- complete_data.push item_data
41
+ payload = [].tap do |complete_data|
42
+ index_data = index(**options)
43
+ threads = []
44
+
45
+ concurrency = options.key?(:concurrency) ? options[:concurrency].to_i : BlizzardApi.concurrency
46
+ concurrency.times do
47
+ threads << Thread.new do
48
+ while index_data[@collection.to_sym].size.positive?
49
+ item = index_data[@collection.to_sym].pop
50
+ link = item.key?(:key) ? item[:key][:href] : item[:href]
51
+ item_data = request link
52
+ complete_data.push item_data
53
+ end
54
+ end
45
55
  end
56
+ ThreadsWait.all_waits threads
46
57
  end
58
+ payload.sort { |a, b| a[:id] <=> b[:id] }
47
59
  end
48
60
 
49
61
  protected
@@ -24,7 +24,7 @@ module BlizzardApi
24
24
  #
25
25
  # @!macro response
26
26
  def border_media(id, **options)
27
- api_request "#{base_url(:media)}/#{@endpoint}/border/#{id}", default_options.merge(options)
27
+ api_request "#{base_url(:media)}/#{@endpoint}/border/#{id}", **default_options.merge(options)
28
28
  end
29
29
 
30
30
  ##
@@ -37,7 +37,7 @@ module BlizzardApi
37
37
  #
38
38
  # @!macro response
39
39
  def emblem_media(id, **options)
40
- api_request "#{base_url(:media)}/#{@endpoint}/emblem/#{id}", default_options.merge(options)
40
+ api_request "#{base_url(:media)}/#{@endpoint}/emblem/#{id}", **default_options.merge(options)
41
41
  end
42
42
 
43
43
  protected
@@ -36,7 +36,7 @@ module BlizzardApi
36
36
  #
37
37
  # @!macro response
38
38
  def classes(**options)
39
- api_request "#{endpoint_uri('class')}/index", default_options.merge(options)
39
+ api_request "#{endpoint_uri('class')}/index", **default_options.merge(options)
40
40
  end
41
41
 
42
42
  ##
@@ -48,7 +48,7 @@ module BlizzardApi
48
48
  #
49
49
  # @!macro response
50
50
  def class(id, **options)
51
- api_request "#{endpoint_uri('class')}/#{id}", default_options.merge(options)
51
+ api_request "#{endpoint_uri('class')}/#{id}", **default_options.merge(options)
52
52
  end
53
53
 
54
54
  ##
@@ -61,7 +61,7 @@ module BlizzardApi
61
61
  #
62
62
  # @!macro response
63
63
  def subclass(id, subclass_id, **options)
64
- api_request "#{endpoint_uri('class')}/#{id}/item-subclass/#{subclass_id}", default_options.merge(options)
64
+ api_request "#{endpoint_uri('class')}/#{id}/item-subclass/#{subclass_id}", **default_options.merge(options)
65
65
  end
66
66
 
67
67
  ##
@@ -74,7 +74,7 @@ module BlizzardApi
74
74
  #
75
75
  # @!macro response
76
76
  def media(id, **options)
77
- api_request "#{base_url(:media)}/item/#{id}", default_options.merge(options)
77
+ api_request "#{base_url(:media)}/item/#{id}", **default_options.merge(options)
78
78
  end
79
79
 
80
80
  ##
@@ -84,7 +84,7 @@ module BlizzardApi
84
84
  #
85
85
  # @!macro response
86
86
  def sets(**options)
87
- api_request "#{endpoint_uri('set')}/index", default_options.merge(options)
87
+ api_request "#{endpoint_uri('set')}/index", **default_options.merge(options)
88
88
  end
89
89
 
90
90
  ##
@@ -95,7 +95,7 @@ module BlizzardApi
95
95
  #
96
96
  # @!macro response
97
97
  def set(id, **options)
98
- api_request "#{endpoint_uri('set')}/#{id}", default_options.merge(options)
98
+ api_request "#{endpoint_uri('set')}/#{id}", **default_options.merge(options)
99
99
  end
100
100
 
101
101
  protected
@@ -41,7 +41,7 @@ module BlizzardApi
41
41
  #
42
42
  # @!macro response
43
43
  def expansions(**options)
44
- api_request "#{endpoint_uri('expansion')}/index", default_options.merge(options)
44
+ api_request "#{endpoint_uri('expansion')}/index", **default_options.merge(options)
45
45
  end
46
46
 
47
47
  ##
@@ -52,7 +52,7 @@ module BlizzardApi
52
52
  #
53
53
  # @!macro response
54
54
  def expansion(id, **options)
55
- api_request "#{endpoint_uri('expansion')}/#{id}", default_options.merge(options)
55
+ api_request "#{endpoint_uri('expansion')}/#{id}", **default_options.merge(options)
56
56
  end
57
57
 
58
58
  ##
@@ -62,7 +62,7 @@ module BlizzardApi
62
62
  #
63
63
  # @!macro response
64
64
  def instances(**options)
65
- api_request "#{endpoint_uri('instance')}/index", default_options.merge(options)
65
+ api_request "#{endpoint_uri('instance')}/index", **default_options.merge(options)
66
66
  end
67
67
 
68
68
  ##
@@ -73,7 +73,7 @@ module BlizzardApi
73
73
  #
74
74
  # @!macro response
75
75
  def instance(id, **options)
76
- api_request "#{endpoint_uri('instance')}/#{id}", default_options.merge(options)
76
+ api_request "#{endpoint_uri('instance')}/#{id}", **default_options.merge(options)
77
77
  end
78
78
 
79
79
  ##
@@ -83,7 +83,7 @@ module BlizzardApi
83
83
  #
84
84
  # @!macro response
85
85
  def encounters(**options)
86
- api_request "#{endpoint_uri('encounter')}/index", default_options.merge(options)
86
+ api_request "#{endpoint_uri('encounter')}/index", **default_options.merge(options)
87
87
  end
88
88
 
89
89
  ##
@@ -94,7 +94,7 @@ module BlizzardApi
94
94
  #
95
95
  # @!macro response
96
96
  def encounter(id, **options)
97
- api_request "#{endpoint_uri('encounter')}/#{id}", default_options.merge(options)
97
+ api_request "#{endpoint_uri('encounter')}/#{id}", **default_options.merge(options)
98
98
  end
99
99
 
100
100
  ##
@@ -109,7 +109,7 @@ module BlizzardApi
109
109
  search_options = SearchComposer.new(page, page_size)
110
110
  yield search_options if block_given?
111
111
 
112
- api_request "#{endpoint_uri('encounter', :search)}?#{search_options.to_search_query}", default_options.merge(options)
112
+ api_request "#{endpoint_uri('encounter', :search)}?#{search_options.to_search_query}", **default_options.merge(options)
113
113
  end
114
114
 
115
115
  protected
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  #
20
20
  # @!macro request_options
21
21
  def categories(**options)
22
- api_request "#{base_url(:game_data)}/modified-crafting/category/index", default_options.merge(options)
22
+ api_request "#{base_url(:game_data)}/modified-crafting/category/index", **default_options.merge(options)
23
23
  end
24
24
 
25
25
  ##
@@ -31,7 +31,7 @@ module BlizzardApi
31
31
  #
32
32
  # @!macro response
33
33
  def category(id, **options)
34
- api_request "#{base_url(:game_data)}/modified-crafting/category/#{id}", default_options.merge(options)
34
+ api_request "#{base_url(:game_data)}/modified-crafting/category/#{id}", **default_options.merge(options)
35
35
  end
36
36
 
37
37
  ##
@@ -39,7 +39,7 @@ module BlizzardApi
39
39
  #
40
40
  # @!macro request_options
41
41
  def slot_types(**options)
42
- api_request "#{base_url(:game_data)}/modified-crafting/reagent-slot-type/index", default_options.merge(options)
42
+ api_request "#{base_url(:game_data)}/modified-crafting/reagent-slot-type/index", **default_options.merge(options)
43
43
  end
44
44
 
45
45
  ##
@@ -51,7 +51,7 @@ module BlizzardApi
51
51
  #
52
52
  # @!macro response
53
53
  def slot_type(id, **options)
54
- api_request "#{base_url(:game_data)}/modified-crafting/reagent-slot-type/#{id}", default_options.merge(options)
54
+ api_request "#{base_url(:game_data)}/modified-crafting/reagent-slot-type/#{id}", **default_options.merge(options)
55
55
  end
56
56
 
57
57
  protected
@@ -25,7 +25,7 @@ module BlizzardApi
25
25
  #
26
26
  # @!macro response
27
27
  def dungeons(**options)
28
- api_request "#{endpoint_uri}/dungeon/index", default_options.merge(options)
28
+ api_request "#{endpoint_uri}/dungeon/index", **default_options.merge(options)
29
29
  end
30
30
 
31
31
  ##
@@ -37,7 +37,7 @@ module BlizzardApi
37
37
  #
38
38
  # @!macro response
39
39
  def dungeon(id, **options)
40
- api_request "#{endpoint_uri}/dungeon/#{id}", default_options.merge(options)
40
+ api_request "#{endpoint_uri}/dungeon/#{id}", **default_options.merge(options)
41
41
  end
42
42
 
43
43
  ##
@@ -47,7 +47,7 @@ module BlizzardApi
47
47
  #
48
48
  # @!macro response
49
49
  def periods(**options)
50
- api_request "#{endpoint_uri}/period/index", default_options.merge(options)
50
+ api_request "#{endpoint_uri}/period/index", **default_options.merge(options)
51
51
  end
52
52
 
53
53
  ##
@@ -59,7 +59,7 @@ module BlizzardApi
59
59
  #
60
60
  # @!macro response
61
61
  def period(id, **options)
62
- api_request "#{endpoint_uri}/period/#{id}", default_options.merge(options)
62
+ api_request "#{endpoint_uri}/period/#{id}", **default_options.merge(options)
63
63
  end
64
64
 
65
65
  ##
@@ -69,7 +69,7 @@ module BlizzardApi
69
69
  #
70
70
  # @!macro response
71
71
  def seasons(**options)
72
- api_request "#{endpoint_uri}/season/index", default_options.merge(options)
72
+ api_request "#{endpoint_uri}/season/index", **default_options.merge(options)
73
73
  end
74
74
 
75
75
  ##
@@ -81,7 +81,7 @@ module BlizzardApi
81
81
  #
82
82
  # @!macro response
83
83
  def season(id, **options)
84
- api_request "#{endpoint_uri}/season/#{id}", default_options.merge(options)
84
+ api_request "#{endpoint_uri}/season/#{id}", **default_options.merge(options)
85
85
  end
86
86
 
87
87
  protected
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  #
20
20
  # @!macro response
21
21
  def media(id, **options)
22
- api_request "#{base_url(:media)}/keystone-affix/#{id}", default_options.merge(options)
22
+ api_request "#{base_url(:media)}/keystone-affix/#{id}", **default_options.merge(options)
23
23
  end
24
24
 
25
25
  protected
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  #
20
20
  # @!macro response
21
21
  def index(connected_realm_id, **options)
22
- api_request "#{endpoint_uri(connected_realm_id)}/index", default_options(options)
22
+ api_request "#{endpoint_uri(connected_realm_id)}/index", **default_options(options)
23
23
  end
24
24
 
25
25
  ##
@@ -31,7 +31,7 @@ module BlizzardApi
31
31
  #
32
32
  # @!macro response
33
33
  def get(connected_realm_id, dungeon_id, period, **options)
34
- api_request "#{endpoint_uri(connected_realm_id)}/#{dungeon_id}/period/#{period}", default_options(options)
34
+ api_request "#{endpoint_uri(connected_realm_id)}/#{dungeon_id}/period/#{period}", **default_options(options)
35
35
  end
36
36
 
37
37
  private
@@ -21,7 +21,7 @@ module BlizzardApi
21
21
  # @!macro response
22
22
  def get(raid, faction, **options)
23
23
  opts = options.merge(namespace: :dynamic, ttl: CACHE_DAY)
24
- api_request "#{base_url(:game_data)}/leaderboard/hall-of-fame/#{raid}/#{faction}", opts
24
+ api_request "#{base_url(:game_data)}/leaderboard/hall-of-fame/#{raid}/#{faction}", **opts
25
25
  end
26
26
  end
27
27
  end
@@ -19,7 +19,7 @@ module BlizzardApi
19
19
  #
20
20
  # @!macro response
21
21
  def media(id, **options)
22
- api_request "#{base_url(:media)}/pet/#{id}", default_options.merge(options)
22
+ api_request "#{base_url(:media)}/pet/#{id}", **default_options.merge(options)
23
23
  end
24
24
 
25
25
  ##
@@ -29,7 +29,7 @@ module BlizzardApi
29
29
  #
30
30
  # @!macro response
31
31
  def abilities(**options)
32
- api_request "#{endpoint_uri('ability')}/index", default_options.merge(options)
32
+ api_request "#{endpoint_uri('ability')}/index", **default_options.merge(options)
33
33
  end
34
34
 
35
35
  ##
@@ -41,7 +41,7 @@ module BlizzardApi
41
41
  #
42
42
  # @!macro response
43
43
  def ability(id, **options)
44
- api_request "#{endpoint_uri('ability')}/#{id}", default_options.merge(options)
44
+ api_request "#{endpoint_uri('ability')}/#{id}", **default_options.merge(options)
45
45
  end
46
46
 
47
47
  ##
@@ -53,7 +53,7 @@ module BlizzardApi
53
53
  #
54
54
  # @!macro response
55
55
  def ability_media(id, **options)
56
- api_request "#{base_url(:media)}/pet-ability/#{id}", default_options.merge(options)
56
+ api_request "#{base_url(:media)}/pet-ability/#{id}", **default_options.merge(options)
57
57
  end
58
58
 
59
59
  protected