relic_link 1.0.0 → 1.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
  SHA256:
3
- metadata.gz: 91f52523becf51e404509246fefdcdbd84a86113924a1e8d0c9d82a1c29b0930
4
- data.tar.gz: 914a001a68c62e4ddea565bc2591c09ffe3ce71de99461f079a56c91e6891dae
3
+ metadata.gz: b0a6925bd59c93badd256bc6e31c23cf2ecd58827b93b604f2ce4fd954924ee5
4
+ data.tar.gz: 68e0f9f49e38f2c5d7b6e870684828c21bc88e9d4ecd56c4a7d6245e94462d43
5
5
  SHA512:
6
- metadata.gz: fcb580a08a348b9332adfd000c3621f7c91553f066618e0ae0f6e2ddafec2d9be22dfd61e2cbac35a4464891bd5cf92ea2df5f0194413c1065b5623e6cf6bf1a
7
- data.tar.gz: 6641c8b30587fb37118a3201a8e3dca50ebd112f96280774f74ad9749ec2e350e6cd4ffc342be75608c025a2fa5ee87f8a76aafec9f88973052361ff68ce54c8
6
+ metadata.gz: 9b6b44e95aab707016e1825eecd7f952f63bdceb299b5622fa6d61b27e8930b7559066eab6fd35f83aa4be2131713bab4c17097cb86f46abe878d7bba3228480
7
+ data.tar.gz: cf4eec64ecffecffb3e4d0e313c5fc0f6c66d5135103be65ddffa4c8251c9d960afbaa706c945290e5c6ce160eaeb18f39a2e4d5055db212906ce8811d1a1e08
data/.rubocop.yml CHANGED
@@ -2,6 +2,9 @@ AllCops:
2
2
  TargetRubyVersion: 3.1
3
3
  NewCops: enable
4
4
 
5
+ Layout/AccessModifierIndentation:
6
+ EnforcedStyle: outdent
7
+
5
8
  Metrics/BlockLength:
6
9
  Enabled: false
7
10
 
data/Gemfile CHANGED
@@ -5,10 +5,10 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in relic_link.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
8
+ gem 'rake', '~> 13.1'
9
9
 
10
- gem 'rspec', '~> 3.0'
10
+ gem 'rspec', '~> 3.13'
11
11
 
12
- gem 'rubocop', '~> 1.52'
12
+ gem 'rubocop', '~> 1.61'
13
13
 
14
- gem 'vcr', '~> 6.1'
14
+ gem 'vcr', '~> 6.2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relic_link (0.1.2)
4
+ relic_link (1.1.0)
5
5
  faraday (~> 2.7)
6
6
  faraday-mashify (~> 0.1)
7
7
  hashie (~> 5.0)
@@ -10,65 +10,69 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ast (2.4.2)
13
- diff-lcs (1.5.0)
14
- faraday (2.7.6)
15
- faraday-net_http (>= 2.0, < 3.1)
16
- ruby2_keywords (>= 0.0.4)
13
+ diff-lcs (1.5.1)
14
+ faraday (2.9.0)
15
+ faraday-net_http (>= 2.0, < 3.2)
17
16
  faraday-mashify (0.1.1)
18
17
  faraday (~> 2.0)
19
18
  hashie
20
- faraday-net_http (3.0.2)
19
+ faraday-net_http (3.1.0)
20
+ net-http
21
21
  hashie (5.0.0)
22
- json (2.6.3)
23
- parallel (1.23.0)
24
- parser (3.2.2.3)
22
+ json (2.7.1)
23
+ language_server-protocol (3.17.0.3)
24
+ net-http (0.4.1)
25
+ uri
26
+ parallel (1.24.0)
27
+ parser (3.3.0.5)
25
28
  ast (~> 2.4.1)
26
29
  racc
27
- racc (1.7.0)
30
+ racc (1.7.3)
28
31
  rainbow (3.1.1)
29
- rake (13.0.6)
30
- regexp_parser (2.8.0)
31
- rexml (3.2.5)
32
- rspec (3.12.0)
33
- rspec-core (~> 3.12.0)
34
- rspec-expectations (~> 3.12.0)
35
- rspec-mocks (~> 3.12.0)
36
- rspec-core (3.12.2)
37
- rspec-support (~> 3.12.0)
38
- rspec-expectations (3.12.3)
32
+ rake (13.1.0)
33
+ regexp_parser (2.9.0)
34
+ rexml (3.2.6)
35
+ rspec (3.13.0)
36
+ rspec-core (~> 3.13.0)
37
+ rspec-expectations (~> 3.13.0)
38
+ rspec-mocks (~> 3.13.0)
39
+ rspec-core (3.13.0)
40
+ rspec-support (~> 3.13.0)
41
+ rspec-expectations (3.13.0)
39
42
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.12.0)
41
- rspec-mocks (3.12.5)
43
+ rspec-support (~> 3.13.0)
44
+ rspec-mocks (3.13.0)
42
45
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.12.0)
44
- rspec-support (3.12.0)
45
- rubocop (1.52.0)
46
+ rspec-support (~> 3.13.0)
47
+ rspec-support (3.13.1)
48
+ rubocop (1.61.0)
46
49
  json (~> 2.3)
