Sha256: a2105990aa8c57483b5f488057194475ed00f57871591cdf2c98eab24fe068d3

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

module AirbrakeAPI
  class Base
    include HTTParty
    format :xml

    private

    def self.setup
      base_uri AirbrakeAPI.account_path
      default_params :auth_token => AirbrakeAPI.auth_token

      check_configuration
    end

    def self.check_configuration
      raise AirbrakeError.new('API Token cannot be nil') if default_options.nil? || default_options[:default_params].nil? || !default_options[:default_params].has_key?(:auth_token)
      raise AirbrakeError.new('Account cannot be nil') unless default_options.has_key?(:base_uri)
    end

    def self.fetch(path, options)
      response = get(path, { :query => options })
      if response.code == 403
        raise AirbrakeError.new('SSL should be enabled - use AirbrakeAPI.secure = true in configuration')
      end

      Hashie::Mash.new(response)
    end

  end
end

# airbrake sometimes returns broken xml with invalid xml tag names
# so we remove them
require 'httparty/parser'
class HTTParty::Parser
  def xml
    body.gsub!(/<__utmz>.*?<\/__utmz>/m,'')
    body.gsub!(/<[0-9]+.*?>.*?<\/[0-9]+.*?>/m,'')
    MultiXml.parse(body)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
airbrake-api-3.3.0 lib/airbrake-api/client.rb
airbrake-api-3.2.3 lib/airbrake-api/client.rb
airbrake-api-3.2.2 lib/airbrake-api/client.rb
airbrake-api-3.2.1 lib/airbrake-api/client.rb
airbrake-api-3.2.0 lib/airbrake-api/client.rb