Sha256: 5ff251f1bfbac3fdce85e8221e0b13b3dbd537ca6ab0534ecb2b03debff2d789

Contents?: true

Size: 862 Bytes

Versions: 189

Compression:

Stored size: 862 Bytes

Contents

module Appsignal
  class AuthCheck
    ACTION = 'auth'.freeze

    attr_reader :config, :logger

    def initialize(config, 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

189 entries across 189 versions & 1 rubygems

Version Path
appsignal-0.12.rc.10 lib/appsignal/auth_check.rb
appsignal-0.12.rc.9 lib/appsignal/auth_check.rb
appsignal-0.12.rc.8 lib/appsignal/auth_check.rb
appsignal-0.12.rc.7 lib/appsignal/auth_check.rb
appsignal-0.12.rc.6 lib/appsignal/auth_check.rb
appsignal-0.12.rc.5 lib/appsignal/auth_check.rb
appsignal-0.12.beta.54 lib/appsignal/auth_check.rb
appsignal-0.12.beta.53 lib/appsignal/auth_check.rb
appsignal-0.12.beta.52 lib/appsignal/auth_check.rb
appsignal-0.12.beta.51 lib/appsignal/auth_check.rb
appsignal-0.11.17 lib/appsignal/auth_check.rb
appsignal-0.12.beta.50 lib/appsignal/auth_check.rb
appsignal-0.12.beta.49 lib/appsignal/auth_check.rb
appsignal-0.11.16 lib/appsignal/auth_check.rb
appsignal-0.12.beta.48 lib/appsignal/auth_check.rb
appsignal-0.12.beta.47 lib/appsignal/auth_check.rb
appsignal-0.12.beta.46 lib/appsignal/auth_check.rb
appsignal-0.12.beta.45 lib/appsignal/auth_check.rb
appsignal-0.12.beta.44 lib/appsignal/auth_check.rb
appsignal-0.12.beta.43 lib/appsignal/auth_check.rb