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
-
#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.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ats/amp4e/api.rb', line 12 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 |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 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
22 23 24 |
# File 'lib/ats/amp4e/api.rb', line 22 def computers ATS::AMP4E::Computers.new(self) end |
#events ⇒ Object
26 27 28 |
# File 'lib/ats/amp4e/api.rb', line 26 def events ATS::AMP4E::Events.new(self) end |
#get(url, params: {}, version: 1) ⇒ Object
38 39 40 41 42 |
# File 'lib/ats/amp4e/api.rb', line 38 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 |