relic_link 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f946c4d09c17dbdd9522d22cfea4e8ff935cffdca59728b34e398d4e35986ece
4
- data.tar.gz: 75924b2a77be65290e8ff3d312d6ba619b733b4276fe38e178e0c3fb49b224d6
3
+ metadata.gz: 5dd48a69634e2aa875e803418d20d0a0efbe30b967fa79291446011141cad56a
4
+ data.tar.gz: f88e3a85be7b1b8294e0f70eefed82d5e2dbc37e0e4e84f15d3d3dc2a86ee4ac
5
5
  SHA512:
6
- metadata.gz: eea1940ab9da3a557aa941028f4635ff089d4fe8506a1b822e460984b2098076163386019497aca46248182e518f91c767a8f3ccd90f9f328b8fc1f0fc6c123e
7
- data.tar.gz: '0975d7c5e3173c1d876f0bd7e48b86db108635254ed6abe698a3987a65ec8f8b37a4f05ad9eccec53f1b31a06f730c26b36249b47f7081a087e983f15fcd9729'
6
+ metadata.gz: 152d82681993c93f8032dc16cb404569d12a248f0946085d49f4b0d660a21d2fad41d6659a0764128f7d014448ea3c61e41cd970a3cb9ee62be83f4134266154
7
+ data.tar.gz: 2da9d7c64bce6cccbfec9b7db516fdea4214a952e3938d9cd0cd61c1b6abda752c7a247edc94505036fa32a6572ec46afa4ac1bd1f36277407880848e80092f1
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rake
3
3
  - rubocop-rspec
4
4
 
@@ -15,6 +15,9 @@ Metrics/BlockLength:
15
15
  Metrics/MethodLength:
16
16
  Max: 15
17
17
 
18
+ Naming/PredicateMethod:
19
+ Enabled: false
20
+
18
21
  Rake/Desc:
19
22
  Enabled: false
20
23
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.4
1
+ 3.4.5
data/Gemfile CHANGED
@@ -5,12 +5,12 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in relic_link.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.2'
8
+ gem 'rake', '~> 13.4'
9
9
 
10
10
  gem 'rspec', '~> 3.13'
11
11
 
12
- gem 'rubocop', '~> 1.66'
12
+ gem 'rubocop', '~> 1.86'
13
13
  gem 'rubocop-rake'
14
14
  gem 'rubocop-rspec'
15
15
 
16
- gem 'vcr', '~> 6.3'
16
+ gem 'vcr', '~> 6.4'
data/Gemfile.lock CHANGED
@@ -1,87 +1,97 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relic_link (1.2.1)
4
+ relic_link (1.3.0)
5
5
  faraday (~> 2.7)
6
- faraday-mashify (~> 0.1)
6
+ faraday-mashify (>= 0.1, < 2.0)
7
7
  hashie (~> 5.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- ast (2.4.2)
13
- base64 (0.2.0)
14
- diff-lcs (1.5.1)
15
- faraday (2.11.0)
16
- faraday-net_http (>= 2.0, < 3.4)
12
+ ast (2.4.3)
13
+ diff-lcs (1.6.2)
14
+ faraday (2.14.1)
15
+ faraday-net_http (>= 2.0, < 3.5)
16
+ json
17
17
  logger
18
- faraday-mashify (0.1.1)
18
+ faraday-mashify (1.0.2)
19
19
  faraday (~> 2.0)
20
20
  hashie
21
- faraday-net_http (3.3.0)
22
- net-http
23
- hashie (5.0.0)
24
- json (2.7.2)
25
- language_server-protocol (3.17.0.3)
26
- logger (1.6.1)
27
- net-http (0.4.1)
28
- uri
29
- parallel (1.26.3)
30
- parser (3.3.5.0)
21
+ faraday-net_http (3.4.2)
22
+ net-http (~> 0.5)
23
+ hashie (5.1.0)
24
+ logger
25
+ json (2.19.4)
26
+ language_server-protocol (3.17.0.5)
27
+ lint_roller (1.1.0)
28
+ logger (1.7.0)
29
+ net-http (0.9.1)
30
+ uri (>= 0.11.1)
31
+ parallel (1.28.0)
32
+ parser (3.3.11.1)
31
33
  ast (~> 2.4.1)
32
34
  racc
35
+ prism (1.9.0)
33
36
  racc (1.8.1)
34
37
  rainbow (3.1.1)
35
- rake (13.2.1)
36
- regexp_parser (2.9.2)
37
- rspec (3.13.0)
38
+ rake (13.4.2)
39
+ regexp_parser (2.12.0)
40
+ rspec (3.13.2)
38
41
  rspec-core (~> 3.13.0)
39
42
  rspec-expectations (~> 3.13.0)
40
43
  rspec-mocks (~> 3.13.0)
41
- rspec-core (3.13.1)
44
+ rspec-core (3.13.6)
42
45
  rspec-support (~> 3.13.0)
43
- rspec-expectations (3.13.3)
46
+ rspec-expectations (3.13.5)
44
47
  diff-lcs (>= 1.2.0, < 2.0)
45
48
  rspec-support (~> 3.13.0)
46
- rspec-mocks (3.13.1)
49
+ rspec-mocks (3.13.8)
47
50
  diff-lcs (>= 1.2.0, < 2.0)
48
51
  rspec-support (~> 3.13.0)
49
- rspec-support (3.13.1)
50
- rubocop (1.66.1)
52
+ rspec-support (3.13.7)
53
+ rubocop (1.86.1)
51
54
  json (~> 2.3)
52
- language_server-protocol (>= 3.17.0)
53
- parallel (~> 1.10)
55
+ language_server-protocol (~> 3.17.0.2)
56
+ lint_roller (~> 1.1.0)
57
+ parallel (>= 1.10)
54
58
  parser (>= 3.3.0.2)
55
59
  rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 2.4, < 3.0)
