hots_api 0.1.0 → 0.2.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 +4 -4
- data/README.md +11 -2
- data/lib/hots_api/fetcher.rb +6 -2
- data/lib/hots_api/repositories/replay_repository.rb +5 -5
- data/lib/hots_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3089660b5c9e3dacd7f95292a7f1523e5749be9e
|
4
|
+
data.tar.gz: '0874565a44bd71426c2d8a103e6da9527c9768a5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e2c44230b039fdf25f8b908bc55f06f80cf507f80a1d8c8e367198bd125034f4483a977b0293b70f5492180ef9a57089e1241e99d230cd7d05517aada0a278
|
7
|
+
data.tar.gz: 65f039f8da1c58da15fdd660406f53b958b25e9e4d1c1d5562d98c248d495379324dfd2898a7fb1c15da728a4a5a6bab33e470dfbff163fdaf832e41d589ce05
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/tbuehlmann/hots_api)
|
4
4
|
|
5
|
-
HotsApi is an API client for the Heroes of the Storm replay metadata API [hotsapi.net](
|
5
|
+
HotsApi is an API client for the Heroes of the Storm replay metadata API [hotsapi.net](https://hotsapi.net/). It consumes the API and lets you retrieve information about uploaded replays.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -85,7 +85,16 @@ replays = HotsApi.replays.where(start_date: '2017-09-01 00:00').with_players.to_
|
|
85
85
|
|
86
86
|
#### Pagination
|
87
87
|
|
88
|
-
The API returns a maximum of 100 replays per request. If you want to retrieve
|
88
|
+
The API returns a maximum of 100 replays per request. If you want to retrieve the second page (or the next 100 replays) for a given query:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
first_page = HotsApi.replays
|
92
|
+
second_page = first_page.next_page
|
93
|
+
```
|
94
|
+
|
95
|
+
Internally, this will set the appropriate `min_id` to the query. If there's no next page, calling `next_page` will return `nil`.
|
96
|
+
|
97
|
+
If you want to retrieve all replays for a given query, use `find_each`:
|
89
98
|
|
90
99
|
```ruby
|
91
100
|
HotsApi.replays.where(start_date: '2017-09-01 00:00', end_date: '2017-09-01 23:59').find_each do |replay|
|
data/lib/hots_api/fetcher.rb
CHANGED
@@ -10,13 +10,13 @@ module HotsApi
|
|
10
10
|
|
11
11
|
def get(path, params: {})
|
12
12
|
with_retrying do
|
13
|
-
HTTP.get("
|
13
|
+
HTTP.get("#{base_path}/#{path}", params: params)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def post(path, body: nil, file: nil)
|
18
18
|
with_retrying do
|
19
|
-
HTTP.post("
|
19
|
+
HTTP.post("#{base_path}/#{path}", post_options_for(body: body, file: file))
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -29,6 +29,10 @@ module HotsApi
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def base_path
|
33
|
+
'https://hotsapi.net/api/v1'
|
34
|
+
end
|
35
|
+
|
32
36
|
def with_retrying(tries: 10)
|
33
37
|
tries.times do |try|
|
34
38
|
response = yield
|
@@ -4,22 +4,22 @@ module HotsApi
|
|
4
4
|
module Repositories
|
5
5
|
class ReplayRepository < Repository
|
6
6
|
def upload(file)
|
7
|
-
response = HotsApi.post(
|
7
|
+
response = HotsApi.post(path, file: file)
|
8
8
|
Models::UploadedReplay.new(response.parse)
|
9
9
|
end
|
10
10
|
|
11
11
|
def trigger_hotslogs_upload(fingerprint)
|
12
|
-
HotsApi.get("
|
12
|
+
HotsApi.get("#{path}/fingerprints/v3/#{fingerprint}", params: {uploadToHotslogs: 1}).parse['exists']
|
13
13
|
end
|
14
14
|
|
15
15
|
def fingerprint_uploaded?(fingerprint)
|
16
|
-
HotsApi.get("
|
16
|
+
HotsApi.get("#{path}/fingerprints/v3/#{fingerprint}").parse['exists']
|
17
17
|
end
|
18
18
|
|
19
19
|
def fingerprints_uploaded?(fingerprints)
|
20
20
|
return {} if fingerprints.empty?
|
21
21
|
|
22
|
-
upload_statuses = HotsApi.post(
|
22
|
+
upload_statuses = HotsApi.post("#{path}/fingerprints", body: fingerprints.join("\n")).parse
|
23
23
|
|
24
24
|
{}.tap do |fingerprint_statuses|
|
25
25
|
upload_statuses['exists'].each do |fingerprint|
|
@@ -33,7 +33,7 @@ module HotsApi
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def minimum_supported_build
|
36
|
-
HotsApi.get(
|
36
|
+
HotsApi.get("#{path}/min-build").to_s.to_i
|
37
37
|
end
|
38
38
|
|
39
39
|
def with_players
|
data/lib/hots_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hots_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Bühlmann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|