Class: RooOnRails::PapertrailClient

Inherits:
Object
  • Object
show all
Defined in:
lib/roo_on_rails/papertrail_client.rb

Instance Method Summary collapse

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_urlObject



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

#_connObject

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_destinationsObject



11
12
13
# File 'lib/roo_on_rails/papertrail_client.rb', line 11

def list_destinations
  _conn.get('destinations.json').body
end

#list_systemsObject



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