57
- rubocop-ast (>= 1.32.2, < 2.0)
60
+ regexp_parser (>= 2.9.3, < 3.0)
61
+ rubocop-ast (>= 1.49.0, < 2.0)
58
62
  ruby-progressbar (~> 1.7)
59
- unicode-display_width (>= 2.4.0, < 3.0)
60
- rubocop-ast (1.32.3)
61
- parser (>= 3.3.1.0)
62
- rubocop-rake (0.6.0)
63
- rubocop (~> 1.0)
64
- rubocop-rspec (3.0.5)
65
- rubocop (~> 1.61)
63
+ unicode-display_width (>= 2.4.0, < 4.0)
64
+ rubocop-ast (1.49.1)
65
+ parser (>= 3.3.7.2)
66
+ prism (~> 1.7)
67
+ rubocop-rake (0.7.1)
68
+ lint_roller (~> 1.1)
69
+ rubocop (>= 1.72.1)
70
+ rubocop-rspec (3.9.0)
71
+ lint_roller (~> 1.1)
72
+ rubocop (~> 1.81)
66
73
  ruby-progressbar (1.13.0)
67
- unicode-display_width (2.5.0)
68
- uri (0.13.1)
69
- vcr (6.3.1)
70
- base64
74
+ unicode-display_width (3.2.0)
75
+ unicode-emoji (~> 4.1)
76
+ unicode-emoji (4.2.0)
77
+ uri (1.1.1)
78
+ vcr (6.4.0)
71
79
 
72
80
  PLATFORMS
73
81
  arm64-darwin-21
74
82
  arm64-darwin-23
83
+ arm64-darwin-24
84
+ arm64-darwin-25
75
85
  x86_64-linux
76
86
 
77
87
  DEPENDENCIES
78
- rake (~> 13.2)
88
+ rake (~> 13.4)
79
89
  relic_link!
80
90
  rspec (~> 3.13)
81
- rubocop (~> 1.66)
91
+ rubocop (~> 1.86)
82
92
  rubocop-rake
83
93
  rubocop-rspec
84
- vcr (~> 6.3)
94
+ vcr (~> 6.4)
85
95
 
86
96
  BUNDLED WITH