50
+ language_server-protocol (>= 3.17.0)
47
51
  parallel (~> 1.10)
48
- parser (>= 3.2.0.0)
52
+ parser (>= 3.3.0.2)
49
53
  rainbow (>= 2.2.2, < 4.0)
50
54
  regexp_parser (>= 1.8, < 3.0)
51
55
  rexml (>= 3.2.5, < 4.0)
52
- rubocop-ast (>= 1.28.0, < 2.0)
56
+ rubocop-ast (>= 1.30.0, < 2.0)
53
57
  ruby-progressbar (~> 1.7)
54
58
  unicode-display_width (>= 2.4.0, < 3.0)
55
- rubocop-ast (1.29.0)
56
- parser (>= 3.2.1.0)
59
+ rubocop-ast (1.31.1)
60
+ parser (>= 3.3.0.4)
57
61
  ruby-progressbar (1.13.0)
58
- ruby2_keywords (0.0.5)
59
- unicode-display_width (2.4.2)
60
- vcr (6.1.0)
62
+ unicode-display_width (2.5.0)
63
+ uri (0.13.0)
64
+ vcr (6.2.0)
61
65
 
62
66
  PLATFORMS
63
67
  arm64-darwin-21
64
68
  x86_64-linux
65
69
 
66
70
  DEPENDENCIES
67
- rake (~> 13.0)
71
+ rake (~> 13.1)
68
72
  relic_link!
69
- rspec (~> 3.0)
70
- rubocop (~> 1.52)
71
- vcr (~> 6.1)
73
+ rspec (~> 3.13)
74
+ rubocop (~> 1.61)
75
+ vcr (~> 6.2)
72
76
 
73
77
  BUNDLED WITH
