Class: ATS::AMP4E::API
- Inherits:
-
Object
- Object
- ATS::AMP4E::API
- Defined in:
- lib/ats/amp4e/api.rb
Constant Summary collapse
- HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'User-Agent' => "RubyGems/ATS #{ATS::VERSION}", }.freeze
Instance Attribute Summary collapse
-
#bearer_token ⇒ Object
readonly
Returns the value of attribute bearer_token.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
- #computers ⇒ Object
- #events ⇒ Object
- #get(url, params: {}, version: 1) ⇒ Object
- #groups ⇒ Object
-
#initialize(configuration:, debug: false) ⇒ API
constructor
A new instance of API.
- #policies ⇒ Object
Constructor Details
#initialize(configuration:, debug: false) ⇒ API
Returns a new instance of API.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ats/amp4e/api.rb', line 13 def initialize(configuration:, debug: false) @http = Net::Hippie::Client.new(headers: HEADERS, verify_mode: debug ? OpenSSL::SSL::VERIFY_NONE : nil) @configuration = configuration @port = configuration[:port] @scheme = configuration[:scheme] @host = configuration[:host] @bearer_token = configuration[:bearer_token] @client_id = configuration[:client_id] @client_secret = configuration[:client_secret] end |
Instance Attribute Details
#bearer_token ⇒ Object (readonly)
Returns the value of attribute bearer_token.
11 12 13 |
# File 'lib/ats/amp4e/api.rb', line 11 def bearer_token @bearer_token end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
11 12 13 |
# File 'lib/ats/amp4e/api.rb', line 11 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
11 12 13 |
# File 'lib/ats/amp4e/api.rb', line 11 def client_secret @client_secret end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def host @host end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def http @http end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def port @port end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def scheme @scheme end |
Instance Method Details
#computers ⇒ Object
24 25 26 |
# File 'lib/ats/amp4e/api.rb', line 24 def computers ATS::AMP4E::Computers.new(self) end |
#events ⇒ Object
28 29 30 |
# File 'lib/ats/amp4e/api.rb', line 28 def events ATS::AMP4E::Events.new(self) end |
#get(url, params: {}, version: 1) ⇒ Object
40 41 42 43 44 |
# File 'lib/ats/amp4e/api.rb', line 40 def get(url, params: {}, version: 1) http.get(build_uri(url, version: version), headers: headers, body: params) do |request, response| JSON.parse(response.body, symbolize_names: true) end end |