87
- 2.5.17
97
+ 4.0.5
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RelicLink
4
+ module Coh3
5
+ module Api
6
+ module Endpoints
7
+ # Endpoint definitions for the internal CoH3 advertisement API.
8
+ module Advertisements
9
+ # Fetch games currently observable by spectators.
10
+ #
11
+ # This is a private internal Relic endpoint that returns games currently open
12
+ # to spectators. Both +data_checksum+ and +app_binary_checksum+ act as
13
+ # version-compatibility filters — only games matching both checksums are returned.
14
+ #
15
+ # @option options [String] :token
16
+ # Valid CoH3 game client authentication token (required)
17
+ # @option options [Integer] :data_checksum
18
+ # Version-specific CRC32 of game data files (required)
19
+ # @option options [Integer] :app_binary_checksum
20
+ # PE build number of the game binary (required)
21
+ # @option options [Integer] :start (0)
22
+ # Zero-based index of the first result to return.
23
+ # @option options [Integer] :count (200)
24
+ # Number of results to return. Must be an integer between 1 and 200.
25
+ #
26
+ # @raise [ArgumentError] if one of the required parameters are not provided.
27
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
28
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
29
+ # @raise [RelicLink::Errors::UnauthorizedError] if the +token+ provided is invalid.
30
+ # @raise [RelicLink::Errors::BadRequestError] if inputs are missing or violate type constraints.
31
+ def find_observable_advertisements(options = {})
32
+ validate_observable_advertisements_options!(options)
33
+ get(advertisements, 'findObservableAdvertisements',
34
+ observable_advertisements_params(options))
35
+ end
36
+
37
+ # Fetch active game lobbies (ranked and custom) for a given match type.
38
+ #
39
+ # @option options [String] :token
40
+ # Valid CoH3 game client authentication token (required)
41
+ # @option options [Integer] :data_checksum
42
+ # Version-specific CRC32 of game data files (required)
43
+ # @option options [Integer] :app_binary_checksum
44
+ # PE build number of the game binary (required)
45
+ # @option options [Integer] :matchtype_id
46
+ # Match type to filter by (required)
47
+ # @option options [Integer] :start (0)
48
+ # Zero-based index of the first result to return.
49
+ # @option options [Integer] :count (200)
50
+ # Number of results to return. Must be an integer between 1 and 200.
51
+ #
52
+ # @raise [ArgumentError] if one of the required parameters are not provided.
53
+ # @raise [RelicLink::Errors::ServerError] if Relic's API is down.
54
+ # @raise [RelicLink::Errors::RateLimitError] if you're rate-limited.
55
+ # @raise [RelicLink::Errors::UnauthorizedError] if the +token+ provided is invalid.
56
+ # @raise [RelicLink::Errors::BadRequestError] if inputs are missing or violate type constraints.
57
+ def find_advertisements(options = {})
58
+ validate_advertisements_options!(options)
59
+ get(advertisements, 'findAdvertisements',
60
+ advertisements_params(options))
61
+ end
62
+
63
+ private
64
+
65
+ def observable_advertisements_params(options)
66
+ base_advertisement_params(options).merge(observerGroupID: -2)
67
+ end
68
+
69
+ def advertisements_params(options)
70
+ base_advertisement_params(options).merge(matchtype_id: options[:matchtype_id])
71
+ end
72
+
73
+ def base_advertisement_params(options) # rubocop:disable Metrics/MethodLength
74
+ {
75
+ connect_id: options[:token],
76
+ sessionID: options[:token],
77
+ appBinaryChecksum: options[:app_binary_checksum],
78
+ dataChecksum: options[:data_checksum],
79
+ modDLLChecksum: 0,
80
+ modDLLFile: 'INVALID',
81
+ modName: 'INVALID',
82
+ modVersion: 'INVALID',
83
+ versionFlags: 0,
84
+ callNum: rand(1..999),
85
+ desc: 0,
86
+ sortOrder: 0,
87
+ start: options.fetch(:start, 0),
88
+ count: options.fetch(:count, 200)
89
+ }
90
+ end
91
+
92
+ def validate_observable_advertisements_options!(options)
93
+ missing = []
94
+ missing << 'token' if options[:token].nil?
95
+ missing << 'data_checksum' if options[:data_checksum].nil?
96
+ missing << 'app_binary_checksum' if options[:app_binary_checksum].nil?
97
+ missing_str = missing.map { |s| ":#{s}" }.join(', ')
98
+
99
+ raise ArgumentError, "Missing required params #{missing_str}" unless missing.empty?
100
+
101
+ true
102
+ end
103
+
104
+ def validate_advertisements_options!(options) # rubocop:disable Metrics/AbcSize
105
+ missing = []
106
+ missing << 'token' if options[:token].nil?
107
+ missing << 'data_checksum' if options[:data_checksum].nil?
108
+ missing << 'app_binary_checksum' if options[:app_binary_checksum].nil?
109
+ missing << 'matchtype_id' if options[:matchtype_id].nil?
110
+ missing_str = missing.map { |s| ":#{s}" }.join(', ')
111
+
112
+ raise ArgumentError, "Missing required params #{missing_str}" unless missing.empty?
113
+
114
+ true
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'endpoints/advertisements'
3
4
  require_relative 'endpoints/leaderboards'
4
5
  require_relative 'endpoints/matches'
5
6
  require_relative 'endpoints/replays'
@@ -9,6 +10,7 @@ module RelicLink
9
10
  module Coh3
10
11
  module Api
11
12
  module Endpoints
13
+ include Advertisements
12
14
  include Leaderboards
13
15
  include Matches
14
16
  include Replays
@@ -43,6 +43,21 @@ module RelicLink
43
43
  f.response :logger, logger if logger
44
44
  end
45
45
  end
