cocRb 0.1.3 → 0.1.4
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 +74 -35
- data/lib/cocRb.rb +2 -0
- data/lib/cocRb/api.rb +29 -30
- data/lib/cocRb/clan.rb +200 -162
- data/lib/cocRb/clanWar.rb +198 -191
- data/lib/cocRb/gp.rb +47 -45
- data/lib/cocRb/labels.rb +47 -44
- data/lib/cocRb/league.rb +92 -102
- data/lib/cocRb/location.rb +78 -97
- data/lib/cocRb/player.rb +44 -40
- data/lib/cocRb/utility.rb +28 -24
- data/lib/cocRb/version.rb +1 -1
- metadata +16 -2
data/lib/cocRb/location.rb
CHANGED
@@ -1,137 +1,118 @@
|
|
1
|
-
require
|
1
|
+
require "faraday"
|
2
2
|
require "json"
|
3
3
|
|
4
4
|
module CocRb
|
5
|
-
|
6
|
-
|
5
|
+
class << self
|
6
|
+
attr_accessor :configuration
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.configure
|
10
|
-
|
11
|
-
|
10
|
+
@configuration ||= Configuration.new
|
11
|
+
yield(configuration)
|
12
12
|
end
|
13
13
|
|
14
14
|
class Configuration
|
15
|
-
|
16
|
-
|
15
|
+
attr_accessor :token, :url
|
17
16
|
def initialize
|
18
|
-
|
19
|
-
|
17
|
+
@token = nil
|
18
|
+
@url = nil
|
20
19
|
end
|
21
20
|
end
|
21
|
+
|
22
22
|
class Settings
|
23
|
+
|
23
24
|
def self.get
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
@conn = Faraday.new(
|
26
|
+
url:"https://api.clashofclans.com" ,
|
27
|
+
headers: {
|
28
|
+
'Content-Type' => 'application/json',
|
29
|
+
'Authorization' => "Bearer #{CocRb.configuration.token}"
|
29
30
|
}
|
30
31
|
)
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
rescue => e
|
33
|
+
raise "Oops Unexpected error Caught!"
|
34
|
+
puts e
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
class Location < Settings
|
39
|
+
# This method will get all the location ID including country name and country code.
|
40
|
+
def self.get_LocationId(_limit:false, status:false)
|
41
|
+
get
|
42
|
+
res = @conn.get("v1/locations") do |req|
|
43
|
+
req.params[:limit] = _limit if _limit
|
44
|
+
end
|
45
|
+
if status
|
46
|
+
res.status
|
47
|
+
else
|
48
|
+
val = res.body
|
49
|
+
convert = JSON.parse(val)
|
38
50
|
|
39
|
-
def self.get_LocationId(_limit:false, status:false)
|
40
|
-
get
|
41
|
-
res = @conn.get("v1/locations") do |req|
|
42
|
-
req.params[:limit] = _limit if _limit
|
43
|
-
end
|
44
|
-
|
45
|
-
if status
|
46
|
-
res.status
|
47
|
-
else
|
48
|
-
val = res.body
|
49
|
-
convert = JSON.parse(val)
|
50
51
|
end
|
51
|
-
|
52
|
-
|
53
52
|
end
|
54
|
-
|
55
|
-
def self.get_LocationInfo(locationId:, status:false)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
val = res.body
|
64
|
-
convert = JSON.parse(val)
|
53
|
+
# This method gets detailed location information takes Location as a paramter
|
54
|
+
def self.get_LocationInfo(locationId:, status:false)
|
55
|
+
get
|
56
|
+
res = @conn.get("v1/locations/#{locationId}")
|
57
|
+
if status
|
58
|
+
res.status
|
59
|
+
else
|
60
|
+
val = res.body
|
61
|
+
convert = JSON.parse(val)
|
65
62
|
end
|
66
|
-
|
67
|
-
|
68
63
|
end
|
69
64
|
|
70
65
|
|
71
|
-
def self.get_LocationRankClan(locationId:, _limit:false, status:false)
|
72
|
-
get
|
73
|
-
|
74
|
-
|
66
|
+
def self.get_LocationRankClan(locationId:, _limit:false, status:false)
|
67
|
+
get
|
68
|
+
res = @conn.get("v1/locations/#{locationId}/rankings/clans") do |req|
|
69
|
+
req.params[:limit] = _limit if _limit
|
75
70
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
val = res.body
|
82
|
-
convert = JSON.parse(val)
|
71
|
+
if status
|
72
|
+
res.status
|
73
|
+
else
|
74
|
+
val = res.body
|
75
|
+
convert = JSON.parse(val)
|
83
76
|
end
|
84
|
-
|
85
77
|
end
|
86
78
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
req.params[:limit] = _limit if _limit
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
if status
|
96
|
-
res.status
|
97
|
-
else
|
98
|
-
val = res.body
|
99
|
-
convert = JSON.parse(val)
|
79
|
+
def self.get_LocationRankPlayer(locationId:, _limit:false, status:false)
|
80
|
+
get
|
81
|
+
res = @conn.get("v1/locations/#{locationId}/rankings/players") do |req|
|
82
|
+
req.params[:limit] = _limit if _limit
|
100
83
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
req.params[:limit] = _limit if _limit
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
if status
|
111
|
-
res.status
|
112
|
-
else
|
113
|
-
val = res.body
|
114
|
-
convert = JSON.parse(val)
|
84
|
+
if status
|
85
|
+
res.status
|
86
|
+
else
|
87
|
+
val = res.body
|
88
|
+
convert = JSON.parse(val)
|
115
89
|
end
|
116
|
-
|
117
90
|
end
|
118
91
|
|
119
|
-
def self.
|
120
|
-
|
121
|
-
|
122
|
-
|
92
|
+
def self.get_LocationRankClanVersus(locationId:, _limit:false, status:false)
|
93
|
+
get
|
94
|
+
res = @conn.get("v1/locations/#{locationId}/rankings/clans-versus") do |req|
|
95
|
+
req.params[:limit] = _limit if _limit
|
123
96
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
convert = JSON.parse(val)
|
97
|
+
if status
|
98
|
+
res.status
|
99
|
+
else
|
100
|
+
val = res.body
|
101
|
+
convert = JSON.parse(val)
|
130
102
|
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
103
|
end
|
136
104
|
|
105
|
+
def self.get_LocationRankPlayerVersus(locationId:, _limit:false, status:false)
|
106
|
+
get
|
107
|
+
res = @conn.get("v1/locations/#{locationId}/rankings/players-versus") do |req|
|
108
|
+
req.params[:limit] = _limit if _limit
|
109
|
+
end
|
110
|
+
if status
|
111
|
+
res.status
|
112
|
+
else
|
113
|
+
val = res.body
|
114
|
+
convert = JSON.parse(val)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
137
118
|
end
|
data/lib/cocRb/player.rb
CHANGED
@@ -1,68 +1,72 @@
|
|
1
|
-
require
|
1
|
+
require "faraday"
|
2
2
|
require "json"
|
3
3
|
|
4
4
|
module CocRb
|
5
5
|
|
6
6
|
class << self
|
7
|
-
|
7
|
+
attr_accessor :configuration
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.configure
|
11
|
-
|
12
|
-
|
11
|
+
@configuration ||= Configuration.new
|
12
|
+
yield(configuration)
|
13
13
|
end
|
14
14
|
|
15
15
|
class Configuration
|
16
|
-
|
17
|
-
|
16
|
+
attr_accessor :token, :url
|
18
17
|
def initialize
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
@token = nil
|
19
|
+
@url = nil
|
22
20
|
end
|
21
|
+
end
|
22
|
+
|
23
23
|
class Settings
|
24
|
+
|
24
25
|
def self.get
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
@conn = Faraday.new(
|
27
|
+
url:"https://api.clashofclans.com" ,
|
28
|
+
headers: {
|
29
|
+
'Content-Type' => 'application/json',
|
30
|
+
'Authorization' => "Bearer #{CocRb.configuration.token}"
|
30
31
|
}
|
31
32
|
)
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
rescue => e
|
34
|
+
raise "Oops Unexpected error Caught!"
|
35
|
+
puts e
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
37
39
|
class Player < Settings
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
|
41
|
+
def self.get_PlayerByTag(tag:, status: false)
|
42
|
+
get
|
43
|
+
io = tag
|
44
|
+
tag1 = io.gsub('#', '%23')
|
45
|
+
res = @conn.get("v1/players/#{tag1}")
|
43
46
|
|
44
47
|
if status
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
48
|
+
res.status
|
49
|
+
else
|
50
|
+
val = res.body
|
51
|
+
convert = JSON.parse(val)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.verify_PlayerByToken(tag:, playertoken:)
|
56
|
+
get
|
57
|
+
io = tag
|
51
58
|
|
59
|
+
tag1 = io.gsub('#', '%23')
|
52
60
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
res = @conn.post("v1/players/#{tag1}/verifytoken") do |req|
|
58
|
-
req.body = {
|
59
|
-
token: playertoken
|
60
|
-
}.to_json
|
61
|
+
res = @conn.post("v1/players/#{tag1}/verifytoken") do |req|
|
62
|
+
req.body = {
|
63
|
+
token: playertoken
|
64
|
+
}.to_json
|
61
65
|
end
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
val = res.body
|
68
|
+
convert = JSON.parse(val)
|
65
69
|
|
66
|
-
end
|
67
|
-
|
70
|
+
end
|
71
|
+
end
|
68
72
|
end
|
data/lib/cocRb/utility.rb
CHANGED
@@ -1,43 +1,47 @@
|
|
1
|
-
require
|
1
|
+
require "faraday"
|
2
2
|
|
3
3
|
module CocRb
|
4
4
|
|
5
5
|
class << self
|
6
|
-
|
6
|
+
attr_accessor :configuration
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.configure
|
10
|
-
|
11
|
-
|
10
|
+
@configuration ||= Configuration.new
|
11
|
+
yield(configuration)
|
12
12
|
end
|
13
13
|
|
14
14
|
class Configuration
|
15
|
-
|
16
|
-
|
15
|
+
attr_accessor :token, :url
|
17
16
|
def initialize
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
@token = nil
|
18
|
+
@url = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
22
|
class Settings
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
|
24
|
+
def self.get
|
25
|
+
@conn = Faraday.new(
|
26
|
+
url:"https://api.clashofclans.com",
|
27
|
+
headers: {
|
28
|
+
'Content-Type' => 'application/json',
|
29
|
+
'Authorization' => "Bearer #{CocRb.configuration.token}"
|
29
30
|
}
|
30
31
|
)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
rescue => e
|
33
|
+
raise "Oops Unexpected error Caught!"
|
34
|
+
puts e
|
35
|
+
end
|
35
36
|
end
|
37
|
+
|
38
|
+
|
36
39
|
class Check < Settings
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
|
41
|
+
def self.check_headers
|
42
|
+
get
|
43
|
+
res = @conn.get(CocRb.configuration.url)
|
44
|
+
res.headers
|
41
45
|
end
|
42
46
|
end
|
43
47
|
end
|
data/lib/cocRb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocRb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crusader123
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.3.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.3.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: faraday
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|