tt2 0.1.0 → 0.1.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 +4 -4
- data/lib/tt2.rb +2 -0
- data/lib/tt2/api.rb +54 -0
- data/lib/tt2/client.rb +4 -18
- data/lib/tt2/client/server_time.rb +8 -0
- data/lib/tt2/util.rb +4 -1
- data/lib/tt2/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08eb90cc5e429850613e0be0e9b966553bf58c03'
|
4
|
+
data.tar.gz: ac3ddeb75fa3e99ce8afd72e940660415eef5a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f940ff584c6b41f9acac46813cbccc8a91f3331566f31e7d56a7ff1fe29c49793d8b06b6a16b4f47e719969af2d283a4b530ac1b34df09c1b2bf8990bdc89336
|
7
|
+
data.tar.gz: 7d49fa5d354332260d3fda11cb483fec2229ee9437dc496629b185d925755a35f59cbbd8b5a42a84429bdd15ced56e02a122364b4c81bd9918b16707fc50564d
|
data/lib/tt2.rb
CHANGED
data/lib/tt2/api.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module TT2
|
4
|
+
class API
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
attr_accessor :player_id, :auth_token, :created_at
|
8
|
+
attr_writer :ad_id
|
9
|
+
|
10
|
+
base_uri 'https://tt2.gamehivegames.com'
|
11
|
+
headers 'Accept' => 'application/vnd.gamehive.btb4-v1.0+json',
|
12
|
+
'User-Agent' => 'BestHTTP',
|
13
|
+
'Content-Type' => 'application/json; charset=UTF-8'
|
14
|
+
|
15
|
+
def ad_id
|
16
|
+
@ad_id || '00000000-0000-0000-0000-000000000000'
|
17
|
+
end
|
18
|
+
|
19
|
+
def query_params(body = '', overrides: {})
|
20
|
+
{ d: 'ios',
|
21
|
+
v: '1.7.1',
|
22
|
+
time: TT2::Util.current_time_ticks,
|
23
|
+
dummy: Time.now - @created_at,
|
24
|
+
s: TT2::Util.request_signature(body, ad_id: ad_id) }.merge(overrides)
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_body(params = {})
|
28
|
+
base = { ad_id: ad_id,
|
29
|
+
player_id: player_id }
|
30
|
+
JSON.generate(base.merge(params))
|
31
|
+
end
|
32
|
+
|
33
|
+
def reset_time
|
34
|
+
@created_at = Time.now
|
35
|
+
end
|
36
|
+
|
37
|
+
def get(url)
|
38
|
+
self.class.get(url)
|
39
|
+
end
|
40
|
+
|
41
|
+
def post(url, body_params = {})
|
42
|
+
body = request_body(body_params)
|
43
|
+
post_opts = {
|
44
|
+
query: query_params(body),
|
45
|
+
body: body,
|
46
|
+
headers: {
|
47
|
+
'X-HTTP-Method-Override' => 'POST',
|
48
|
+
'Authorization' => "token #{auth_token}"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
self.class.post(url, post_opts)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/tt2/client.rb
CHANGED
@@ -1,21 +1,11 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
|
2
3
|
module TT2
|
3
4
|
# The TT2 API client
|
4
|
-
class Client
|
5
|
-
|
6
|
-
|
7
|
-
base_uri 'https://tt2.gamehivegames.com'
|
8
|
-
headers 'Accept' => 'application/vnd.gamehive.btb4-v1.0+json',
|
9
|
-
'User-Agent' => 'BestHTTP',
|
10
|
-
'Content-Type' => 'application/json; charset=UTF-8'
|
5
|
+
class Client < API
|
6
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
|
11
7
|
|
12
|
-
|
13
|
-
{ d: 'ios',
|
14
|
-
v: '1.7.1',
|
15
|
-
time: Tt2::Util.current_time_ticks,
|
16
|
-
dummy: Time.now - @created_at,
|
17
|
-
s: Tt2::Util.request_signature(data) }
|
18
|
-
end
|
8
|
+
include ServerTime
|
19
9
|
|
20
10
|
def initialize(player_id:, auth_token:)
|
21
11
|
@player_id = player_id
|
@@ -23,9 +13,5 @@ module TT2
|
|
23
13
|
|
24
14
|
reset_time
|
25
15
|
end
|
26
|
-
|
27
|
-
def reset_time
|
28
|
-
@created_at = Time.now
|
29
|
-
end
|
30
16
|
end
|
31
17
|
end
|
data/lib/tt2/util.rb
CHANGED
@@ -3,6 +3,8 @@ require 'openssl'
|
|
3
3
|
module TT2
|
4
4
|
# This is where all of the fun utility functions like to come and hang out.
|
5
5
|
module Util
|
6
|
+
module_function
|
7
|
+
|
6
8
|
BOSSES = %w[ Sponkinack Lucanus Caratacos Sklatborg Drakon
|
7
9
|
Straton Grokstomp Grekksfist Zeksgrat FumpTorm
|
8
10
|
RamBloggs Brongunk Plogriftus Darmbonack Gredmash
|
@@ -37,7 +39,8 @@ module TT2
|
|
37
39
|
AVATARS = {}.freeze
|
38
40
|
|
39
41
|
# The signature hash for all requests
|
40
|
-
def request_signature(data,
|
42
|
+
def request_signature(data, ad_id: '00000000-0000-0000-0000-000000000000')
|
43
|
+
key = ad_id[1] + ad_id[0] + ad_id[3]
|
41
44
|
digest = OpenSSL::Digest.new('md5')
|
42
45
|
OpenSSL::HMAC.hexdigest(digest, key, data)
|
43
46
|
end
|
data/lib/tt2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tt2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,7 +119,9 @@ files:
|
|
119
119
|
- README.md
|
120
120
|
- exe/tt2
|
121
121
|
- lib/tt2.rb
|
122
|
+
- lib/tt2/api.rb
|
122
123
|
- lib/tt2/client.rb
|
124
|
+
- lib/tt2/client/server_time.rb
|
123
125
|
- lib/tt2/save_parser.rb
|
124
126
|
- lib/tt2/util.rb
|
125
127
|
- lib/tt2/version.rb
|