battlerite 0.0.1
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/battlerite.rb +64 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f7a82859d01beb9daa5fbfd2c478a4b7bf11344
|
4
|
+
data.tar.gz: 4266d52717767b3086612419abb3bf16102d2f45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93d9122789fab95b2dc14fbc3e14cffd8865a767a78d4dbae1a0a85c41212adde3ba6882b6735c492816cc662e8428c13e574f7db81370c64669c65174dde001
|
7
|
+
data.tar.gz: e2265be74aab8ffb4ea1e35f6f95e88b084c50a25dd981d5189a2b1311aacda229d147cb8757bce10fd6256f6cd97ab06bc502e344262546ff27e8bd55724a70
|
data/lib/battlerite.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
|
+
require "pry"
|
4
|
+
|
5
|
+
|
6
|
+
class Battlerite
|
7
|
+
|
8
|
+
def uris
|
9
|
+
@uris ||= {
|
10
|
+
matches: "https://api.dc01.gamelockerapp.com/shards/global/matches",
|
11
|
+
match: "https://api.dc01.gamelockerapp.com/shards/global/matches/:match_id",
|
12
|
+
players: "https://api.dc01.gamelockerapp.com/shards/global/players",
|
13
|
+
player: "https://api.dc01.gamelockerapp.com/shards/na/players/:player_id",
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_matches opt={}
|
18
|
+
uri = URI(uris[:matches])
|
19
|
+
a = uri.query.nil? ? [] : URI.decode_www_form(uri.query)
|
20
|
+
a << ["page[offset]", opt[:offset] || 0]
|
21
|
+
a << ["page[limit]", opt[:limit] || 5]
|
22
|
+
a << ["sort", opt[:sort] || "createdAt"]
|
23
|
+
uri.query = URI.encode_www_form(a)
|
24
|
+
get uri
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_match id
|
28
|
+
uri = URI(uris[:match].gsub(":match_id", id))
|
29
|
+
get uri
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_players opt={}
|
33
|
+
uri = URI(uris[:players])
|
34
|
+
a = uri.query.nil? ? [] : URI.decode_www_form(uri.query)
|
35
|
+
a << ["filter[playerNames]", opt[:player_names]] unless opt[:player_names].nil?
|
36
|
+
a << ["filter[playerIds]", opt[:player_ids]] unless opt[:player_ids].nil?
|
37
|
+
uri.query = URI.encode_www_form(a)
|
38
|
+
get uri
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_player id
|
42
|
+
uri = URI(uris[:player].gsub(":player_id", id))
|
43
|
+
get uri
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def get uri
|
48
|
+
req = Net::HTTP::Get.new(uri)
|
49
|
+
req["Authorization"] = api_key
|
50
|
+
req["Accept"] = "application/vnd.api+json"
|
51
|
+
|
52
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
53
|
+
http.request(req)
|
54
|
+
end
|
55
|
+
|
56
|
+
JSON.parse(res.body)
|
57
|
+
end
|
58
|
+
|
59
|
+
def api_key
|
60
|
+
ENV["BATTLERITE_API_KEY"]
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: battlerite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- eiko kokuma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: API wrapper for Battlerite
|
14
|
+
email: kokumeiko@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/battlerite.rb
|
20
|
+
homepage: https://gitlab.com/eiko/battlerite-ruby
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.13
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: API wrapper for Battlerite
|
44
|
+
test_files: []
|