relic_link 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/lib/relic_link/coh3/api/endpoints/leaderboards/ids.rb +104 -0
- data/lib/relic_link/coh3/api/endpoints/leaderboards/sort.rb +19 -0
- data/lib/relic_link/coh3/api/endpoints/leaderboards.rb +51 -0
- data/lib/relic_link/coh3/api/endpoints/matches.rb +51 -0
- data/lib/relic_link/coh3/api/endpoints/stats.rb +36 -0
- data/lib/relic_link/coh3/api/endpoints.rb +17 -0
- data/lib/relic_link/coh3/client.rb +18 -0
- data/lib/relic_link/coh3/faraday/connection.rb +24 -0
- data/lib/relic_link/coh3/util.rb +18 -0
- data/lib/relic_link/faraday/request.rb +15 -0
- data/lib/relic_link/version.rb +5 -0
- data/lib/relic_link.rb +15 -0
- data/relic_link.gemspec +36 -0
- data/sig/relic_link.rbs +4 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf617099e292af72fd7cca5444c0ed5133db251d8d147697e91d75cf7d8dc0b9
|
4
|
+
data.tar.gz: e9dd839fe8db31538220b633150cac6b226b3bb87f76bc6ab7b0d0d48dfca613
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 663c350662a7ef6b58a737dfae8b0065475b40f09f1b0c09a827e861d77fe1ddac0cce349d7f9ca7cd06e8ff220f3f723be32755b7fb6739612b654808de491a
|
7
|
+
data.tar.gz: b280809d55eb9142913360eaf50b9d4ee6ad3bfa1ba90c785efe1a22254d6ef0004fc4627374af0864e3aaf02912726a1ec0e01b0fa2ab8a1bf308a5520ae62b
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.1
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
relic_link (0.1.0)
|
5
|
+
faraday (~> 2.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
faraday (2.7.4)
|
13
|
+
faraday-net_http (>= 2.0, < 3.1)
|
14
|
+
ruby2_keywords (>= 0.0.4)
|
15
|
+
faraday-net_http (3.0.2)
|
16
|
+
json (2.6.3)
|
17
|
+
parallel (1.22.1)
|
18
|
+
parser (3.2.2.0)
|
19
|
+
ast (~> 2.4.1)
|
20
|
+
rainbow (3.1.1)
|
21
|
+
rake (13.0.6)
|
22
|
+
regexp_parser (2.7.0)
|
23
|
+
rexml (3.2.5)
|
24
|
+
rspec (3.12.0)
|
25
|
+
rspec-core (~> 3.12.0)
|
26
|
+
rspec-expectations (~> 3.12.0)
|
27
|
+
rspec-mocks (~> 3.12.0)
|
28
|
+
rspec-core (3.12.1)
|
29
|
+
rspec-support (~> 3.12.0)
|
30
|
+
rspec-expectations (3.12.2)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-mocks (3.12.5)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.12.0)
|
36
|
+
rspec-support (3.12.0)
|
37
|
+
rubocop (1.48.1)
|
38
|
+
json (~> 2.3)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 3.2.0.0)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.8, < 3.0)
|
43
|
+
rexml (>= 3.2.5, < 4.0)
|
44
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
47
|
+
rubocop-ast (1.28.0)
|
48
|
+
parser (>= 3.2.1.0)
|
49
|
+
ruby-progressbar (1.13.0)
|
50
|
+
ruby2_keywords (0.0.5)
|
51
|
+
unicode-display_width (2.4.2)
|
52
|
+
vcr (6.1.0)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
arm64-darwin-21
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
rake (~> 13.0)
|
59
|
+
relic_link!
|
60
|
+
rspec (~> 3.0)
|
61
|
+
rubocop (~> 1.21)
|
62
|
+
vcr (~> 6.1)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.4.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 ryantaylor
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# RelicLink
|
2
|
+
|
3
|
+
A client wrapper for Relic APIs. Currently supports the Company of Heroes 3 leaderboard, stats, and recent matches API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add to Gemfile:
|
8
|
+
```
|
9
|
+
gem 'relic_link'
|
10
|
+
```
|
11
|
+
Then run `bundle install`.
|
12
|
+
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Currently the only Relic API supported is the Company of Heroes 3 API (PRs are welcome for other games/APIs though, and others may be added based on resourcing and demand).
|
17
|
+
|
18
|
+
In order to make requests to the API, you need to initialize a client:
|
19
|
+
```ruby
|
20
|
+
client = RelicLink::Coh3::Client.new
|
21
|
+
```
|
22
|
+
Then you can make requests to any of the supported CoH3 API endpoints:
|
23
|
+
```ruby
|
24
|
+
client.available_leaderboards
|
25
|
+
client.leaderboard(leaderboard_id: RelicLink::Coh3::Api::Endpoints::Leaderboards::Ids::AMERICAN_1V1)
|
26
|
+
client.recent_match_history(profile_ids: [8230])
|
27
|
+
client.recent_match_history_by_profile_id(8230)
|
28
|
+
client.personal_stats(profile_ids: [8230])
|
29
|
+
```
|
30
|
+
Consult the documentation 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!
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ryantaylor/relic_link.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
module Leaderboards
|
8
|
+
# Various leaderboard IDs provided for convenience. Best effort
|
9
|
+
# will be made to ensure these IDs are accurate and up-to-date,
|
10
|
+
# but it's possible Relic changes them in the future. If you
|
11
|
+
# really want to be sure you have accurate IDs, call
|
12
|
+
# {#available_leaderboards}.
|
13
|
+
module Ids
|
14
|
+
AMERICAN_1V1 = 2130255
|
15
|
+
AMERICAN_1V1_UNRANKED = 2130256
|
16
|
+
AMERICAN_2V2 = 2130300
|
17
|
+
AMERICAN_2V2_UNRANKED = 2130301
|
18
|
+
AMERICAN_2V2_EASY_AI = 2130283
|
19
|
+
AMERICAN_2V2_MEDIUM_AI = 2130296
|
20
|
+
AMERICAN_2V2_HARD_AI = 2130291
|
21
|
+
AMERICAN_2V2_EXPERT_AI = 2130287
|
22
|
+
AMERICAN_3V3 = 2130329
|
23
|
+
AMERICAN_3V3_UNRANKED = 2130330
|
24
|
+
AMERICAN_3V3_EASY_AI = 2130308
|
25
|
+
AMERICAN_3V3_MEDIUM_AI = 2130325
|
26
|
+
AMERICAN_3V3_HARD_AI = 2130320
|
27
|
+
AMERICAN_3V3_EXPERT_AI = 2130313
|
28
|
+
AMERICAN_4V4 = 2130353
|
29
|
+
AMERICAN_4V4_UNRANKED = 2130354
|
30
|
+
AMERICAN_4V4_EASY_AI = 2130337
|
31
|
+
AMERICAN_4V4_MEDIUM_AI = 2130349
|
32
|
+
AMERICAN_4V4_HARD_AI = 2130345
|
33
|
+
AMERICAN_4V4_EXPERT_AI = 2130341
|
34
|
+
|
35
|
+
BRITISH_1V1 = 2130257
|
36
|
+
BRITISH_1V1_UNRANKED = 2130258
|
37
|
+
BRITISH_2V2 = 2130302
|
38
|
+
BRITISH_2V2_UNRANKED = 2130303
|
39
|
+
BRITISH_2V2_EASY_AI = 2130284
|
40
|
+
BRITISH_2V2_MEDIUM_AI = 2130297
|
41
|
+
BRITISH_2V2_HARD_AI = 2130293
|
42
|
+
BRITISH_2V2_EXPERT_AI = 2130288
|
43
|
+
BRITISH_3V3 = 2130331
|
44
|
+
BRITISH_3V3_UNRANKED = 2130332
|
45
|
+
BRITISH_3V3_EASY_AI = 2130309
|
46
|
+
BRITISH_3V3_MEDIUM_AI = 2130326
|
47
|
+
BRITISH_3V3_HARD_AI = 2130321
|
48
|
+
BRITISH_3V3_EXPERT_AI = 2130317
|
49
|
+
BRITISH_4V4 = 2130356
|
50
|
+
BRITISH_4V4_UNRANKED = 2130357
|
51
|
+
BRITISH_4V4_EASY_AI = 2130338
|
52
|
+
BRITISH_4V4_MEDIUM_AI = 2130350
|
53
|
+
BRITISH_4V4_HARD_AI = 2130346
|
54
|
+
BRITISH_4V4_EXPERT_AI = 2130342
|
55
|
+
|
56
|
+
WEHRMACHT_1V1 = 2130261
|
57
|
+
WEHRMACHT_1V1_UNRANKED = 2130262
|
58
|
+
WEHRMACHT_2V2 = 2130306
|
59
|
+
WEHRMACHT_2V2_UNRANKED = 2130307
|
60
|
+
WEHRMACHT_2V2_EASY_AI = 2130286
|
61
|
+
WEHRMACHT_2V2_MEDIUM_AI = 2130299
|
62
|
+
WEHRMACHT_2V2_HARD_AI = 2130295
|
63
|
+
WEHRMACHT_2V2_EXPERT_AI = 2130290
|
64
|
+
WEHRMACHT_3V3 = 2130335
|
65
|
+
WEHRMACHT_3V3_UNRANKED = 2130336
|
66
|
+
WEHRMACHT_3V3_EASY_AI = 2130311
|
67
|
+
WEHRMACHT_3V3_MEDIUM_AI = 2130328
|
68
|
+
WEHRMACHT_3V3_HARD_AI = 2130323
|
69
|
+
WEHRMACHT_3V3_EXPERT_AI = 2130319
|
70
|
+
WEHRMACHT_4V4 = 2130360
|
71
|
+
WEHRMACHT_4V4_UNRANKED = 2130361
|
72
|
+
WEHRMACHT_4V4_EASY_AI = 2130340
|
73
|
+
WEHRMACHT_4V4_MEDIUM_AI = 2130352
|
74
|
+
WEHRMACHT_4V4_HARD_AI = 2130348
|
75
|
+
WEHRMACHT_4V4_EXPERT_AI = 2130344
|
76
|
+
|
77
|
+
DAK_1V1 = 2130259
|
78
|
+
DAK_1V1_UNRANKED = 2130260
|
79
|
+
DAK_2V2 = 2130304
|
80
|
+
DAK_2V2_UNRANKED = 2130305
|
81
|
+
DAK_2V2_EASY_AI = 2130285
|
82
|
+
DAK_2V2_MEDIUM_AI = 2130298
|
83
|
+
DAK_2V2_HARD_AI = 2130294
|
84
|
+
DAK_2V2_EXPERT_AI = 2130289
|
85
|
+
DAK_3V3 = 2130333
|
86
|
+
DAK_3V3_UNRANKED = 2130334
|
87
|
+
DAK_3V3_EASY_AI = 2130310
|
88
|
+
DAK_3V3_MEDIUM_AI = 2130327
|
89
|
+
DAK_3V3_HARD_AI = 2130322
|
90
|
+
DAK_3V3_EXPERT_AI = 2130318
|
91
|
+
DAK_4V4 = 2130358
|
92
|
+
DAK_4V4_UNRANKED = 2130359
|
93
|
+
DAK_4V4_EASY_AI = 2130339
|
94
|
+
DAK_4V4_MEDIUM_AI = 2130351
|
95
|
+
DAK_4V4_HARD_AI = 2130347
|
96
|
+
DAK_4V4_EXPERT_AI = 2130343
|
97
|
+
|
98
|
+
CUSTOM = 2130362
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
module Leaderboards
|
8
|
+
# Sort order options for leaderboard API calls.
|
9
|
+
module Sort
|
10
|
+
# Sort by most wins in descending order.
|
11
|
+
WINS = 0
|
12
|
+
# Sort by highest ELO in descending order.
|
13
|
+
ELO = 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'leaderboards/ids'
|
4
|
+
require_relative 'leaderboards/sort'
|
5
|
+
|
6
|
+
module RelicLink
|
7
|
+
module Coh3
|
8
|
+
module Api
|
9
|
+
module Endpoints
|
10
|
+
# Endpoint definitions for the CoH3 leaderboards API.
|
11
|
+
module Leaderboards
|
12
|
+
# List available leaderboards and associated metadata.
|
13
|
+
def available_leaderboards
|
14
|
+
get('getAvailableLeaderboards')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieve the leaderboard with the given ID. For your convenience
|
18
|
+
# a list of IDs is provided inside {Ids}, or you can retrieve a list
|
19
|
+
# of available IDs using {#available_leaderboards}.
|
20
|
+
#
|
21
|
+
# @option options [Ids, Integer] :leaderboard_id
|
22
|
+
# ID of the leaderboard to be retrieved (required).
|
23
|
+
# @option options [Integer] :start (1)
|
24
|
+
# Leaderboard position to start retrieval from. Passing a value of
|
25
|
+
# 1 will retrieve leaderboard information from the beginning. Must
|
26
|
+
# be an integer between 1 and 2147483647.
|
27
|
+
# @option options [Integer] :count (200)
|
28
|
+
# Number of leaderboard entries to retrieve in the given call.
|
29
|
+
# Must be an integer between 1 and 200.
|
30
|
+
# @option options [Sort] :sort_by (Sort::ELO)
|
31
|
+
# Field to sort the leaderboard entries by.
|
32
|
+
#
|
33
|
+
# @raise [ArgumentError] if the required parameters aren't provided.
|
34
|
+
def leaderboard(options = {})
|
35
|
+
raise ArgumentError, 'Required argument :leaderboard_id missing' if options[:leaderboard_id].nil?
|
36
|
+
|
37
|
+
get('getLeaderboard2', format_sort_key(options))
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def format_sort_key(options)
|
43
|
+
options.transform_keys do |key|
|
44
|
+
key == :sort_by ? :sortBy : key
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
# Endpoint definitions for the CoH3 recent matches API.
|
8
|
+
module Matches
|
9
|
+
# Retrieve the match history information for the given player identifiers.
|
10
|
+
# Note that multiple combinations of identifier types (such as +profile_ids+
|
11
|
+
# and +aliases+ or +aliases+ and +profile_names+) are technically supported
|
12
|
+
# but produce undefined behaviour on Relic's API. Therefore, it is recommended
|
13
|
+
# to choose one identifier type when making requests to this endpoint.
|
14
|
+
#
|
15
|
+
# @option options [Array<Integer>] :profile_ids
|
16
|
+
# Internal Relic IDs of players whose stats you wish to retrieve (one of required).
|
17
|
+
# @option options [Array<String>] :aliases
|
18
|
+
# Steam profile names of players whose stats you wish to retrieve. Names must match
|
19
|
+
# exactly and are case sensitive (one of required).
|
20
|
+
# @option options [Array<Integer>] :profile_names
|
21
|
+
# Specially formatted Steam IDs of players whose stats you wish to retrieve. Must
|
22
|
+
# be in the format +/steam/<ID>+ (one of required).
|
23
|
+
#
|
24
|
+
# @raise [ArgumentError] if none of the required parameters are provided.
|
25
|
+
def recent_match_history(options = {})
|
26
|
+
unless options.keys.intersect?(%i[profile_ids aliases profile_names])
|
27
|
+
raise ArgumentError, 'Missing one of required arguments :profile_ids, :aliases, or :profile_names'
|
28
|
+
end
|
29
|
+
|
30
|
+
get('getRecentMatchHistory', array_params(options))
|
31
|
+
end
|
32
|
+
|
33
|
+
# Retrieve the match history information for the given profile ID. Profile
|
34
|
+
# ID is an internal Relic player identifier that can be pulled from
|
35
|
+
# leaderboard results (such as by calling {Leaderboards#leaderboard})
|
36
|
+
# or match history results (like {#recent_match_history}) using other known
|
37
|
+
# parameters such as +aliases+ or +profile_names+.
|
38
|
+
#
|
39
|
+
# @param profile_id [Integer] Internal Relic ID of player whose stats you wish to retrieve (required).
|
40
|
+
#
|
41
|
+
# @raise [ArgumentError] if no +profile_id+ provided.
|
42
|
+
def recent_match_history_by_profile_id(profile_id)
|
43
|
+
raise ArgumentError, 'Required argument :profile_id missing' if profile_id.nil?
|
44
|
+
|
45
|
+
get('getRecentMatchHistoryByProfileId', { profile_id: })
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
# Endpoint definitions for the CoH3 stats API.
|
8
|
+
module Stats
|
9
|
+
# Retrieve the personal stats for the given player identifiers. Note that
|
10
|
+
# multiple combinations of identifier types (such as +profile_ids+ and
|
11
|
+
# +aliases+ or +aliases+ and +profile_names+) are technically supported but
|
12
|
+
# produce undefined behaviour on Relic's API. Therefore, it is recommended
|
13
|
+
# to choose one identifier type when making requests to this endpoint.
|
14
|
+
#
|
15
|
+
# @option options [Array<Integer>] :profile_ids
|
16
|
+
# Internal Relic IDs of players whose stats you wish to retrieve (one of required).
|
17
|
+
# @option options [Array<String>] :aliases
|
18
|
+
# Steam profile names of players whose stats you wish to retrieve. Names must match
|
19
|
+
# exactly and are case sensitive (one of required).
|
20
|
+
# @option options [Array<Integer>] :profile_names
|
21
|
+
# Specially formatted Steam IDs of players whose stats you wish to retrieve. Must
|
22
|
+
# be in the format +/steam/<ID>+ (one of required).
|
23
|
+
#
|
24
|
+
# @raise [ArgumentError] if none of the required parameters are provided.
|
25
|
+
def personal_stats(options = {})
|
26
|
+
unless options.keys.intersect?(%i[profile_ids aliases profile_names])
|
27
|
+
raise ArgumentError, 'Missing one of required params :profile_ids, :aliases, or :profile_names'
|
28
|
+
end
|
29
|
+
|
30
|
+
get('getPersonalStat', array_params(options))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'endpoints/leaderboards'
|
4
|
+
require_relative 'endpoints/matches'
|
5
|
+
require_relative 'endpoints/stats'
|
6
|
+
|
7
|
+
module RelicLink
|
8
|
+
module Coh3
|
9
|
+
module Api
|
10
|
+
module Endpoints
|
11
|
+
include Leaderboards
|
12
|
+
include Matches
|
13
|
+
include Stats
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
# Main entrypoint for the CoH3 API. Create a new instance of
|
6
|
+
# this class in order to begin querying the CoH3 API.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# client = RelicLink::Coh3::Client.new
|
10
|
+
# client.available_leaderboards
|
11
|
+
class Client
|
12
|
+
include ::RelicLink::Faraday::Request
|
13
|
+
include Faraday::Connection
|
14
|
+
include Api::Endpoints
|
15
|
+
include Util
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
module Faraday
|
6
|
+
# Faraday connection implementation for API requests. You shouldn't
|
7
|
+
# ever have to use this directly.
|
8
|
+
module Connection
|
9
|
+
private
|
10
|
+
|
11
|
+
def connection
|
12
|
+
@connection ||= ::Faraday.new(
|
13
|
+
url: 'https://coh3-api.reliclink.com/community/leaderboard'
|
14
|
+
) do |f|
|
15
|
+
f.params[:title] = 'coh3'
|
16
|
+
|
17
|
+
f.response :logger
|
18
|
+
f.response :json
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Coh3
|
5
|
+
# Miscellaneous utility and helper methods.
|
6
|
+
module Util
|
7
|
+
# Formats the options as JSON (mainly to format arrays correctly
|
8
|
+
# for Relic's API).
|
9
|
+
#
|
10
|
+
# @param options (Hash) Parameters to be added to the query string.
|
11
|
+
def array_params(options)
|
12
|
+
options.transform_values do |value|
|
13
|
+
JSON.generate(Array(value))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelicLink
|
4
|
+
module Faraday
|
5
|
+
# Wrapper for HTTP client +GET+ requests. You should never
|
6
|
+
# have to use this directly.
|
7
|
+
module Request
|
8
|
+
def get(path, options = {})
|
9
|
+
connection.get(path) do |req|
|
10
|
+
req.params = req.params.merge(options)
|
11
|
+
end.body
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/relic_link.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require_relative 'relic_link/coh3/util'
|
7
|
+
require_relative 'relic_link/coh3/api/endpoints'
|
8
|
+
require_relative 'relic_link/faraday/request'
|
9
|
+
require_relative 'relic_link/coh3/faraday/connection'
|
10
|
+
require_relative 'relic_link/coh3/client'
|
11
|
+
require_relative 'relic_link/version'
|
12
|
+
|
13
|
+
# Relic API client wrappers. To query the CoH3 API see {Coh3::Client}.
|
14
|
+
module RelicLink
|
15
|
+
end
|
data/relic_link.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/relic_link/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'relic_link'
|
7
|
+
spec.version = RelicLink::VERSION
|
8
|
+
spec.authors = ['ryantaylor']
|
9
|
+
spec.email = ['2320507+ryantaylor@users.noreply.github.com']
|
10
|
+
|
11
|
+
spec.summary = 'Wrapper for Relic APIs'
|
12
|
+
spec.description = 'Wraps Relic APIs for easy access in Ruby. Current supports CoH3 stats/leaderboards API.'
|
13
|
+
spec.homepage = 'https://github.com/ryantaylor/relic_link'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 3.1.0'
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
spec.add_dependency 'faraday', '~> 2.7'
|
34
|
+
|
35
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
36
|
+
end
|
data/sig/relic_link.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: relic_link
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ryantaylor
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
description: Wraps Relic APIs for easy access in Ruby. Current supports CoH3 stats/leaderboards
|
28
|
+
API.
|
29
|
+
email:
|
30
|
+
- 2320507+ryantaylor@users.noreply.github.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
37
|
+
- ".ruby-version"
|
38
|
+
- CHANGELOG.md
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- lib/relic_link.rb
|
45
|
+
- lib/relic_link/coh3/api/endpoints.rb
|
46
|
+
- lib/relic_link/coh3/api/endpoints/leaderboards.rb
|
47
|
+
- lib/relic_link/coh3/api/endpoints/leaderboards/ids.rb
|
48
|
+
- lib/relic_link/coh3/api/endpoints/leaderboards/sort.rb
|
49
|
+
- lib/relic_link/coh3/api/endpoints/matches.rb
|
50
|
+
- lib/relic_link/coh3/api/endpoints/stats.rb
|
51
|
+
- lib/relic_link/coh3/client.rb
|
52
|
+
- lib/relic_link/coh3/faraday/connection.rb
|
53
|
+
- lib/relic_link/coh3/util.rb
|
54
|
+
- lib/relic_link/faraday/request.rb
|
55
|
+
- lib/relic_link/version.rb
|
56
|
+
- relic_link.gemspec
|
57
|
+
- sig/relic_link.rbs
|
58
|
+
homepage: https://github.com/ryantaylor/relic_link
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata:
|
62
|
+
allowed_push_host: https://rubygems.org
|
63
|
+
homepage_uri: https://github.com/ryantaylor/relic_link
|
64
|
+
source_code_uri: https://github.com/ryantaylor/relic_link
|
65
|
+
rubygems_mfa_required: 'true'
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.1.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.4.12
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Wrapper for Relic APIs
|
85
|
+
test_files: []
|