74
78
  2.4.7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RelicLink
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/relic_link.svg)](https://badge.fury.io/rb/relic_link) [![Documentation](https://img.shields.io/badge/View-Documentation-blue.svg)](https://rubydoc.info/github/ryantaylor/relic_link/v1.0.0)
3
+ [![Gem Version](https://badge.fury.io/rb/relic_link.svg)](https://badge.fury.io/rb/relic_link) [![Documentation](https://img.shields.io/badge/View-Documentation-blue.svg)](https://rubydoc.info/github/ryantaylor/relic_link/v1.1.0)
4
4
 
5
5
  A client wrapper for Relic APIs. Currently supports the Company of Heroes 3 leaderboard, stats, and recent matches API.
6
6
 
@@ -29,7 +29,7 @@ client.recent_match_history(profile_ids: [8230])
29
29
  client.recent_match_history_by_profile_id(8230)
30
30
  client.personal_stats(profile_ids: [8230])
31
31
  ```
32
- Consult the [documentation](https://rubydoc.info/github/ryantaylor/relic_link/v1.0.0) for all endpoints that have been discovered and are currently queryable. Note that Relic does not publish official documentation for their endpoints, so the functionality here is based on best estimates and is subject to change without warning. Please open an issue if you are aware of endpoints that are not exposed in this library!
32
+ Consult the [documentation](https://rubydoc.info/github/ryantaylor/relic_link/v1.1.0) for all endpoints that have been discovered and are currently queryable. Note that Relic does not publish official documentation for their endpoints, so the functionality here is based on best estimates and is subject to change without warning. Please open an issue if you are aware of endpoints that are not exposed in this library!
33
33
 
34
34
  ## Contributing
35
35
 
@@ -10,6 +10,9 @@ module RelicLink
10
10
  # Endpoint definitions for the CoH3 leaderboards API.
11
11
  module Leaderboards
12
12
  # List available leaderboards and associated metadata.
13
+ #
14
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
15
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
13
16
  def available_leaderboards
14
17
  get('getAvailableLeaderboards')
15
18
  end
@@ -31,13 +34,18 @@ module RelicLink
31
34
  # Field to sort the leaderboard entries by.
32
35
  #
33
36
  # @raise [ArgumentError] if the required parameters aren't provided.
37
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
38
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
39
+ # @raise [Errors::NotFound] if +leaderboard_id+ does not correspond to a leaderboard.
40
+ # @raise [RelicLink::Errors::BadRequestError] if +start+, +count+, or +sort_by+ are outside the
41
+ # limits enumerated above.
34
42
  def leaderboard(options = {})
35
43
  raise ArgumentError, 'Required argument :leaderboard_id missing' if options[:leaderboard_id].nil?
36
44
 
37
45
  get('getLeaderboard2', format_sort_key(options))
38
46
  end
39
47
 
40
- private
48
+ private
41
49
 
42
50
  def format_sort_key(options)
43
51
  options.transform_keys do |key|
@@ -22,6 +22,12 @@ module RelicLink
22
22
  # be in the format +/steam/<ID>+ (one of required).
23
23
  #
24
24
  # @raise [ArgumentError] if none of the required parameters are provided.
25
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
26
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
27
+ # @raise [Errors::UnknownProfileIds] if no values in +profile_ids+ match known profile IDs.
28
+ # @raise [Errors::UnknownAliases] if no values in +aliases+ match known aliases.
29
+ # @raise [Errors::UnregisteredProfileName] if no values in +profile_names+ match known profile names.
30
+ # @raise [RelicLink::Errors::BadRequestError] if inputs violate type constraints.
25
31
  def recent_match_history(options = {})
26
32
  unless options.keys.intersect?(%i[profile_ids aliases profile_names])
27
33
  raise ArgumentError, 'Missing one of required arguments :profile_ids, :aliases, or :profile_names'
@@ -39,6 +45,9 @@ module RelicLink
39
45
  # @param profile_id [Integer] Internal Relic ID of player whose stats you wish to retrieve (required).
40
46
  #
41
47
  # @raise [ArgumentError] if no +profile_id+ provided.
48
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
49
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
50
+ # @raise [RelicLink::Errors::BadRequestError] if input violates type constraints.
42
51
  def recent_match_history_by_profile_id(profile_id)
43
52
  raise ArgumentError, 'Required argument :profile_id missing' if profile_id.nil?
44
53
 
@@ -22,6 +22,12 @@ module RelicLink
22
22
  # be in the format +/steam/<ID>+ (one of required).
23
23
  #
24
24
  # @raise [ArgumentError] if none of the required parameters are provided.
25
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
26
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
27
+ # @raise [Errors::UnknownProfileIds] if no values in +profile_ids+ match known profile IDs.
28
+ # @raise [Errors::UnknownAliases] if no values in +aliases+ match known aliases.
29
+ # @raise [Errors::UnregisteredProfileName] if no values in +profile_names+ match known profile names.
30
+ # @raise [RelicLink::Errors::BadRequestError] if inputs violate type constraints.
25
31
  def personal_stats(options = {})
26
32
  unless options.keys.intersect?(%i[profile_ids aliases profile_names])
27
33
  raise ArgumentError, 'Missing one of required params :profile_ids, :aliases, or :profile_names'
@@ -9,7 +9,7 @@ module RelicLink
9
9
  attr_reader :response
10
10
 
11
11
  def initialize(message, response = nil)
12
- super message
12
+ super(message)
13
13
  @response = response
14
14
  end
15
15
 
@@ -8,7 +8,7 @@ module RelicLink
8
8
  # Faraday connection implementation for API requests. You shouldn't
9
9
  # ever have to use this directly.
10
10
  module Connection
11
- private
11
+ private
12
12
 
13
13
  def connection
14
14
  @connection ||= ::Faraday.new(
@@ -8,6 +8,7 @@ module RelicLink
8
8
  class RaiseError < ::Faraday::Middleware
9
9
  def on_complete(env)
10
10
  raise RelicLink::Errors::BadRequestError, env.response if env.status == 400
11
+ raise RelicLink::Errors::RateLimitError, env.response if env.status == 429
11
12
 
12
13
  return unless env.success?
13
14
 
@@ -16,6 +17,12 @@ module RelicLink
16
17
 
17
18
  return if body['result']['code'].zero?
18
19
 
20
+ raise_relic_error!(body, env)
21
+ end
22
+
23
+ private
24
+
25
+ def raise_relic_error!(body, env)
19
26
  error_message = body['result']['message']
20
27
  error_class = RelicLink::Coh3::Api::Errors::ERROR_CLASSES[error_message]
21
28
  error_class ||= RelicLink::Coh3::Api::Errors::RelicError
@@ -8,7 +8,7 @@ module RelicLink
8
8
 
9
9
  def initialize(message, response)
10
10
  @response = response
11
- super message
11
+ super(message)
12
12
  end
13
13
  end
14
14
 
@@ -29,6 +29,13 @@ module RelicLink
29
29
  end
30
30
  end
31
31
 
32
+ # Raised when a 429 is returned in an API response.
33
+ class RateLimitError < HttpRequestError
34
+ def initialize(response)
35
+ super('rate_limited', response)
36
+ end
37
+ end
38
+
32
39
  # Raised when an API request times out.
33
40
  class TimeoutError < HttpRequestError
34
41
  def initialize(response)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelicLink
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relic_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryantaylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-11 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday