dota2_api27n 1.0.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 +7 -0
- data/lib/dota2_api27n.rb +28 -0
- data/lib/dota2_api27n/client.rb +9 -0
- data/lib/dota2_api27n/models/league.rb +23 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 91b20a82a269629634b4825635e773aeaa155f5b77ec78813ae7ffbf7fa329d0
|
4
|
+
data.tar.gz: 857367a7f7d68d5e5bacc37ed871b54a1bc14e4b760c880090201dae33c61ea8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a542727da32c1399b23aa6f1174adfe9abf55e285b0ab15e0a067d80b25d06963aaf8debb9188de46ec36873a250913babcd99c4cccddc7970c29f6544d098e
|
7
|
+
data.tar.gz: 74771a7ad27fb7cf0bc0e99841925e49236ccbb00f3d3af159766692183ea21831f3ded32d998266cb7f314feb846f2e83c35abc89696ddb20080d9af89394ee
|
data/lib/dota2_api27n.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
require_relative 'dota2_api27n/models/league'
|
5
|
+
require_relative 'dota2_api27n/client'
|
6
|
+
|
7
|
+
module Dota2Api27n
|
8
|
+
|
9
|
+
def self.leagues
|
10
|
+
leagues = request(League::ENDPOINT, League::OPTIONS)
|
11
|
+
|
12
|
+
if leagues.headers['x-ratelimit-remaining'].to_i < 0
|
13
|
+
sleep leagues.headers['x-ratelimit-reset'].to_i
|
14
|
+
leagues = request(League::ENDPOINT, League::OPTIONS)
|
15
|
+
leagues = leagues['results']
|
16
|
+
else
|
17
|
+
leagues = leagues['results']
|
18
|
+
end
|
19
|
+
|
20
|
+
leagues.map { |league| League.new(league) }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.request(method, options = nil)
|
26
|
+
Client.new.get(method, options)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Dota2Api27n
|
2
|
+
class League
|
3
|
+
ENDPOINT = 'leagues'.freeze
|
4
|
+
OPTIONS = '?offset=0&limit=100'.freeze
|
5
|
+
|
6
|
+
attr_reader :league_id, :name, :tier, :region, :url, :description, :start_timestamp,
|
7
|
+
:end_timestamp, :status, :total_prize_pool, :is_live
|
8
|
+
|
9
|
+
def initialize(attributes)
|
10
|
+
@total_prize_pool = attributes['total_prize_pool']
|
11
|
+
@start_timestamp = attributes['start_timestamp']
|
12
|
+
@end_timestamp = attributes['end_timestamp']
|
13
|
+
@description = attributes['description']
|
14
|
+
@league_id = attributes['league_id']
|
15
|
+
@is_live = attributes['is_live']
|
16
|
+
@region = attributes['region']
|
17
|
+
@status = attributes['status']
|
18
|
+
@name = attributes['name']
|
19
|
+
@tier = attributes['tier']
|
20
|
+
@url = attributes['url']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dota2_api27n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleksii Protsenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dota2_api27n.rb
|
20
|
+
- lib/dota2_api27n/client.rb
|
21
|
+
- lib/dota2_api27n/models/league.rb
|
22
|
+
homepage: https://github.com/railkun/dota_leagues_api
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Dota2_Api27n - Simple gem for parse dota leagues
|
45
|
+
test_files: []
|