diff options
| -rw-r--r-- | lib/ats/amp4e/api.rb | 27 | ||||
| -rw-r--r-- | lib/ats/threat_grid/api.rb | 24 |
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 |
