cocRb 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,137 +1,118 @@
1
- require 'faraday'
1
+ require "faraday"
2
2
  require "json"
3
3
 
4
4
  module CocRb
5
- class << self
6
- attr_accessor :configuration
5
+ class << self
6
+ attr_accessor :configuration
7
7
  end
8
8
 
9
9
  def self.configure
10
- @configuration ||= Configuration.new
11
- yield(configuration)
10
+ @configuration ||= Configuration.new
11
+ yield(configuration)
12
12
  end
13
13
 
14
14
  class Configuration
15
- attr_accessor :token, :url
16
-
15
+ attr_accessor :token, :url
17
16
  def initialize
18
- @token = nil
19
- @url = nil
17
+ @token = nil
18
+ @url = nil
20
19
  end
21
20
  end
21
+
22
22
  class Settings
23
+
23
24
  def self.get
24
- @conn = Faraday.new(
25
- url:"https://api.clashofclans.com" ,
26
- headers: {
27
- 'Content-Type' => 'application/json',
28
- 'Authorization' => "Bearer #{CocRb.configuration.token}"
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
- rescue => e
32
- raise "Oops Unexpected error Caught!"
33
- puts e
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
- get
57
- res = @conn.get("v1/locations/#{locationId}")
58
-
59
-
60
- if status
61
- res.status
62
- else
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
- res = @conn.get("v1/locations/#{locationId}/rankings/clans") do |req|
74
- req.params[:limit] = _limit if _limit
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
- if status
79
- res.status
80
- else
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
- def self.get_LocationRankPlayer(locationId:, _limit:false, status:false)
89
- get
90
- res = @conn.get("v1/locations/#{locationId}/rankings/players") do |req|
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
- end
103
- def self.get_LocationRank_ClanVersus(locationId:, _limit:false, status:false)
104
- get
105
- res = @conn.get("v1/locations/#{locationId}/rankings/clans-versus") do |req|
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.get_LocationRank_PlayerVersus(locationId:, _limit:false, status:false)
120
- get
121
- res = @conn.get("v1/locations/#{locationId}/rankings/players-versus") do |req|
122
- req.params[:limit] = _limit if _limit
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
- if status
126
- res.status
127
- else
128
- val = res.body
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 'faraday'
1
+ require "faraday"
2
2
  require "json"
3
3
 
4
4
  module CocRb
5
5
 
6
6
  class << self
7
- attr_accessor :configuration
7
+ attr_accessor :configuration
8
8
  end
9
9
 
10
10
  def self.configure
11
- @configuration ||= Configuration.new
12
- yield(configuration)
11
+ @configuration ||= Configuration.new
12
+ yield(configuration)
13
13
  end
14
14
 
15
15
  class Configuration
16
- attr_accessor :token, :url
17
-
16
+ attr_accessor :token, :url
18
17
  def initialize
19
- @token = nil
20
- @url = nil
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
- @conn = Faraday.new(
26
- url:"https://api.clashofclans.com" ,
27
- headers: {
28
- 'Content-Type' => 'application/json',
29
- 'Authorization' => "Bearer #{CocRb.configuration.token}"
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
- rescue => e
33
- raise "Oops Unexpected error Caught!"
34
- puts e
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
- def self.getPlayerBy_Tag(tag:, status: false)
39
- get
40
- io = tag
41
- tag1 = io.gsub('#', '%23')
42
- res = @conn.get("v1/players/#{tag1}")
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
- res.status
46
- else
47
- val = res.body
48
- convert = JSON.parse(val)
49
- end
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
- def self.verifyPlayer(tag:, playertoken:)
54
- get
55
- io = tag
56
- tag1 = io.gsub('#', '%23')
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
- val = res.body
64
- convert = JSON.parse(val)
67
+ val = res.body
68
+ convert = JSON.parse(val)
65
69
 
66
- end
67
- end
70
+ end
71
+ end
68
72
  end
data/lib/cocRb/utility.rb CHANGED
@@ -1,43 +1,47 @@
1
- require 'faraday'
1
+ require "faraday"
2
2
 
3
3
  module CocRb
4
4
 
5
5
  class << self
6
- attr_accessor :configuration
6
+ attr_accessor :configuration
7
7
  end
8
8
 
9
9
  def self.configure
10
- @configuration ||= Configuration.new
11
- yield(configuration)
10
+ @configuration ||= Configuration.new
11
+ yield(configuration)
12
12
  end
13
13
 
14
14
  class Configuration
15
- attr_accessor :token, :url
16
-
15
+ attr_accessor :token, :url
17
16
  def initialize
18
- @token = nil
19
- @url = nil
20
- end
21
- end
17
+ @token = nil
18
+ @url = nil
19
+ end
20
+ end
21
+
22
22
  class Settings
23
- def self.get
24
- @conn = Faraday.new(
25
- url:"https://api.clashofclans.com",
26
- headers: {
27
- 'Content-Type' => 'application/json',
28
- 'Authorization' => "Bearer #{CocRb.configuration.token}"
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
- rescue => e
32
- raise "Oops Unexpected error Caught!"
33
- puts e
34
- end
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
- def self.check_headers
38
- get
39
- res = @conn.get(CocRb.configuration.url)
40
- res.headers
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CocRb
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
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.3
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-05 00:00:00.000000000 Z
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