Sha256: 3ff1839ced667c04914f0508ee447c2944e4721327d51d9cb56678a887928d54

Contents?: true

Size: 934 Bytes

Versions: 20

Compression:

Stored size: 934 Bytes

Contents

require 'faraday'
require 'faraday_middleware'
require 'json'

module RooOnRails
  class PapertrailClient
    def initialize(token:)
      @token = token
    end

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

    def list_systems
      _conn.get('systems.json').body
    end

    def get_system(id)
      _conn.get('systems/%s.json' % id).body
    end

    def update_system(id, data)
      _conn.put('systems/%s.json' % id, system: { name: data }).body
    end

    # private

    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

    def _api_url
      @_api_url = URI.parse('https://papertrailapp.com/api/v1')
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
roo_on_rails-2.2.2 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.2.1 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.2.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.1.2 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.1.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.0.0.pre.pre.2 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-2.0.0.pre.pre.1 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.22.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.21.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.20.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.19.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.18.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.17.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.16.2 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.16.1 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.16.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.15.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.14.0 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.13.1 lib/roo_on_rails/papertrail_client.rb
roo_on_rails-1.13.0 lib/roo_on_rails/papertrail_client.rb