summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2018-03-19 15:38:34 -0600
committermokha <mokha@cisco.com>2018-03-19 15:38:34 -0600
commitf8abd4677bd4d31e408ccfdf0c468f67c2a9f2d9 (patch)
tree503998501f464d61296f01fecb3bdcbb01f8e400
parent43e6ab21b611bc7e743f150ce97f414f0711992a (diff)
methods to instance variables.
-rw-r--r--lib/ats/amp4e/api.rb27
-rw-r--r--lib/ats/threat_grid/api.rb24
2 files changed, 11 insertions, 40 deletions
diff --git a/lib/ats/amp4e/api.rb b/lib/ats/amp4e/api.rb
index dc57ab7..1664ec8 100644
--- a/lib/ats/amp4e/api.rb
+++ b/lib/ats/amp4e/api.rb
@@ -7,11 +7,16 @@ module ATS
'User-Agent' => "RubyGems/ATS #{ATS::VERSION}",
}.freeze
- attr_reader :http, :configuration
+ attr_reader :http, :port, :host, :scheme, :client_id, :client_secret
def initialize(configuration:, debug: false)
@http = HttpAPI.new(headers: HEADERS, debug: debug)
@configuration = configuration
+ @port = configuration[:port]
+ @scheme = configuration[:scheme]
+ @host = configuration[:host]
+ @client_id = configuration[:client_id]
+ @client_secret = configuration[:client_secret]
end
def computers
@@ -42,26 +47,6 @@ module ATS
URI::Generic.build(host: host, port: port, scheme: scheme, path: "/v#{version}/#{relative_url}")
end
- def client_id
- configuration[:client_id]
- end
-
- def client_secret
- configuration[:client_secret]
- end
-
- def host
- configuration[:host]
- end
-
- def scheme
- configuration[:scheme]
- end
-
- def port
- configuration[:port]
- end
-
def headers
{ AUTHORIZATION: "Basic #{Base64.strict_encode64("#{client_id}:#{client_secret}")}" }
end
diff --git a/lib/ats/threat_grid/api.rb b/lib/ats/threat_grid/api.rb
index a66456f..1f2fa83 100644
--- a/lib/ats/threat_grid/api.rb
+++ b/lib/ats/threat_grid/api.rb
@@ -1,5 +1,3 @@
-require 'ats/http_api'
-
module ATS
module ThreatGrid
class API
@@ -8,11 +6,15 @@ module ATS
'User-Agent' => "RubyGems/ATS #{ATS::VERSION}",
}.freeze
- attr_reader :http, :configuration
+ attr_reader :http, :port, :host, :scheme, :api_key
def initialize(configuration:, debug: false)
@http = HttpAPI.new(headers: HEADERS, debug: debug)
@configuration = configuration
+ @port = configuration[:port]
+ @scheme = configuration[:scheme]
+ @host = configuration[:host]
+ @api_key = configuration[:api_key]
end
def whoami
@@ -50,22 +52,6 @@ module ATS
def build_uri(relative_url, version:)
URI::Generic.build(host: host, port: port, scheme: scheme, path: "/api/v#{version}/#{relative_url}")
end
-
- def api_key
- configuration[:api_key]
- end
-
- def host
- configuration[:host]
- end
-
- def scheme
- configuration[:scheme]
- end
-
- def port
- configuration[:port]
- end
end
end
end