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.beta.25 lib/appsignal/auth_check.rb
appsignal-0.12.beta.24 lib/appsignal/auth_check.rb
appsignal-0.12.beta.23 lib/appsignal/auth_check.rb
appsignal-0.12.beta.22 lib/appsignal/auth_check.rb
appsignal-0.12.beta.21 lib/appsignal/auth_check.rb
appsignal-0.12.beta.20 lib/appsignal/auth_check.rb
appsignal-0.12.beta.19 lib/appsignal/auth_check.rb
appsignal-0.12.beta.18 lib/appsignal/auth_check.rb
appsignal-0.12.beta.17 lib/appsignal/auth_check.rb
appsignal-0.11.13 lib/appsignal/auth_check.rb
appsignal-0.12.beta.16 lib/appsignal/auth_check.rb
appsignal-0.12.beta.15 lib/appsignal/auth_check.rb
appsignal-0.11.13.beta.4 lib/appsignal/auth_check.rb
appsignal-0.11.13.beta.3 lib/appsignal/auth_check.rb
appsignal-0.11.13.beta.2 lib/appsignal/auth_check.rb
appsignal-0.12.beta.14 lib/appsignal/auth_check.rb
appsignal-0.12.beta.13 lib/appsignal/auth_check.rb
appsignal-0.12.beta.12 lib/appsignal/auth_check.rb
appsignal-0.12.beta.11 lib/appsignal/auth_check.rb
appsignal-0.12.beta.9 lib/appsignal/auth_check.rb