Sha256: f4ddc4a5b82efd1efd7266b85ac46c5fae1e8feff1d037a3ce504c1b9691c138

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'faraday'
require 'json'

module Rollman
  module Connection
    API_ENDPOINT = "https://api.rollbar.com".freeze

    def get(url, options = {})
      request :get, url, options
    end

    def post(url, options = {})
      request :post, url, options
    end

    def agent
      Faraday.new(endpoint) do |http|
        http.request :url_encoded
        http.response :logger do |logger|
          logger.filter(/(access_token=)(\w+)/,'\1[REMOVED]')
        end
        http.adapter Faraday.default_adapter
      end
    end

    def endpoint
      API_ENDPOINT
    end

    private

    def request(method, path, options = {})
      options.merge!({access_token: @access_token})

      response = agent.__send__(method, path, options)
      JSON.parse(response.body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollman-0.1.0 lib/rollman/connection.rb