Class: RooOnRails::PapertrailClient
- Inherits:
-
Object
- Object
- RooOnRails::PapertrailClient
- Defined in:
- lib/roo_on_rails/papertrail_client.rb
Instance Method Summary collapse
- #_api_url ⇒ Object
-
#_conn ⇒ Object
private.
- #get_system(id) ⇒ Object
-
#initialize(token:) ⇒ PapertrailClient
constructor
A new instance of PapertrailClient.
- #list_destinations ⇒ Object
- #list_systems ⇒ Object
- #update_system(id, data) ⇒ Object
Constructor Details
#initialize(token:) ⇒ PapertrailClient
Returns a new instance of PapertrailClient.
7 8 9 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 7 def initialize(token:) @token = token end |
Instance Method Details
#_api_url ⇒ Object
41 42 43 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 41 def _api_url @_api_url = URI.parse('https://papertrailapp.com/api/v1') end |
#_conn ⇒ Object
private
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 29 def _conn @_conn ||= Faraday.new(_api_url, headers: { 'X-Papertrail-Token' => @token }) do |conf| conf.response :mashify conf.response :json conf.response :raise_error # conf.response :logger conf.request :json conf.adapter Faraday.default_adapter end end |
#get_system(id) ⇒ Object
19 20 21 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 19 def get_system(id) _conn.get('systems/%s.json' % id).body end |
#list_destinations ⇒ Object
11 12 13 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 11 def list_destinations _conn.get('destinations.json').body end |
#list_systems ⇒ Object
15 16 17 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 15 def list_systems _conn.get('systems.json').body end |
#update_system(id, data) ⇒ Object
23 24 25 |
# File 'lib/roo_on_rails/papertrail_client.rb', line 23 def update_system(id, data) _conn.put('systems/%s.json' % id, system: { name: data }).body end |