Sha256: 9f1e9361a06d297a3b4e1ff258f4d328b8109fa55ff19d78547de19dea00fc25

Contents?: true

Size: 879 Bytes

Versions: 61

Compression:

Stored size: 879 Bytes

Contents

module Appsignal
  class AuthCheck
    ACTION = 'auth'.freeze

    attr_reader :config, :logger

    def initialize(config, logger=Appsignal.logger)
      @config = config
      @logger = logger
    end

    def perform
      Appsignal::Transmitter.new(ACTION, config).transmit({})
    end

    def perform_with_result
      begin
        status = perform
        case status
        when '200'
          result = 'AppSignal has confirmed authorization!'
        when '401'
          result = 'API key not valid with AppSignal...'
        else
          result = 'Could not confirm authorization: '\
                   "#{status.nil? ? 'nil' : status}"
        end
        [status, result]
      rescue Exception => e
        result = 'Something went wrong while trying to '\
                 "authenticate with AppSignal: #{e}"
        [nil, result]
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
appsignal-1.3.6 lib/appsignal/auth_check.rb
appsignal-1.3.6.beta.1 lib/appsignal/auth_check.rb
appsignal-1.3.5 lib/appsignal/auth_check.rb
appsignal-1.3.5.beta.1 lib/appsignal/auth_check.rb
appsignal-1.3.4 lib/appsignal/auth_check.rb
appsignal-1.3.3 lib/appsignal/auth_check.rb
appsignal-1.4.0.alpha.2 lib/appsignal/auth_check.rb
appsignal-1.4.0.alpha.1 lib/appsignal/auth_check.rb
appsignal-1.3.2 lib/appsignal/auth_check.rb
appsignal-1.3.1 lib/appsignal/auth_check.rb
appsignal-1.3.0 lib/appsignal/auth_check.rb
appsignal-1.3.0.beta.3 lib/appsignal/auth_check.rb
appsignal-1.3.0.beta.2 lib/appsignal/auth_check.rb
appsignal-1.3.0.beta.1 lib/appsignal/auth_check.rb
appsignal-1.2.5 lib/appsignal/auth_check.rb
appsignal-1.2.4 lib/appsignal/auth_check.rb
appsignal-1.2.4.beta.4 lib/appsignal/auth_check.rb
appsignal-1.2.4.beta.3 lib/appsignal/auth_check.rb
appsignal-1.2.4.beta.2 lib/appsignal/auth_check.rb
appsignal-1.2.4.beta.1 lib/appsignal/auth_check.rb