46
+
47
+ def advertisements
48
+ @advertisements ||= ::Faraday.new(
49
+ url: 'https://coh3-api.reliclink.com/game/advertisement'
50
+ ) do |f|
51
+ ::Faraday::Mashify::Middleware.mash_class = ResponseMash
52
+
53
+ f.use ::RelicLink::Coh3::Faraday::Response::RaiseHttpError
54
+ f.use ::RelicLink::Coh3::Faraday::Response::RaiseAdvertisementError
55
+ f.response :mashify
56
+ f.response :json
57
+ f.use ::RelicLink::Faraday::Response::WrapError
58
+ f.response :logger, logger if logger
59
+ end
60
+ end
46
61
  end
47
62
  end
48
63
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RelicLink
4
+ module Coh3
5
+ module Faraday
6
+ module Response
7
+ # Middleware to catch CoH3 advertisement API errors and raise them as exceptions.
8
+ class RaiseAdvertisementError < ::Faraday::Middleware
9
+ def on_complete(env)
10
+ return unless env.success?
11
+
12
+ body = env.body
13
+ return unless body
14
+ return if body.first.zero?
15
+
16
+ raise RelicLink::Coh3::Api::Errors::RelicError.new('advertisement API error', env.response)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelicLink
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  end
data/lib/relic_link.rb CHANGED
@@ -12,6 +12,7 @@ require_relative 'relic_link/coh3/api/errors/relic_error'
12
12
  require_relative 'relic_link/coh3/api/error'
13
13
  require_relative 'relic_link/coh3/api/errors'
14
14
  require_relative 'relic_link/coh3/faraday/response/raise_http_error'
15
+ require_relative 'relic_link/coh3/faraday/response/raise_advertisement_error'
15
16
  require_relative 'relic_link/coh3/faraday/response/raise_replay_error'
16
17
  require_relative 'relic_link/coh3/faraday/response/raise_stats_error'
17
18
  require_relative 'relic_link/faraday/response/wrap_error'
data/relic_link.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency 'faraday', '~> 2.7'
34
- spec.add_dependency 'faraday-mashify', '~> 0.1'
34
+ spec.add_dependency 'faraday-mashify', '>= 0.1', '< 2.0'
35
35
  spec.add_dependency 'hashie', '~> 5.0'
36
36
 
37
37
  spec.metadata['rubygems_mfa_required'] = 'true'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relic_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryantaylor
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -28,16 +27,22 @@ dependencies:
28
27
  name: faraday-mashify
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0.1'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
34
36
  type: :runtime
35
37
  prerelease: false
36
38
  version_requirements: !ruby/object:Gem::Requirement
37
39
  requirements:
38
- - - "~>"
40
+ - - ">="
39
41
  - !ruby/object:Gem::Version
40
42
  version: '0.1'
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: hashie
43
48
  requirement: !ruby/object:Gem::Requirement
@@ -71,6 +76,7 @@ files:
71
76
  - Rakefile
72
77
  - lib/relic_link.rb
73
78
  - lib/relic_link/coh3/api/endpoints.rb
79
+ - lib/relic_link/coh3/api/endpoints/advertisements.rb
74
80
  - lib/relic_link/coh3/api/endpoints/leaderboards.rb
75
81
  - lib/relic_link/coh3/api/endpoints/leaderboards/ids.rb
76
82
  - lib/relic_link/coh3/api/endpoints/leaderboards/sort.rb
@@ -83,6 +89,7 @@ files:
83
89
  - lib/relic_link/coh3/client.rb
84
90
  - lib/relic_link/coh3/config.rb
85
91
  - lib/relic_link/coh3/faraday/connection.rb
92
+ - lib/relic_link/coh3/faraday/response/raise_advertisement_error.rb
86
93
  - lib/relic_link/coh3/faraday/response/raise_http_error.rb
87
94
  - lib/relic_link/coh3/faraday/response/raise_replay_error.rb
88
95
  - lib/relic_link/coh3/faraday/response/raise_stats_error.rb
@@ -103,7 +110,6 @@ metadata:
103
110
  homepage_uri: https://github.com/ryantaylor/relic_link
104
111
  source_code_uri: https://github.com/ryantaylor/relic_link
105
112
  rubygems_mfa_required: 'true'
106
- post_install_message:
107
113
  rdoc_options: []
108
114
  require_paths:
109
115
  - lib
@@ -118,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
124
  - !ruby/object:Gem::Version
119
125
  version: '0'
120
126
  requirements: []
121
- rubygems_version: 3.5.10
122
- signing_key:
127
+ rubygems_version: 3.7.2
123
128
  specification_version: 4
124
129
  summary: Wrapper for Relic APIs
125
130
  test_files: []